[ http://issues.apache.org/jira/browse/AXIS2-70?page=comments#action_12315407 ]
Davanum Srinivas commented on AXIS2-70: --------------------------------------- FYI, got all the example XPath statements here (http://webservices.xml.com/pub/a/ws/2003/09/16/jaxen.html) working. //* //soap-env:Envelope/* //soap-env:Envelope/soap-env:Body/* //soap-env:Envelope/soap-env:Body/ns1:CalculateResponse/* //soap-env:Envelope/soap-env:Body/ns1:CalculateResponse/Summary/* //soap-env:Envelope/soap-env:Body/ns1:CalculateResponse/Summary/Mean //soap-env:Envelope/soap-env:Body/ns1:CalculateResponse/Values/* //soap-env:Envelope/soap-env:Body/ns1:CalculateResponse/Values/[EMAIL PROTECTED]'0'] using the following test program. ========================================================================================= import org.apache.axis2.om.impl.llom.OMElementImpl; import org.apache.axis2.om.xpath.DocumentNavigator; import org.jaxen.BaseXPath; import org.jaxen.Navigator; import org.jaxen.SimpleNamespaceContext; import org.jaxen.XPath; import java.io.File; import java.util.Iterator; import java.util.List; public class TestXPath { public static void main(String[] args) throws Exception { File f = new File("x.xml"); String url = f.toURL().toString(); Navigator nav = new DocumentNavigator(); SimpleNamespaceContext nsContext = new SimpleNamespaceContext(); nsContext.addNamespace("soap-env", "http://schemas.xmlsoap.org/soap/envelope/"); nsContext.addNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); nsContext.addNamespace("soapenc", "http://schemas.xmlsoap.org/soap/encoding/"); nsContext.addNamespace("ns1", "http://namespaces.bigatti.it"); System.out.println("Document [" + url + "]"); Object document = nav.getDocument(url); XPath contextpath = new BaseXPath("//soap-env:Envelope/soap-env:Body/ns1:CalculateResponse/Values/[EMAIL PROTECTED]'0']", nav); contextpath.setNamespaceContext(nsContext); System.out.println("Initial Context :: " + contextpath); List list = contextpath.selectNodes(document); Iterator iter = list.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof OMElementImpl) { OMElementImpl omElement = ((OMElementImpl) o); if (omElement.getNamespace() != null) System.out.println(omElement.getNamespace().getPrefix() + omElement.getLocalName() + "=" + omElement.getText()); else System.out.println(omElement.getLocalName() + "=" + omElement.getText()); } else { System.out.println(o); } } } } ========================================================================================= will upload the x.xml as well. > XPath support for AXIOM > ----------------------- > > Key: AXIS2-70 > URL: http://issues.apache.org/jira/browse/AXIS2-70 > Project: Apache Axis 2.0 (Axis2) > Type: New Feature > Reporter: Davanum Srinivas > Attachments: x.xml > > Adding XPath support can be easily done using Jaxen. Involves implementing > org.jaxen.Navigator. > http://jaxen.org/apidocs/org/jaxen/Navigator.html > More details in their FAQ (http://jaxen.org/faq.html) > I'd highly recommend adding this to our 1.0 list. > thanks, > dims -- 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