XPath with default namespace - No result
----------------------------------------

                 Key: XALANJ-2549
                 URL: https://issues.apache.org/jira/browse/XALANJ-2549
             Project: XalanJ2
          Issue Type: Bug
      Security Level: No security risk; visible to anyone (Ordinary problems in 
Xalan projects.  Anybody can view the issue.)
          Components: Xalan
    Affects Versions: 2.7.1
            Reporter: Olivier Roger


Hi,
 
I am having difficulties to use XPath query on a XML dataset having its root 
element with an *xmlns attribute with no prefix*.
 
In that specific case, the XPath query does not return the value. Since I have 
no prefix for the namespace I simply can get the value.
It this a known issue or am I simply doing something wrong ?

Here is my XML :

{noformat:title=default-ns.xml}
<?xml version="1.0" encoding="UTF-8"?>

<report xmlns="http://www.mydomain.com/report";>
    <account_number>123</account_number>
</report>
{noformat}

{code}
    @Test
    public void xPathDefaultNS() throws XPathExpressionException {
        javax.xml.xpath.XPathFactory factory = 
javax.xml.xpath.XPathFactory.newInstance();
        javax.xml.xpath.XPath xpath = factory.newXPath();
        javax.xml.xpath.XPathExpression expression = 
xpath.compile("/report/account_number");
        String result = expression.evaluate(new 
org.xml.sax.InputSource(this.getClass().getResourceAsStream("default-ns.xml")));
        Assert.assertTrue("123".equals(result));
    }
{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to