Package org.jaxen

Examples of org.jaxen.SimpleNamespaceContext


            assertNotNull(ex.getMessage());
        }
    }
    public void testContextFromElement() throws ParserConfigurationException, UnsupportedAxisException {
        SimpleNamespaceContext context = new SimpleNamespaceContext();
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document doc = builder.newDocument();
        Element root = doc.createElementNS("http://www.example.org/", "pre:root");
        doc.appendChild(root);
        context.addElementNamespaces(new org.jaxen.dom.DocumentNavigator(), root);
       
        assertEquals("http://www.example.org/", context.translateNamespacePrefixToUri("pre"));
    }
View Full Code Here


    }
    public void testSerialization() throws IOException, ClassNotFoundException {
       
        // construct test object
        SimpleNamespaceContext original = new SimpleNamespaceContext();
        original.addNamespace("a", "http://www.a.com");
        original.addNamespace("b", "http://www.b.com");
       
        // serialize
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(out);
        oos.writeObject(original);
        oos.close();
       
        //deserialize
        byte[] pickled = out.toByteArray();
        InputStream in = new ByteArrayInputStream(pickled);
        ObjectInputStream ois = new ObjectInputStream(in);
        Object o = ois.readObject();
        SimpleNamespaceContext copy = (SimpleNamespaceContext) o;
       
        // test the result
        assertEquals("http://www.a.com", copy.translateNamespacePrefixToUri("a"));
        assertEquals("http://www.b.com", copy.translateNamespacePrefixToUri("b"));
        assertEquals("", "");
       
    }
View Full Code Here

     * @throws IOException       If there was a problem reading the DSML file.
     */
    public DSMLFormatReader(final InputStream inputStream) throws DocumentException, IOException, JaxenException {
        final Map<String, String> map = new HashMap<String, String>();
        map.put("dsml", "http://www.dsml.org/DSML");
        namespaceContext = new SimpleNamespaceContext(map);
        final SAXReader reader = new SAXReader();
        final Document document = reader.read(inputStream);
        final XPath xpath = createXPath("/dsml[namespace-uri()='http://www.dsml.org/DSML']/dsml:directory-entries/dsml:entry");
        objectClassXPath = createXPath("dsml:objectclass/dsml:oc-value");
        attrXPath = createXPath("dsml:attr");
View Full Code Here

    public String toString() {
        return "[XPathPattern: text: " + text + " Pattern: " + pattern + "]";
    }

    protected ContextSupport getContextSupport() {
        return new ContextSupport(new SimpleNamespaceContext(),
                XPathFunctionContext.getInstance(),
                new SimpleVariableContext(), DocumentNavigator.getInstance());
    }
View Full Code Here

    public NamespaceContext getNamespaceContext() {
        return namespaceContext;
    }

    public void setNamespaceURIs(Map<String, String> map) {
        setNamespaceContext(new SimpleNamespaceContext(map));
    }
View Full Code Here

/*     */   public NamespaceContext getNamespaceContext() {
/*  86 */     return this.namespaceContext;
/*     */   }
/*     */
/*     */   public void setNamespaceURIs(Map map) {
/*  90 */     setNamespaceContext(new SimpleNamespaceContext(map));
/*     */   }
View Full Code Here

/*     */   public String toString() {
/* 115 */     return "[XPathPattern: text: " + this.text + " Pattern: " + this.pattern + "]";
/*     */   }
/*     */
/*     */   protected ContextSupport getContextSupport() {
/* 119 */     return new ContextSupport(new SimpleNamespaceContext(), XPathFunctionContext.getInstance(), new SimpleVariableContext(), DocumentNavigator.getInstance());
/*     */   }
View Full Code Here

     *
     * @param namespaceMap
     *            A prefix->namespace map for all necessary namespace prefix bindings.
     */
    public AxiomXPathHelper(Map<String, String> namespaceMap) {
        _namespaceContext = new SimpleNamespaceContext(namespaceMap);
    }
View Full Code Here

        else if( document instanceof Document )
            xpath = new DOMXPath(xpathExpr);
        else
            fail("Document type "+document.getClass().getName());

        xpath.setNamespaceContext(new SimpleNamespaceContext(namespaces));

        return xpath.stringValueOf(document);
    }
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.