Skip to content

Instantly share code, notes, and snippets.

View emchateau's full-sized avatar

Emmanuel Château-Dutier emchateau

View GitHub Profile
@emchateau
emchateau / bxListFiles
Created February 18, 2014 11:56
List all files in the directory of your query file in BaseX
(: list all files in the directory of your query file in BaseX :)
let $dir := file:parent(static-base-uri())
for $file in file:list($dir)
return $dir || $file
@emchateau
emchateau / bxCurrentWorkingDir
Created February 18, 2014 11:57
Find out the current working directory in BaseX
(: find out the current working directory in BaseX :)
file:parent('.')
<?xml version="1.0" encoding="UTF-8"?>
<!--
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@Name : .xsl
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@version : 000
@creaDate : 2014/
@modifDate
@vXslt: 2.0
@autor : Emmanuel Château emchateau@laposte.net
@emchateau
emchateau / splitContentAsAttributeValues.xsl
Last active August 29, 2015 14:01
Split content as attribute values
<!-- Split content as attribute value -->
<xsl:template match="element[@id]">
<xsl:variable name="att-values" select="tokenize(@id, ', ')"/>
<xsl:for-each select="tokenize(., '; ')">
<xsl:variable name="pos" select="position()"/>
<xsl:if test="position() gt 1"><xsl:text>; </xsl:text></xsl:if>
<a href="#{$att-values[$pos]}">
<xsl:value-of select="."/>
</a>
</xsl:for-each>
<div>
<h2>{$heading} - {count($actions/generate)}</h2>
<p>Actions are processes that generate a new item from an existing item.</p>
<div>
{$partial("action1.xml","action",$actions/generate )}
</div>
</div>
# Requirements:
# - pen drive formatted in FAT
# - boot.img.gz downloaded from: http://ftp.debian.org/debian/dists/Debian6.0.2/main/installer-amd64/current/images/hd-media/
# - netinstall iso image http://cdimage.debian.org/debian-cd/6.0.2.1/amd64/iso-cd/
# - pen drive is on /dev/disk1 -> check with "diskutil list"
diskutil unmountDisk /dev/disk1
gzip -dc boot.img.gz >/dev/disk1
diskutil eject /dev/disk1
# mount pen drive again
# add iso image to the pen drive
@emchateau
emchateau / strict.xhtml
Created November 9, 2014 09:40
A minimal strict xhtml file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
</head>
<body>
</body>
</html>
@emchateau
emchateau / tokenizeToElements.xq
Last active August 29, 2015 14:10 — forked from xquery/gist:1536327
This function tokenize a string and returns each token in an xml element
xquery version "1.0";
(:~
: This function tokenize a string and returns each text item in a <text/> element
:)
let $string := "test,test,test,test,test"
return
for $text in tokenize($string,',')
return
<text>{concat('add some text: ', $text)}</text>
@emchateau
emchateau / identityTransform.xq
Last active August 29, 2015 14:14
This function returns a deep copy of the elements and all sub-elements (Identity transform)
xquery version "1.0" ;
(:~
: This function returns a deep copy of the elements and all sub-elements
: Identity transform
: copies the input directly to the output without modification
: @source http://en.wikipedia.org/wiki/Identity_transform
:)
declare function local:copy($element as element()) as element() {
element {node-name($element)}{
$element/@*,
@emchateau
emchateau / identityTransformWithTypeswitch.xq
Last active August 29, 2015 14:14
This function returns a deep copy of the elements and all sub-elements (identity transform with typeswitch)
xquery version "1.0";
(:~
: This function returns a deep copy of the elements and all sub-elements
: (identity transform with typeswitch)
: copies the input to the output without modification
: @source http://en.wikibooks.org/wiki/XQuery/Typeswitch_Transformations
:)
declare function local:copy($input as item()*) as item()* {
for $node in $input
return typeswitch($node)