![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re:still problems with XPath and namespaces... >Thread Next - Re: still problems with XPath and namespaces... Re: still problems with XPath and namespaces...To: NULL Date: 1/3/2005 6:45:00 PM Stefan Franke wrote: > The XML I'm using looks like this: > > <SAMMLUNG > xmlns:buch="http://www.example.com/buecher" > xmlns:cd="http://www.example.com/cds"> > > <buch:ARTIKEL Status="vorhanden"> > <buch:TITEL>The Marble Faun</buch:TITEL> > <buch:AUTOR>Nathaniel Hawthorne</buch:AUTOR> > <buch:PREIS>10.95</buch:PREIS> > </buch:ARTIKEL> > <cd:ARTIKEL> > <cd:TITEL>Violinkonzerte 1, 2 und 3</cd:TITEL> > <cd:KOMPONIST>Mozart</cd:KOMPONIST> > <cd:PREIS>16.49</cd:PREIS> > </cd:ARTIKEL> > </SAMMLUNG> > > > If I want to display e.g. all the CDs of Mozart, I would do something like > this if I wouldn't have to deal with namespaces: > > string(//*/TITEL[following-sibling::KOMPONIST='Mozart']) Not really, if you apply the string function to a nodeset then you get the string value of the first node in document order so the above doesn't give you all CD titles but only one. > My suggestion when dealing with namespaces would be something like this (but > it doesn't work, as there is no TITEL-element anywhere, but I don't know how > to get it in there): > > string(//*[local-name()='ARTIKEL' and > namespace-uri()='http://www.example.com/cds']/*[string(local-name()='KOMPONIST') > = 'Mozart']) How are you evaluating your XPaths? You should simply be able to declare prefixes for the namespaces and then use e.g. //prefix:TITLE instead of going to the pain of using namespace-uri comparisons. So I think you should better tell us about the software you are using to evaluate XPaths and then probably someone can tell you how to use namespace prefixes bound to namespaces when evaluating XPath expressions. -- Martin Honnen http://JavaScript.FAQTs.com/ | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
