Package org.dom4j

Examples of org.dom4j.Node


    DocumentPage retVal = null;
    try {
      if (pageNode != null) {
        retVal = new DocumentPage();

        Node deletedNode = (Node) pageNode.selectSingleNode("@deleted");
        if (deletedNode != null && deletedNode.getText().length() > 0) {
          retVal.setDeleted(Boolean.valueOf(deletedNode.getText()));
        }

        Node numberNode = (Node) pageNode.selectSingleNode("@number");
        if (numberNode != null && numberNode.getText().length() > 0) {
          retVal.setPageNumber(Integer.valueOf(numberNode.getText()));
        }

        Node rotationNode = (Node) pageNode.selectSingleNode("@rotation");
        if (rotationNode != null && rotationNode.getText().length() > 0) {
          retVal.setRotation(Rotation.getRotation(Integer.valueOf(rotationNode.getText())));
        }

      }
    } catch (Exception e) {
      log.warn(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
View Full Code Here


   * @return The xml tag values for the given xpath
   * @throws Exception
   */
  public static String getXmlValue(Document document, String xpath) {
    String retVal = "";
    Node node = document.selectSingleNode(xpath);
    if (node != null) {
      retVal = node.getText().trim();
    }
    return retVal;
  }
View Full Code Here

      try {
        synchronized(Environment.class){
          SAXReader reader = new SAXReader();
          Document document = reader.read(inputFile);
          for (AbstractPlugablePanel plugablePanel: plugins.values()) {
            Node node = document.selectSingleNode("/pdfsam_saved_jobs/plugin[@class=\""
                + plugablePanel.getClass().getName() + "\"]");
            if(node == null){
              //backwards compatibility
              node = document.selectSingleNode("/pdfsam_saved_jobs/plugin[@class=\""
                  + plugablePanel.getClass().getName().replaceAll("^org.pdfsam", "it.pdfsam") + "\"]");
            }
            if(node != null){
              plugablePanel.resetPanel();
              plugablePanel.loadJobNode(node);
            }
          }
          //set the selected plugin
          Node node = document.selectSingleNode("/pdfsam_saved_jobs/@selection");
          if(node!=null){
            treePanel.setSelectedPlugin(node.getText());
          }
          LOG.info(GettextResource.gettext(i18nMessages, "Environment loaded."));
        }
      } catch (Exception ex) {
        LOG.error(GettextResource.gettext(i18nMessages, "Error loading environment."),ex);
View Full Code Here

            throw new RuntimeException("Wrong element: " + root.getQName());
        }

        Iterator children = root.elementIterator();
        while (children.hasNext()) {
            Node n = (Node) children.next();
            String childName = n.getName();
            if (childName == null)
                continue;

            if (childName.equals("book")) {
                Book b = parseBook((Element) n);
View Full Code Here

        Iterator children = n.elementIterator();
        /*
         * parse book element, we have to once more iterate over children.
         */
        while (children.hasNext()) {
            Node child = (Node) children.next();
            String childName = child.getName();
            // empty/text nodes dont have name
            if (childName == null)
                continue;

            if (childName.equals("author")) {
View Full Code Here

        XPath xpath = DocumentHelper.createXPath("/xhtml:html/xhtml:body/xhtml:p");
        Map<String, String> namespaceUris = new HashMap<String, String>();
        namespaceUris.put("xhtml", "http://www.w3.org/1999/xhtml");
        xpath.setNamespaceURIs(namespaceUris);
       
        Node paragraphNode = xpath.selectSingleNode(doc);
        Assert.assertNotNull(paragraphNode);
        Assert.assertEquals("this is a test", paragraphNode.getText());
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public void removeNamespaces( Element elem )
    {
        elem.setQName( QName.get( elem.getName(), Namespace.NO_NAMESPACE, elem.getQualifiedName() ) );

        Node n;

        Iterator<Node> it = elem.elementIterator();
        while ( it.hasNext() )
        {
            n = it.next();

            switch ( n.getNodeType() )
            {
                case Node.ATTRIBUTE_NODE:
                    ( (Attribute) n ).setNamespace( Namespace.NO_NAMESPACE );
                    break;
                case Node.ELEMENT_NODE:
View Full Code Here

     */
    public void checkMessages(XMLFile messagesDoc) throws DocumentException {
        // Detector elements must all have a class attribute
        // and details child element.
        for (Iterator<Node> i = messagesDoc.xpathIterator("/MessageCollection/Detector"); i.hasNext();) {
            Node node = i.next();
            messagesDoc.checkAttribute(node, "class");
            messagesDoc.checkElement(node, "Details");
        }

        // BugPattern elements must all have type attribute
        // and ShortDescription, LongDescription, and Details
        // child elements.
        for (Iterator<Node> i = messagesDoc.xpathIterator("/MessageCollection/BugPattern"); i.hasNext();) {
            Node node = i.next();
            messagesDoc.checkAttribute(node, "type");
            messagesDoc.checkElement(node, "ShortDescription");
            messagesDoc.checkElement(node, "LongDescription");
            messagesDoc.checkElement(node, "Details");
        }

        // BugCode elements must contain abbrev attribute
        // and have non-empty text
        for (Iterator<Node> i = messagesDoc.xpathIterator("/MessageCollection/BugCode"); i.hasNext();) {
            Node node = i.next();
            messagesDoc.checkAttribute(node, "abbrev");
            messagesDoc.checkNonEmptyText(node);
        }

        // Check that all Detectors are described
View Full Code Here

         */
        public Set<String> collectAttributes(String xpath, String attrName) throws DocumentException {
            Set<String> result = new HashSet<String>();

            for (Iterator<Node> i = xpathIterator(xpath); i.hasNext();) {
                Node node = i.next();
                String value = checkAttribute(node, attrName).getValue();
                result.add(value);
            }

            return result;
View Full Code Here

       
        dependencies.clear();
       
        if (null != dependenciesNode) {
            for (int i = 0; i < dependenciesNode.nodeCount(); i++) {
                Node dependecyNode = (Node) dependenciesNode.node(i);
                if (Node.ELEMENT_NODE == dependecyNode.getNodeType()) {
                    Dependency dependency = XmlUtils.readDependencyFromXml(dependecyNode, true);
                    if (-1 == dependencies.indexOf(dependency)) {
                        dependencies.add(dependency);
                    }
                }
View Full Code Here

TOP

Related Classes of org.dom4j.Node

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.