[ 
https://issues.apache.org/jira/browse/XALANJ-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13203467#comment-13203467
 ] 

gareth reakes commented on XALANJ-2549:
---------------------------------------

Hi Olivier,

Its best if you ask questions on the mailing list rather than in Jira. As Joe 
said in the comment on 1030, you do still need to resolve namespaces. An 
element has a namespace even if there is no prefix. You will need to bind one 
yourself. Take a look in the mail archives and here:

http://xml.apache.org/xalan-j/xpath_apis.html#namespacecontext

For more information. If its still not clear then ask the list.

Gareth
                
> 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
>              Labels: xalan, xpath
>
> 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: xalan-dev-unsubscr...@xml.apache.org
For additional commands, e-mail: xalan-dev-h...@xml.apache.org

Reply via email to