Always get a null exception while useing XPATH Saxon-8b

Discussion in 'XML' started by Rishabh.Dayal@gmail.com, Sep 22, 2005.

  1. Guest

    Hi,

    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">
    <baz/>
    <ns2:baz xmlns:ns2="namespace2-uri"/>
    </ns1:bar>
    <ns3:hi xmlns:hi="namespace3-uri">
    <there/>
    </ns3:hi>
    </foo>

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

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

    try
    {
    XPathFactory xpf =
    XPathFactory.newInstance(NamespaceConstant.OBJECT_MODEL_SAXON);
    }
    catch( javax.xml.xpath.XPathFactoryConfigurationException exception
    )
    {
    System.out.println( "Exception XPathFactory.newInstance" );
    }

    StandaloneContext context = new StandaloneContext();
    context.declareNamespace("a","namespace1-uri");
    context.declareNamespace("b","namespace1-uri");
    NamespaceContext namespaceContext = new
    NamespaceContextImpl(context);
    InputSource is = new InputSource(xmlExpr);
    SAXSource ss = new SAXSource(is);
    XPathEvaluator xpe = new XPathEvaluator();
    xpe.setNamespaceContext(namespaceContext);

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

    Any suggestions would be of great help.

    Thanks
    -Anurag
    , Sep 22, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RHJXaG8=?=

    File transfer useing <a in VB

    =?Utf-8?B?RHJXaG8=?=, May 12, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    450
    =?Utf-8?B?RHJXaG8=?=
    May 27, 2005
  2. ad
    Replies:
    1
    Views:
    533
    Karl Seguin
    Jul 3, 2005
  3. TobyOne
    Replies:
    0
    Views:
    317
    TobyOne
    May 17, 2006
  4. =?Utf-8?B?Um9nZXI=?=

    Useing OLEDBDataAdapter

    =?Utf-8?B?Um9nZXI=?=, Oct 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    487
    Cowboy \(Gregory A. Beamer\)
    Oct 9, 2006
  5. NeoGeoSNK
    Replies:
    29
    Views:
    1,417
Loading...

Share This Page