Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Always get a null exception while useing XPATH Saxon-8b

Thread Tools

Always get a null exception while useing XPATH Saxon-8b
Posts: n/a

I always get a null exception while using XPATH Saxon-8b. I am using
this for the first time.

My xml document is:
<foo xmlns="default-namespace">
<ns1:bar xmlns:ns1="namespace1-uri" xmlns="namespace1-uri">
<ns2:baz xmlns:ns2="namespace2-uri"/>
<ns3:hi xmlns:hi="namespace3-uri">

XPATH expression is /foo/a:bar/b:baz
java code is:

String xpathExpr = "/foo/a:bar/b:baz";

XPathFactory xpf =
XPathFactory.newInstance(NamespaceConstant.OBJECT_ MODEL_SAXON);
catch( javax.xml.xpath.XPathFactoryConfigurationException exception
System.out.println( "Exception XPathFactory.newInstance" );

StandaloneContext context = new StandaloneContext();
NamespaceContext namespaceContext = new
InputSource is = new InputSource(xmlExpr);
SAXSource ss = new SAXSource(is);
XPathEvaluator xpe = new XPathEvaluator();

String result = null;
result = xpe.evaluate(xpathExpr, ss);
catch( javax.xml.xpath.XPathExpressionException exception )
System.out.println( exception.getCause() );

Any suggestions would be of great help.


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get "java.lang.OutOfMemoryError" when Parsing an XML useing DOM NeoGeoSNK Java 29 03-27-2007 01:32 PM
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
"stringObj == null" vs "stringObj.equals(null)", for null check?? Java 5 03-29-2006 10:37 PM
limited or no connectivity xphome useing bt2110 router =?Utf-8?B?Y2F6NHlvdQ==?= Wireless Networking 0 10-30-2005 11:25 AM
copy tftp to switch by useing snmpset strauch t Cisco 2 11-10-2003 07:20 AM