Package org.jaxen

Examples of org.jaxen.SimpleNamespaceContext


    public void extractContent(
            Document xmlDoc, String name, String xpath, Metadata metadata) {
        try {
            JDOMXPath xp = new JDOMXPath(xpath);
            SimpleNamespaceContext context = new SimpleNamespaceContext();
            context.addNamespace("dc", "http://purl.org/dc/elements/1.1/");
            context.addNamespace("meta", "urn:oasis:names:tc:opendocument:xmlns:meta:1.0");
            xp.setNamespaceContext(context);
            List selectNodes = xp.selectNodes(xmlDoc);
            Iterator nodes = selectNodes.iterator();
            while (nodes.hasNext()) {
                Object node = nodes.next();
View Full Code Here


            HashMap map = new HashMap();
            map.put("default", XmlConstants.POM_DEFAULT_NAMESPACE);

            XPath xpath = new Dom4jXPath("/default:project/default:dependencies");
            xpath.setNamespaceContext(new SimpleNamespaceContext(map));
           
            dependenciesNode = (DefaultElement)xpath.selectSingleNode(pomDocument);
            readDependenciesListFromXmlNode(dependencies, dependenciesNode);
        }
        catch (JaxenException e) {
View Full Code Here

                String prefix = "./";
                if (usePomNamespace) {
                    prefix += "default:";
                }
                XPath xpath = new Dom4jXPath(prefix + childName);
                xpath.setNamespaceContext(new SimpleNamespaceContext(map));

                Node child = (Node) xpath.selectSingleNode(parent);
                if (null != child) {
                    if (null != child.getText()) {
                        result = child.getText().trim();
View Full Code Here

    }

    private XPath createXPath(String expression) throws JaxenException {
        XPath xpath = new DOMXPath(expression);
        if (getNamespaces() != null && !getNamespaces().isEmpty()) {
            xpath.setNamespaceContext(new SimpleNamespaceContext(getNamespaces()));
        }
        return xpath;
    }
View Full Code Here

     * @throws XPathParseException when the given expression cannot be parsed
     */
    public static XPathExpression createXPathExpression(String expression, Map<String, String> namespaces) {
        try {
            XPath xpath = new DOMXPath(expression);
            xpath.setNamespaceContext(new SimpleNamespaceContext(namespaces));
            return new JaxenXpathExpression(xpath);
        }
        catch (JaxenException ex) {
            throw new org.springframework.xml.xpath.XPathParseException(
                    "Could not compile [" + expression + "] to a XPathExpression: " + ex.getMessage(), ex);
View Full Code Here

            throw new FactoryException(e);
        }
    }

    protected NamespaceContext createNamespaceContext(Configuration configuration) {
        SimpleNamespaceContext answer = new SimpleNamespaceContext();
        String[] names = configuration.getAttributeNames();
        for (int i = 0; i < names.length; i++) {
            String name = names[i];
            if (name.equals("xmlns")) {
                answer.addNamespace("", configuration.getAttribute(name));
            }
            else {
                if (name.startsWith("xmlns:")) {
                    String prefix = name.substring(6);
                    String uri = configuration.getAttribute(name);
                    answer.addNamespace(prefix, uri);
                }
            }
        }
        return answer;
    }
View Full Code Here

                Document configDoc = builder.build(is);

                Element root = configDoc.getRootElement();

                // Ensure an appropriate namesepace is setup
                SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
                nsContext.addNamespace(NAMESPACE_PREFIX,
                                       root.getNamespaceURI());

                // Grab the message-store element to allow extraction of the
                // various attributes
                XPath xpath = new JDOMXPath("//" +
View Full Code Here

            // we need to ensure that the JDOMXPath knows about the
            // namespaces associated with this xpath. We can do this
            // be wrapping the namespaceURI map in a SimpleNamespaceContext
            // implementation and registering this with the JDOMXPath instance.
            jXPath.setNamespaceContext(
                    new SimpleNamespaceContext(namespaceURIMap));
        }
        return jXPath;
    }
View Full Code Here

    public ContextSupport getContextSupport()
    {
        if (this.contextSupport == null)
        {
            this.contextSupport = new ContextSupport(new SimpleNamespaceContext(),
                    XPathFunctionContext.getInstance(),
                    new SimpleVariableContext(),
                    getNavigator());
        }
        return this.contextSupport;
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("voo", "http://fooNamespace/");
        nsContext.addNamespace("foo", "http://fooNamespace/");
        getContextSupport().setNamespaceContext(nsContext);
        Iterator iter = list.iterator();
        while (iter.hasNext())
        {
            Object context = iter.next();
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.