Skip to content

Instantly share code, notes, and snippets.

@line-o
Created June 15, 2018 14:41
Show Gist options
  • Select an option

  • Save line-o/be18bd67e37da6e5c02ed3a2f511e70c to your computer and use it in GitHub Desktop.

Select an option

Save line-o/be18bd67e37da6e5c02ed3a2f511e70c to your computer and use it in GitHub Desktop.
test wrapping a sequence of elements
xquery version "3.1";
(:
: the children of <arrow> and <for-each> must be equal inside <return-element>
: and <wrap-element>
:
: in eXistdb 4.1.0 the contents are not equal in wrap-element
:)
declare variable $local:xml :=
<root>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
</root>
;
declare function local:return ($item as item()) as item() { $item };
declare function local:wrap ($item as item()) as item() { <wrap>{ $item }</wrap> };
<result>
<return-element>
<for-each>{ for-each($local:xml//item, local:return#1) }</for-each>
<arrow>{ $local:xml//item => for-each(local:return#1) }</arrow>
</return-element>
<wrap-element>
<for-each>{ for-each($local:xml//item, local:wrap#1) }</for-each>
<arrow>{ $local:xml//item => for-each(local:wrap#1) }</arrow>
</wrap-element>
</result>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment