While I’ve got your attention, here’s an XPath (1.0) puzzler. I have an RDFa dataset compiled from various and sundry sources. It’s all wrapped up in a single XML file. I run this XPath to see how many meta elements are present: //meta and it returns a node-set of size 762. Now, I want to see how many property elements are present, so I run the query: //meta/@property and it returns a node-set of size 764. How is it that the second node-set can be bigger than the first? -m
M. David Peterson http://xmlhacker.com/
December 16th, 2007 at 12:26 amAre the property attributes potentially in different namespaces, and your XPath engine is returning all matches on local-name() as opposed to name()? It’s possible that <meta foo:property=”bar” bar:property=”baz”/> on one or two of your meta elements is causing the increase.
If you try //meta[@property] your count should be something equal to or less than the total count of the meta elements. If it’s not, then there’s really something weird going on.
Dimitre Novatchev http://fxsl.sf.net
December 16th, 2007 at 8:53 amDo try with different XPath engines in order to determine if the observed result is only produced by your XPath engine, in which case this is a clear indication of a bug. If most/all XPath engines report the observed result, could you, please, provide the xml file against which the XPath expression is evaluated?
Cheers,
Dimitre Novatchev
Tom Passin
December 16th, 2007 at 4:48 pmYou would get this if some of the meta elements had more that one property attribute. Since that wouldn’t be well-formed, and the xslt processor shouldn’t be receiving multiple attributes of the same name, let alone be counting them, it would indicate one or more bugs, in the parser and in the xslt processor.
Anthony B. Coates http://kontrawize.blogs.com/kontrawize/
December 19th, 2007 at 10:08 amCan you post the dataset (with the data text replaced by some bogus text if necessary to protect the contents)?
Cheers, Tony.
Push Button Paradise | Blog Archive | XPath puzzler: solution http://dubinko.info/blog/2007/12/31/xpath-puzzler-solution/
December 31st, 2007 at 12:39 am[...] to all the folks who showed interest in this little XPath puzzler published here a few weeks ago. Some asked to see the dataset, but I’m not able to release it [...]