[xquery-talk] getting an attrib value from another attrib value
Robert Walpole
robert.walpole at devon.gov.uk
Mon Dec 4 13:57:58 PST 2006
Thanks John but when I try running the query you suggest I get
"SAXException: Error SENR0001: attribute 'uid' has no parent element".
I am using eXist database so perhaps this is application specific?
Thanks
Rob
> -----Original Message-----
> From: John Snelson [mailto:jsnelson at sleepycat.com]
> Sent: 04 December 2006 13:41
> To: Robert Walpole
> Cc: talk at x-query.com
> Subject: Re: [xquery-talk] getting an attrib value from
> another attrib value
>
>
> The answer you are looking for is:
>
> doc("...")//*[@name = "Torquay"]/@uid
>
> The FLWOR construct is unnecessary in this case.
>
> John
>
> Robert Walpole wrote:
> > Hi,
> >
> > This may be more XPath than XQuery so I hope you don't mind
> me posting
> > here.
> >
> > I want to write a query that given a string (let's say
> "Torbay") will
> > return the uid attribute of the element with the name
> attribute equal to
> > the string value.
> >
> > 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:
> >
> > for $areaserved in doc("...")/*[@name = "Torquay"] return
> $areaserved
> >
> > I should say that the matching name attribute could appear
> at any level
> > in the XML document and may or may not have child elements.
> >
> > Example XML:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <county name="Devon" uid="0">
> > <district uid="8" name="Torbay">
> > <town uid="210" name="Brixham" pct="Torbay"/>
> > <town uid="211" name="Paignton" pct="Torbay"/>
> > <town uid="212" name="Torquay" pct="Torbay">
> > <settlement name="Babbacombe" uid="979"/>
> > <settlement name="Barton" uid="803"/>
> > <settlement name="Chelston" uid="804"/>
> > </town>
> > </district>
> > </county>
> >
> > Many Thanks
> > Rob Walpole
> >
> >
> >
> --------------------------------------------------------------
> ----------
> >
> > _______________________________________________
> > talk at x-query.com
> > http://x-query.com/mailman/listinfo/talk
>
>
More information about the talk
mailing list