Examples of JDOMXPath


Examples of org.jaxen.jdom.JDOMXPath

    }

    public void concatOccurrence(Object xmlDoc, String xpath, String concatSep, Appendable chaineConcat) throws IOException {

        try {
            JDOMXPath xp = new JDOMXPath(xpath);
            List ls = xp.selectNodes(xmlDoc);
            Iterator i = ls.iterator();
            int j = 0;
            while (i.hasNext()) {
                j++;
                String text = "";
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

    }

    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();
                if (node instanceof Element) {
                    Element elem = (Element) node;
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

    SAXBuilder builder = new SAXBuilder();
    Document doc = builder.build(fis);
    Element root = doc.getRootElement();
    // XXX this is expensive for very large documents. In those cases another
    // XXX method (direct processing of SAX events, or XMLPull) should be used.
    XPath path = new JDOMXPath("//text:span | //text:p | //text:tab | //text:tab-stop | //text:a");
    path.addNamespace("text", root.getNamespace("text").getURI());
    Namespace xlink = Namespace.getNamespace("xlink", "http://www.w3.org/1999/xlink");
    List list = path.selectNodes(doc);
    boolean lastp = true;
    for (int i = 0; i < list.size(); i++) {
      Element el = (Element)list.get(i);
      String text = el.getText();
      if (el.getName().equals("p")) {
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

    FilterInputStream fis = new FilterInputStream(zis) {
      public void close() {};
    };
    SAXBuilder builder = new SAXBuilder();
    Document doc = builder.build(fis);
    XPath path = new JDOMXPath("/office:document-meta/office:meta/*");
    Element root = doc.getRootElement();
    path.addNamespace("office", root.getNamespace("office").getURI());
    List list = path.selectNodes(doc);
    for (int i = 0; i < list.size(); i++) {
      Element n = (Element)list.get(i);
      String text = n.getText();
      if (text.trim().equals("")) continue;
      String name = n.getName();
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

  }

  @SuppressWarnings("unchecked")
  public List<Element> getMetsValues(String expr, Object element, HashMap<String, Namespace> namespaces) throws JaxenException {
      JDOMXPath xpath = new JDOMXPath(expr.trim().replace("\n", ""));
      // Add all namespaces
      for (String key : namespaces.keySet()) {
        Namespace value = namespaces.get(key);
        xpath.addNamespace(key, value.getURI());
      }
      return xpath.selectNodes(element);
  }
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

                nsContext.addNamespace(NAMESPACE_PREFIX,
                                       root.getNamespaceURI());

                // Grab the message-store element to allow extraction of the
                // various attributes
                XPath xpath = new JDOMXPath("//" +
                                            NAMESPACE_PREFIX + ":" +
                                            MSS_CONFIG_MESSAGESTORE_ELEMENT);
                xpath.setNamespaceContext(nsContext);

                Element element = (Element) xpath.selectSingleNode(root);

                // Location
                config.setLocation(element.getAttributeValue(
                        MSS_CONFIG_LOCATION_ATTRIBUTE));

                // ID Size
                config.setIdSize(Integer.parseInt(element.getAttributeValue(
                        MSS_CONFIG_IDSIZE_ATTRIBUTE)));

                // Timeout
                String timeout = element.getAttributeValue(
                        MSS_CONFIG_TIMEOUT_ATTRIBUTE);
                if (timeout.equalsIgnoreCase(UNLIMITED)) {
                    config.setUnlimitedTimeout(true);
                } else {
                    config.setTimeout(Integer.parseInt(timeout));
                }

                // Validation
                String validate = element.getAttributeValue(
                        MSS_CONFIG_VALIDATE_ATTRIBUTE);
                config.setValidate(validate.equals("true"));

                // Get the environment element and extract the log4j attribute
                xpath = new JDOMXPath("//" +
                                      NAMESPACE_PREFIX + ":" +
                                      MSS_CONFIG_ENVIRONMENT_ELEMENT);
                xpath.setNamespaceContext(nsContext);

                element = (Element) xpath.selectSingleNode(root);
                config.setLog4jConfigurationFile(
                        element.getAttributeValue(MSS_CONFIG_LOG4J_ATTRIBUTE));
            } else {
                handleConfigError(null);
            }
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

     * @return a JDOMXPath instance
     * @throws org.jaxen.JaxenException if an error occurs.
     */
    private JDOMXPath createJDOMXPath() throws JaxenException {
        // create a JDOMXPath instance
        JDOMXPath jXPath = new JDOMXPath(xpath);
        if (namespaceURIMap != null) {
            // 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

Examples of org.jaxen.jdom.JDOMXPath

    SAXBuilder builder = new SAXBuilder();
    Document doc = builder.build(fis);
    Element root = doc.getRootElement();
    // XXX this is expensive for very large documents. In those cases another
    // XXX method (direct processing of SAX events, or XMLPull) should be used.
    XPath path = new JDOMXPath("//text:span | //text:p | //text:tab | //text:tab-stop | //text:a");
    path.addNamespace("text", root.getNamespace("text").getURI());
    Namespace xlink = Namespace.getNamespace("xlink", "http://www.w3.org/1999/xlink");
    List list = path.selectNodes(doc);
    boolean lastp = true;
    for (int i = 0; i < list.size(); i++) {
      Element el = (Element)list.get(i);
      String text = el.getText();
      if (el.getName().equals("p")) {
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

    FilterInputStream fis = new FilterInputStream(zis) {
      public void close() {};
    };
    SAXBuilder builder = new SAXBuilder();
    Document doc = builder.build(fis);
    XPath path = new JDOMXPath("/office:document-meta/office:meta/*");
    Element root = doc.getRootElement();
    path.addNamespace("office", root.getNamespace("office").getURI());
    List list = path.selectNodes(doc);
    for (int i = 0; i < list.size(); i++) {
      Element n = (Element)list.get(i);
      String text = n.getText();
      if (text.trim().equals("")) continue;
      String name = n.getName();
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

      }
      for (int i = 0; i < paramNodeList.getLength(); i++) {
    org.w3c.dom.Element param
        = (org.w3c.dom.Element)paramNodeList.item(i);
    String name = param.getAttribute("Name");
    XPath xpath = new JDOMXPath(param.getAttribute("Select"));
    if (nsNodeList != null) {
        for (int j = 0; j < nsNodeList.getLength(); j++) {
      org.w3c.dom.Element ns
          = (org.w3c.dom.Element)nsNodeList.item(j);
      String prefix = ns.getAttribute("Prefix");
      String uri = ns.getAttribute("Uri");
      xpath.addNamespace(prefix, uri);
        }
    }
    returnParamInfo.put(name, xpath);
      }
  } catch (Exception e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.