Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Using //

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 6/16/2009 2:59:00 PM
JS wrote:

> The closest I coud find was NodeList:
>      NodeList list = (NodeList) expression.evaluate(new 
> org.xml.sax.InputSource(path), javax.xml.xpath.XPathConstants.NODESET);
> 
>      for (Object obj : list) {
>        System.out.println((String)obj);
> 
>      }

I think
        for (int i = 0, int l = list.getLength(); i < l; i++)
        {
          XmlAttribute att = (XmlAttribute)list.getItem(i);
          System.out.println(att.getNodeValue());
        }
should do but I mostly use the W3C DOM with JavaScript so take the above 
as pseudo code, not as compiled Java code.

> Ok but if I use XPath 2.0 would I then get the full result set?

You get the full set of nodes even with XPath 1.0 if you use the right 
method that returns a node-set
.
The difference I mentioned is with taking the string value of a node-set 
(which the method you have implictly does) where XPath 1.0 takes the 
string value of the first node in the node-set.

I thought with XPath 2.0 you would get the string concatenation of all 
nodes in the sequence as what is the result you get with XSLT 2.0 and 
xsl:value-of but it looks to be more complicated, with XPath 2.0 
string(sequence-of-more-than-one-node) is not allowed. I don't know what 
that API you use would do with an XPath 2.0 implementation, I think 
Michal Kay's Saxon allows you to use that API with XPath 2.0 but he 
always recommends to use Saxon's own API tailored to the XPath 2.0 data 
model.


-- 

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent