[Pharo-project] XPath issue ?
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: | 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
Hi, This is for sure not useful at all, but I make the same mistake into PetitXml and PetitXPath (skipping the first element) :) in the Petit parsers, now it is fixed... you can try that or check it to fix the XPath parser (which I didn't know it exists, btw) cheers, Esteban On May 8, 2013, at 11:23 PM, Herve Verjus <herve.verjus@univ-savoie.fr> wrote:
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:
| 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
HI guys may be this mail passed under the radar Stef Begin forwarded message:
From: Herve Verjus <herve.verjus@univ-savoie.fr> Subject: [Pharo-project] XPath issue ? Date: May 8, 2013 11:23:01 PM GMT+02:00 To: Pharo-project@lists.gforge.inria.fr Reply-To: Pharo-project@lists.gforge.inria.fr
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:
| 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
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 <herve.verjus@univ-savoie.fr <mailto:herve.verjus@univ-savoie.fr>> *Subject: **[Pharo-project] XPath issue ?* *Date: *May 8, 2013 11:23:01 PM GMT+02:00 *To: *Pharo-project@lists.gforge.inria.fr <mailto:Pharo-project@lists.gforge.inria.fr> *Reply-To: *Pharo-project@lists.gforge.inria.fr <mailto:Pharo-project@lists.gforge.inria.fr>
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
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 <herve.verjus@univ-savoie.fr <mailto:herve.verjus@univ-savoie.fr>> *Subject: **[Pharo-project] XPath issue ?* *Date: *May 8, 2013 11:23:01 PM GMT+02:00 *To: *Pharo-project@lists.gforge.inria.fr <mailto:Pharo-project@lists.gforge.inria.fr> *Reply-To: *Pharo-project@lists.gforge.inria.fr <mailto:Pharo-project@lists.gforge.inria.fr>
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
thanks hernan! Stef On May 18, 2013, at 10:04 PM, Hernán Morales Durand <hernan.morales@gmail.com> 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 <herve.verjus@univ-savoie.fr <mailto:herve.verjus@univ-savoie.fr>> *Subject: **[Pharo-project] XPath issue ?* *Date: *May 8, 2013 11:23:01 PM GMT+02:00 *To: *Pharo-project@lists.gforge.inria.fr <mailto:Pharo-project@lists.gforge.inria.fr> *Reply-To: *Pharo-project@lists.gforge.inria.fr <mailto:Pharo-project@lists.gforge.inria.fr>
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
herve did you try pastell? Stef On May 8, 2013, at 11:23 PM, Herve Verjus <herve.verjus@univ-savoie.fr> wrote:
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:
| 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
participants (4)
-
Esteban Lorenzano -
Hernán Morales Durand -
Herve Verjus -
Stéphane Ducasse