Skip to content

Instantly share code, notes, and snippets.

@dariok
Last active August 26, 2016 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dariok/212da8c6e245aec773efa6ac9bb78da4 to your computer and use it in GitHub Desktop.
Save dariok/212da8c6e245aec773efa6ac9bb78da4 to your computer and use it in GitHub Desktop.
<test>
<result>true true true</result>
<result type="odn1"/>
<result type="odn2"/>
<result type="odn3">true</result>
</test>
xquery version "3.1";
declare namespace tei = "http://www.tei-c.org/ns/1.0";
let $set-up-collections :=
(
xmldb:create-collection('/db', 'test'),
xmldb:create-collection('/db/system/config/db', 'test')
)
let $in-memory-node :=
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<text>
<body>
<listPerson xml:id="personenregister">
<person xml:id="accolti_pietro">
<persName>
<forename>Pietro</forename>
<surname>Accolti</surname>
</persName>
<birth when="1455-03-15">15. März 1455<placeName>
<settlement type="city">Florenz</settlement>
</placeName>
</birth>
<death when="1532-12-11">11. Dezember 1532 <placeName>
<settlement type="settlement">Rom</settlement>
</placeName>
</death>
<idno type="url"><!-- TODO GND --></idno>
<listBibl type="references">
<bibl>
<ref target="http://en.wikipedia.org/wiki/Pietro_Accolti">Wikipedia</ref>
</bibl>
<bibl ref="#eubel_hierachia"> III, 12, 55, 63, 57, 58, 107, 122, 200, 234.</bibl>
<bibl ref="#DBI"> 1, s.v.</bibl>
</listBibl>
</person>
</listPerson>
</body>
</text>
</TEI>
let $store-indexed-doc := xmldb:store('/db/test', 'test.xml', $in-memory-node)
let $odn1 := doc('/db/test/test.xml')/id('accolti_pietro')/tei:persName
let $odn2 := doc('/db/test/test.xml')//tei:person[@xml:id='accolti_pietro']/tei:persName
let $odn3 := doc('/db/test/test.xml')/id('accolti_pietro')/tei:persName
return <test>
<result>{
for $node in ($odn1, $odn2, $odn3)
return
($node/tei:forename and $node/tei:surname)}</result>
<result type="odn1">{$odn1/tei:surname and $odn1/tei:forename}</result>
<result type="odn2">{$odn2/tei:surname and $odn2/tei:forename}</result>
<result type="odn3">{$odn3/tei:surname and $odn3/tei:forename}</result>
</test>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment