Skip to content

Instantly share code, notes, and snippets.

@evanlenz
Created June 2, 2011 22:43
Show Gist options
  • Save evanlenz/1005505 to your computer and use it in GitHub Desktop.
Save evanlenz/1005505 to your computer and use it in GitHub Desktop.
declare variable $doc := document {
<groups>
<group>
<item>first item</item>
<item>second item</item>
</group>
<group>
<item>third item</item>
<item>fourth item</item>
</group>
</groups>
};
$doc/groups/group/item
$doc/groups/group/item/substring-before(.,' item')
$doc/groups/group/item/substring-before(.,' item')/upper-case(.) (:illegal:)
for $str in $doc/groups/group/item/substring-before(.,' item')
return upper-case($str)
(1 to 3)/concat('#',.)
for $n in (1 to 3) return concat('#',$n)
$doc/groups/group/item/(., string(.)) (:illegal:)
for $item in $doc/groups/group/item return ($item, string($item))
$doc/groups/group/item
for $step1 in $doc return (: $step1 bound once :)
for $step2 in $step1/groups return (: $step2 bound once :)
for $step3 in $step2/group return (: $step3 bound twice :)
for $step4 in $step3/item return $step4 (: $step4 bound four times :)
($doc/groups/group[2],
$doc/groups/group[1],
$doc/groups/group[1])
($doc/groups/group[2],
$doc/groups/group[1],
$doc/groups/group[1])/.
$doc/groups/group/item/(<result>{string(.)}</result>)
xdmp:xslt-invoke("create-docs.xsl",$doc)/xdmp:document-insert(base-uri(.),.)
(fn:root(self::node()) treat as document-node())
(fn:root(self::node()) treat as document-node())/
xquery version "1.0";
/foo
xquery version "1.0-ml";
/foo
$doc/groups/group/item/(/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment