|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] getting an attrib value from another attrib valueRobert Walpole robert.walpole at devon.gov.ukMon Dec 4 14:54:01 PST 2006
That explains the error I was getting then. Returning the string value of the uid attribute would appear to be the answer for me in this case. Thanks to you both for your help. Rob Walpole > -----Original Message----- > From: Michael Kay [mailto:http://x-query.com/mailman/listinfo/talk] > Sent: 04 December 2006 14:24 > To: 'John Snelson'; Robert Walpole > Cc: http://x-query.com/mailman/listinfo/talk > Subject: RE: getting an attrib value from > another attrib value > > > > The answer you are looking for is: > > > > doc("...")//*[@name = "Torquay"]/@uid > > > > Just one little addition: > > > I have only got so far as being able to get the whole node (i.e. > > including children) with the matching name attribute as follows: > > The query above returns a single attribute node (assuming > Torquay is unique, > which I know it is!). > > If you changed the expression to: > > doc("...")//*[@name = "Torquay"] > > then the query still returns only a single node, this time an > element node. > > The difference only arises if and when you serialize the results. The > serialization spec actually doesn't allow you to serialize a single > attribute node (because the result of serialization is always > XML, and in > lexical XML attributes can't exist in isolation). That means > the serializer > will choke on John Snelson's solition. When you serialize an > element, on the > other hand, you get the whole subtree rooted at that element. > But if you are > returning the results to an application, without > serialization, then either > expression is fine. > > If you just want the uid as a string you can write: > > doc("...")//*[@name = "Torquay"]/@uid/string() > > Michael Kay > http://www.saxonica.com/ > > >
|
Purchase Stylus Studio Online Today!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






