[xquery-talk] Attribute node whose parent is a document node

Pierrick Brihaye pierrick.brihaye at free.fr
Thu Jul 7 22:28:02 PDT 2005


Hi,

Given the following query :

let $a :=
<root>
<county name="Devon">
     <district name="East Devon">
         <town name="Axminster" pct="East Devon">
             <town name="Abbey Gate"/>
          </town>
         <town name="Aylesbeare" pct="East Devon"/>
     </district>
</county>
</root>

let $b :=
for $town in $a/county/district/town
where ($town/../@name eq "East Devon" or $town/../@name eq "Exeter")
order by $town/@name ascending
return $town/@name

let $c :=
for $town in $a/county/district[@name = "East Devon" or @name = 
"Exeter"]/town
order by $town/@name ascending
return $town/@name

return ($b,<blah/>,$c)

... Saxon returns :

XTDE0410: Cannot create an attribute node whose parent is a document node

Given this slight modification :

let $a :=
<root>
<county name="Devon">
     <district name="East Devon">
         <town name="Axminster" pct="East Devon">
             <town name="Abbey Gate"/>
          </town>
         <town name="Aylesbeare" pct="East Devon"/>
     </district>
</county>
</root>

let $b :=
for $town in $a/county/district/town
where ($town/../@name eq "East Devon" or $town/../@name eq "Exeter")
order by $town/@name ascending
return $town

let $c :=
for $town in $a/county/district[@name = "East Devon" or @name = 
"Exeter"]/town
order by $town/@name ascending
return $town

return ($b,<blah/>,$c)

... Saxon returns :

<?xml version="1.0" encoding="UTF-8"?>
<town pct="East Devon" name="Axminster">
    <town name="Abbey Gate"/>
</town>
<town pct="East Devon" name="Aylesbeare"/>
<blah/>
<town pct="East Devon" name="Axminster">
    <town name="Abbey Gate"/>
</town>
<town pct="East Devon" name="Aylesbeare"/>

So what's happening ?

Note that my primary purpose was to test the functional equivalence 
between a "where" statement and a predicate filtering.

Cheers,

p.b.






More information about the talk mailing list