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

Pierrick Brihaye pierrick.brihaye at culture.gouv.fr
Fri Jul 8 08:19:58 PDT 2005


Howard Katz <howardk at ...> writes:

> [ from an earlier email ... ]
> > Where does <attribute name="Aylesbeare"/> come from ?
> That's interesting.

Isn't it ? :-)

> Your code is trying to return the two  <at> name attributes that are reachable
> via the given path.


> These are then getting "hoisted" as attributes into the
> newly constructed <attribute> element containing them. 

Would the term "attached" be accurate here ? See below...

> The latest version of the spec says that having duplicate attributes (ie
> attributes of the same name, something not permitted in xml) in a direct
> element constructor should raise a static error. Saxon leniently resolves
> the issue by simply picking the second of the two ("Aylesbeare"), while
> Galax even more accomodatingly accepts both:
> <attribute name="Axminster" name="Aylesbeare"/>

So does eXist.

> Mark Logic, tho operating under an older spec, says "XML Parsing Error:
> duplicate attribute", which seems to be in accord with the latest version of
> the wd.

We may report an error. We have one for parentless attribute nodes as seen
yesterday. It could make sense to have one for attribute nodes whose parent is
not their original one (may we speak about "forced adoption" ?).

I'm also really surprised that an element's *content* may generate an attribute
for this element. It should IMHO generate an error *except* if a construct
similar to <xsl:attribute> is used.

What's your mind ?

We could have a function, say "attach()", that would allow to attach a node to
another thus allowing "forced adoption". Ideally, this function could work on
different axes (I will try to provide some pseudo-examples for this) but maybe a
function dedicated to attributes would be sufficient :
<attribute>{attachAttributes($a/county/district/town/@name[1 to X])}</attribute>
Of course, this function would also be applicable to parentless attributes ;-)

BTW, couldn't Saxon generate a nicer error message ? Something like :
Cannot create an attribute node whose parent is a document node (@name =



More information about the talk mailing list