Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-957

XPathAPI.selectSingleNode() can't select a node relative to a node that is not the document's root

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Resolution: Fixed
    • 2.0.0
    • None
    • XPath
    • None
    • Operating System: Other
      Platform: All
    • 7976

    Description

      I'm having trouble with XPathAPI.selectSingleNode().

      My document:

      <?xml version="1.0"?>
      <encryption-service>
      <encryption-scheme name="sample"
      algorithm="DES"
      provider="SunJCE"
      provider-class="com.sun.crypto.provider.SunJCE"
      key-size="56"
      key-store-type="JCEKS"/>
      </encryption-service>

      When getNode() returns the node that represents 'encryption-scheme', the
      following two calls return null:

      Node node = XPathAPI.selectSingleNode( getNode(),
      "attribute::algorithm" );
      Node node = XPathAPI.selectSingleNode( getNode(),
      "/attribute::algorithm" );

      But this call works:

      Node node = XPathAPI.selectSingleNode( getNode(),
      "/encryption-service/encryption-scheme/attribute::algorithm" );

      It seems that the xpath expression is being evaluated relative to the root
      of the document, even though I'm passing in a node that is not the root.
      I've seen there is another signature for selectSingleNode() that takes a
      namespace node, but I have no idea how to use it. If using this call is my
      answer, can someone describe how to do this?

      Attachments

        Activity

          People

            Unassigned Unassigned
            brobinson@hp.com brobinson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: