Hello there,
I have the following query:
declare variable $queryPath external := "D:\NROD Projects\xqCrews\diagrams.v3";
declare variable $testSet := doc($queryPath || "tests\testSet1.xml");
$testSet
where testSet1.xml is:
<test> <test1> <content>Foobar</content> </test1> <test1> <content>Foobar</content> </test1> </test>
When I run $testSet/*, I would expect to get the following result:
<test1> <content>Foobar</content> </test1> <test1> <content>Foobar</content> </test1>
However, I get the complete document in testSet1.xml
When I run this against testSet1.xml
$testSet/*/*
then I get what would I expect to see:
<test1> <content>Foobar</content> </test1> <test1> <content>Foobar</content> </test1>
Am I misunderstanding something?
Shaun
Hi Shaun,
On 13.06.2018 20:53, Shaun Flynn wrote:
declare variable $testSet := doc($queryPath || "tests\testSet1.xml");
here you bind a whole XML document (and therefore its corresponding, invisible *document node*) to `$testSet`. This is a wrapper around the root element that associates the XML content with the URI of its surrounding document.
When I run $testSet/*, I would expect to get the following result:
<test1> <content>Foobar</content> </test1> <test1> <content>Foobar</content> </test1>
However, I get the complete document in testSet1.xml
This is because the root element `test` is the first and only child of the document node.
When I run this against testSet1.xml
$testSet/*/*
then I get what would I expect to see: [...]
This is correct (if confusing). `$testSet/*` is the first child of the document node, the `test` element, so `$testSet/*/*` is the set of `test`'s children.
Hope that helps, Leo Wörteler
basex-talk@mailman.uni-konstanz.de