[xquery-talk] Attribute node whose parent is a document node
Wolfgang Hoschek
whoschek at lbl.gov
Thu Jul 7 13:40:31 PDT 2005
This is most likely because the W3C draft XQuery serialization spec
disallows top-level attributes (and namespace nodes) on
serialization. (This can be avoided with the Saxon -wrap option).
Hth, Wolfgang.
On Jul 7, 2005, at 12:28 PM, Pierrick Brihaye wrote:
> 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.
>
>
>
>
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
>
>
More information about the talk
mailing list