[xquery-talk] last possible child's attribute

G. Ken Holman gkholman at CraneSoftwrights.com
Sun Mar 8 09:57:50 PST 2009

At 2009-03-08 14:45 +0100, Michalmas wrote:
>It still gives me the same error:
>XQuery Serialization Error!
>A document node may not have an attribute node or a namespace node as a child

Yes, because attribute nodes can only be attached to an element.

You are putting out a document and you are trying to add just the attribute.

I posted code that was working, and you'll see that I used the 
string() function in order to add a string to the document node, not 
the attribute itself.

>On Sun, Mar 8, 2009 at 2:32 PM, G. Ken Holman 
><<mailto:gkholman at cranesoftwrights.com>gkholman at cranesoftwrights.com> wrote:
>t:\ftemp>type michalmas.xml
>  <aa lc="1">
>     <aaa lc="00">
>     </aaa>
>  </aa>
>  <bb lc="0">
>  </bb>
>  <zz lc="1">
>     <ccc lc="123">
>     </ccc>
>  </zz>
>t:\ftemp>type michalmas.xq
>string( a/descendant::*[last()]/@lc ),
>string( (a//@lc)[last()] )
>t:\ftemp>xquery michalmas.xml michalmas.xq
><?xml version="1.0" encoding="UTF-8"?>123 123

Notice above how I'm adding the values of the attributes, not the 
attributes themselves to the result.

I hope this helps.

. . . . . . . Ken

XQuery/XSLT training in Prague, CZ 2009-03 http://www.xmlprague.cz
XQuery/XSLT/XSL-FO training in Los Angeles/Anaheim - 2009-06-01/10
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman at CraneSoftwrights.com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/q/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/q/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

More information about the talk mailing list