Package org.jaxen

Examples of org.jaxen.SimpleNamespaceContext


        log("Document [" + url + "]");
        Object document = nav.getDocument(url);
        XPath contextpath = new BaseXPath("/", nav);
        log("Initial Context :: " + contextpath);
        List list = contextpath.selectNodes(document);
        SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
        nsContext.addNamespace("alias", "http://fooNamespace/");
        nsContext.addNamespace("bar", "http://barNamespace/");
        nsContext.addNamespace("voo", "http://fooNamespace/");
        nsContext.addNamespace("foo", "http://fooNamespace/");
        getContextSupport().setNamespaceContext(nsContext);
        Iterator iter = list.iterator();
        while (iter.hasNext()) {
            Object context = iter.next();
            assertCountXPath(1, context, "/*");
 
View Full Code Here


        log("Document [" + url + "]");
        Object document = nav.getDocument(url);
        XPath contextpath = new BaseXPath("/", nav);
        log("Initial Context :: " + contextpath);
        List list = contextpath.selectNodes(document);
        SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
        nsContext.addNamespace("foo", "http://somethingElse/");
        getContextSupport().setNamespaceContext(nsContext);
        Iterator iter = list.iterator();
        while (iter.hasNext()) {
            Object context = iter.next();
            assertCountXPath(0, context, "/foo:a/b/c");
View Full Code Here

        log("Document [" + url + "]");
        Object document = nav.getDocument(url);
        XPath contextpath = new BaseXPath("/", nav);
        log("Initial Context :: " + contextpath);
        List list = contextpath.selectNodes(document);
        SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
        nsContext.addNamespace("alias", "http://fooNamespace/");
        nsContext.addNamespace("bar", "http://barNamespace/");
        nsContext.addNamespace("foo", "http://fooNamespace/");
        getContextSupport().setNamespaceContext(nsContext);
        Iterator iter = list.iterator();
        while (iter.hasNext()) {
            Object context = iter.next();
            assertValueOfXPath("Hello", context, "/foo:a/b/c");
View Full Code Here

        log("Document [" + url + "]");
        Object document = nav.getDocument(url);
        XPath contextpath = new BaseXPath("/", nav);
        log("Initial Context :: " + contextpath);
        List list = contextpath.selectNodes(document);
        SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
        nsContext.addNamespace("dummy", "http://dummyNamespace/");
        getContextSupport().setNamespaceContext(nsContext);
        Iterator iter = list.iterator();
        while (iter.hasNext()) {
            Object context = iter.next();
            assertCountXPath(1, context, "/dummy:a/dummy:b/dummy:c");
View Full Code Here

        XPath xpath = getXPath(xpathString);
        return (OMElement) xpath.selectSingleNode(parentElement);
    }

    private XPath getXPath(String xpathString) throws JaxenException {
        SimpleNamespaceContext nsCtx = new SimpleNamespaceContext();
        nsCtx.addNamespace("ns", "http://geronimo.apache.org/xml/ns/j2ee/connector-1.1");
        XPath xpath = new AXIOMXPath(xpathString);
        xpath.setNamespaceContext(nsCtx);
        return xpath;
    }
View Full Code Here

    try {
      String xPath = MessageFormat.format( BEAN_ID_XPATH, objectId );
      HashMap<String, String> map = new HashMap<String, String>();
      map.put( "default", DEFAULT_NAMESPACE ); //$NON-NLS-1$
      Dom4jXPath xpath = new Dom4jXPath( xPath );
      xpath.setNamespaceContext( new SimpleNamespaceContext( map ) );
      Element element = (Element) xpath.selectSingleNode( document );
      return element;
    } catch ( JaxenException jex ) {
      return null;
    }
View Full Code Here

    try {
      String xPath = MessageFormat.format( BEAN_ID_XPATH, objectId );
      HashMap<String, String> map = new HashMap<String, String>();
      map.put( "default", DEFAULT_NAMESPACE ); //$NON-NLS-1$
      Dom4jXPath xpath = new Dom4jXPath( xPath );
      xpath.setNamespaceContext( new SimpleNamespaceContext( map ) );
      Element element = (Element) xpath.selectSingleNode( document );
      return element.attributeValue( CLASS_ATTRIBUTE );
    } catch ( JaxenException jex ) {
      return null;
    }
View Full Code Here

  public String getObjectScope( String objectId ) {
    try {
      HashMap<String, String> map = new HashMap<String, String>();
      map.put( "default", DEFAULT_NAMESPACE ); //$NON-NLS-1$
      Dom4jXPath xpath = new Dom4jXPath( BEAN_ID_XPATH );
      xpath.setNamespaceContext( new SimpleNamespaceContext( map ) );
      Element element = (Element) xpath.selectSingleNode( document );
      return element.attributeValue( SCOPE_ATTRIBUTE );
    } catch ( JaxenException jex ) {
      return null;
    }
View Full Code Here

 
  private static final String CIPHER_ELEMENT = "//xenc:EncryptedData/xenc:CipherData/xenc:CipherValue";

  public static void optimize(SOAPEnvelope env, List<String> expressions, Map namespaces) throws RampartException {
   
    SimpleNamespaceContext nsCtx = new SimpleNamespaceContext();
    nsCtx.addNamespace(WSConstants.ENC_PREFIX,WSConstants.ENC_NS);
    nsCtx.addNamespace(WSConstants.SIG_PREFIX,WSConstants.SIG_NS);
    nsCtx.addNamespace(WSConstants.WSSE_PREFIX,WSConstants.WSSE_NS);
    nsCtx.addNamespace(WSConstants.WSU_PREFIX,WSConstants.WSU_NS);

    Iterator keys = namespaces.keySet().iterator();
    while(keys.hasNext()){
      String strPrefix =  (String)keys.next();
      String strNS = (String)namespaces.get(strPrefix);
      nsCtx.addNamespace(strPrefix,strNS);
    }

    try {
            for (String exp : expressions) {
                XPath xp = new AXIOMXPath(exp);
View Full Code Here

  private static List findElements(OMElement elem, String expression) throws WSSecurityException {
    try {
      XPath xp = new AXIOMXPath(expression);

      //Set namespaces
      SimpleNamespaceContext nsCtx = new SimpleNamespaceContext();
      nsCtx.addNamespace(WSConstants.ENC_PREFIX,WSConstants.ENC_NS);
      nsCtx.addNamespace(WSConstants.SIG_PREFIX,WSConstants.SIG_NS);
      nsCtx.addNamespace(WSConstants.WSSE_PREFIX,WSConstants.WSSE_NS);
      nsCtx.addNamespace(WSConstants.WSU_PREFIX,WSConstants.WSU_NS);

      xp.setNamespaceContext(nsCtx);

      return xp.selectNodes(elem);
View Full Code Here

TOP

Related Classes of org.jaxen.SimpleNamespaceContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.