[ http://issues.apache.org/jira/browse/WSCOMMONS-122?page=comments#action_12447487 ] Gul Onural commented on WSCOMMONS-122: --------------------------------------
I have also tried to retrieve value of the tns:name in the xml snippet below and selectSingleNode pointer below code snippet comes as NULL..... <?xml version="1.0" encoding="UTF-8"?> <tns:createSimpleXXX xmlns:tns="http://www.somecompany.com"> <tns:CreateSimpleXXXRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.somecompany.com CommonTypes.xsd"> <tns:simpleXXX> <tns:name>String</tns:name> </tns:simpleReservationSchedule> </tns:CreateSimpleXXXRequest > </tns:createSimpleXXX > AXIOMXPath xpathExp = null; try { xpathExp = new AXIOMXPath("/tns:createSimpleXXX/tns:CreateSimpleXXXRequest /tns:simpleXXX/tns:name"); xpathExp.addNamespace("tns", "http://www.somecompany.com"); OMElement selectSingleNode = (OMElement)xpathExp.selectSingleNode(root); System.out.println("NAME = " + selectSingleNode.getText()); }catch (JaxenException e) { .... } Does this mean Axiom can not be used as is for navigating xml documents with namespaces ? > AXIOMXPath throws exception when navigating on an OMElement with namespace > prefixed elements > -------------------------------------------------------------------------------------------- > > Key: WSCOMMONS-122 > URL: http://issues.apache.org/jira/browse/WSCOMMONS-122 > Project: WS-Commons > Issue Type: Bug > Components: AXIOM > Reporter: Gul Onural > Priority: Blocker > > Hi, > I am trying to use AXIOMXPath to parse an OMElement, but I keep getting > org.jaxen.UnresolvableException. Below I cut and paste my xml snippet, code > and the exception. > Gul > xml snippet > ============================================= > <?xml version="1.0" encoding="UTF-8"?> > <tns:createSimpleXXX xmlns:tns="http://www.somecompany.com"> > <tns:CreateSimpleXXXRequest > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://www.somecompany.com CommonTypes.xsd"> > <tns:simpleXXX> > <tns:name>String</tns:name> > </tns:simpleReservationSchedule> > </tns:CreateSimpleXXXRequest > > </tns:createSimpleXXX > > Code snippet > ============================================= > AXIOMXPath xpathExp = null; > String scheduleName = null; > String xpathScheduleName = "/tns:createSimpleXXX "; try { > xpathExp = new AXIOMXPath(xpathScheduleName); > OMElement selectedNode = > (OMElement)xpathExp.selectSingleNode(element); > }catch (JaxenException e) { > System.out.println(stack2string(e)); > } > Exception > =============================================== > org.jaxen.UnresolvableException: Cannot resolve namespace prefix 'tns' > at > org.jaxen.expr.DefaultNameStep.matches(DefaultNameStep.java:340) > at > org.jaxen.expr.DefaultNameStep.evaluate(DefaultNameStep.java:209) > at > org.jaxen.expr.DefaultLocationPath.evaluate(DefaultLocationPath.java:140 > ) > at > org.jaxen.expr.DefaultAbsoluteLocationPath.evaluate(DefaultAbsoluteLocat > ionPath.java:113) > at > org.jaxen.expr.DefaultXPathExpr.asList(DefaultXPathExpr.java:102) > at org.jaxen.BaseXPath.selectNodesForContext(BaseXPath.java:680) > at org.jaxen.BaseXPath.selectNodes(BaseXPath.java:219) > at org.jaxen.BaseXPath.selectSingleNode(BaseXPath.java:240) > ... -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.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]
