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

Michael Kay mhk at mhk.me.uk
Thu Jul 7 21:58:16 PDT 2005


If you look at the serializer spec, you'll see that you can't serialize a
sequence that contains parentless attribute nodes. The default invocation of
Saxon from the command line requests serialization, which is why this is
failing. 

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: talk-bounces at xquery.com 
> [mailto:talk-bounces at xquery.com] On Behalf Of Pierrick Brihaye
> Sent: 07 July 2005 20:28
> To: talk at xquery.com
> Subject: [xquery-talk] Attribute node whose parent is a document node
> 
> 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