Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to go for XPATH 2.0

 
Anish Kuti
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am using JDK1.5 and java XML parser (import javax.xml.*) for parsing my XML.Now while I am using
count(distinct-values(//tag/items/itemid)) ,my parser is getting failed. later I came to know this above type of XPATH is only supported by XPATH 2.0.

Can anyone let me know What I have to do to make my parser enable to parse the above type of xpath (supporting XPATH 2.0) ? Any change in code or any jar to be used!!

I am using the below java code to parse my XML
----------------------------------------
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
import org.xml.sax.InputSource;



public class XmlParsing {

public void get() throws Throwable
{
String aa ="count(distinct-values(//tag/items/itemid))";
InputSource is = new InputSource("C://Users//kanis//Documents//office//Support//SMI_CHM6544.xml");
XPath xpath = XPathFactory.newInstance().newXPath();
String strArbitaryinfo= (String) xpath.evaluate(aa, is, XPathConstants.STRING);
System.out.println("------------------------Xml String ------------------\n"+strArbitaryinfo+"\n-----------------------------------------------------");


}
public static void main(String[] args) throws Throwable {
new XmlParsing().get();
}
}
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Saxon (http://saxon.sourceforge.net/) implements XPath 2.0.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic