NSXML XQuery/XPath descendant support broken to the point of being useless

Originator:dgatwood42
Number:rdar://18317629 Date Originated:12-Sep-2014
Status:Open Resolved:
Product:OS X Product Version:10.9.4
Classification:Serious Bug Reproducible:Always
 
Summary:
The following NSXML methods:

    * objectsForXQuery:constants:error:
    * objectsForXQuery:error:
    * nodesForXPath:error:

epically fail to handle the descendant selector, running past the end of the element.

Steps to Reproduce:
1.  Use NSXML to read the DocBook RNG file.
2.  Issue the following queries:

    /grammar[1]/div[29]/define[4]/element[1]

    /grammar[1]/div[29]/define[4]/element[1]//ref


Expected Results:
The first query should return this element:

<element name="para"><a:documentation>A paragraph</a:documentation><s:pattern name="Root must have version"><s:rule context="/db:para"><s:assert test="@version">The root element must have a version attribute.</s:assert></s:rule></s:pattern><ref name="db.para.attlist"></ref><ref name="db.para.info"></ref><zeroOrMore><choice><ref name="db.all.inlines"></ref><ref name="db.nopara.blocks"></ref></choice></zeroOrMore></element>

and does.

The second query should return all of the <ref> elements within that blob.

Actual Results:
The second query returns all of the <ref> elements within that blob, plus every <ref> element from there to the end of the document.  Thus, searching for descendants is completely broken to the point of being unusable.


Version:
OS X 10.9.4


Notes:
I'm not the only one running into this:

http://stackoverflow.com/questions/24781425/nsxmlelement-nodesforxpath-name-returns-more-matches-than-descendants


Configuration:


Attachments:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!