thanks hernan! Stef
On May 18, 2013, at 10:04 PM, Hernán Morales Durand <[email protected]> wrote: > I submitted a fix, please check with the latest version at > > http://ss3.gemstone.com/ss/XPath.html > > cheers, > > Hernán > > El 14/05/2013 4:46, Herve Verjus escribió: >> Hello, >> >> Erwan gave me a piece of code I will test in the next couple of days :-) >> >> Thanks >> >> Herve >> >> Stéphane Ducasse wrote: >>> HI guys may be this mail passed under the radar >>> >>> Stef >>> >>> Begin forwarded message: >>> >>>> *From: *Herve Verjus <[email protected] >>>> <mailto:[email protected]>> >>>> *Subject: **[Pharo-project] XPath issue ?* >>>> *Date: *May 8, 2013 11:23:01 PM GMT+02:00 >>>> *To: *[email protected] >>>> <mailto:[email protected]> >>>> *Reply-To: *[email protected] >>>> <mailto:[email protected]> >>>> >>>> Dear All, >>>> >>>> I try a very simple example: >>>> >>>> mydoc.xml document: >>>> >>>> >>>> <?xml version="1.0" encoding="UTF-8" ?> >>>> >>>> <first> >>>> <second> >>>> <item type="attvalue">nodevalue</item> >>>> </second> >>>> </first> >>>> >>>> >>>> And the Pharo code found in the book.pharo-project.org >>>> <http://book.pharo-project.org>: >>>> >>>> | doc results | >>>> doc := XMLDOMParser parseFileNamed: 'mydoc.xml'. >>>> results := ( XPath for: 'first' ) in: doc. >>>> results explore >>>> >>>> >>>> As a result, I obtain an empty OrderedCollection...It should contain >>>> an element. Then a make some changes using different XPath expressions >>>> (i.e. '/first/second/item/@type", etc.) but no way. >>>> >>>> Then I discover the first element of the XPath expression must not be >>>> the root of the XML doc. If I change the mydoc.xml, introducing a new >>>> root element: >>>> >>>> >>>> <?xml version="1.0" encoding="UTF-8" ?> >>>> >>>> <foo> >>>> <first> >>>> <second> >>>> <item type="attvalue">nodevalue</item> >>>> </second> >>>> </first> >>>> </foo> >>>> >>>> Everything is ok (the same code as above). Here, XPath assumes that >>>> the first tag we are looking for is not the root of the doc, otherwise >>>> it fails. I'm not so sure but it seems that such implementation >>>> doesn't follow the XPath specs. I tried another example from >>>> http://www.w3schools.com/xpath/xpath_syntax.asp and same results: I >>>> obtain an empty collection when using an XPath expression beginning >>>> with the 'bookstore' tag, the root element of the doc: >>>> >>>> | doc results | >>>> doc := XMLDOMParser parseFileNamed: 'books.xml'. >>>> results := ( XPath for: '/bookstore' ) in: doc. >>>> results explore >>>> >>>> Maybe, I missed something... >>>> >>>> Note: I have had to replace the isTag (deprecated) with isElement in >>>> some piece of XPath code. >>>> >>>> Cheers, >>>> >>>> Herve >>>> >>> >> >> > >
