[xquery-talk] Serialization question

Michael Kay mike at saxonica.com
Mon Apr 27 03:30:40 PDT 2015

At first sight I would have expected an error. It appears to fall foul of rule 7 in


It is a serialization error [err:SENR0001] if an item in S6 is an attribute node, a namespace node or a function. 

And indeed, Saxon reports:

SENR0001: Cannot serialize a free-standing attribute node

So I think Oxygen is suppressing this error somehow.

The question then becomes, why does the spec do that? I think the answer is that XQuery picked up the serialization spec from XSLT, and XSLT never generates free-standing attribute nodes in its result, so the problem didn't arise there.

XQ 3.1 introduces the serialization method "adaptive" which is designed to display something, without failure, regardless what you throw at it. For attributes, it shows


not just the value, which is what you appear to want.

Michael Kay
mike at saxonica.com
+44 (0) 118 946 5893

On 27 Apr 2015, at 10:49, Leo Studer <leo.studer at varioweb.ch> wrote:

> Hello 
> I use Oxygen with Saxon enterprise edition 9.6.05.
> My output method is “text”.
> The following statement does its job correctly
> for $c in doc("factbook.xml")//country order by $c/@name return $c/@name/string()
> However I do not understand why 
> for $c in doc("factbook.xml")//country order by $c/@name return $c/@name
> returns an empty sequence. 
> What especially intrigues me is that ordering with $c/@name works fine (no conversion to string) and the output as text not.
> Any hints?
> Thanks in advance
> Leo
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk

More information about the talk mailing list