Package org.dom4j

Examples of org.dom4j.Document


   {
      processDir(jbossHome);
      try
      {
         DocumentFactory df = DocumentFactory.getInstance();
         Document doc = df.createDocument();
         Element root = doc.addElement("jar-versions");
         Iterator iter = jars.iterator();
         while( iter.hasNext() )
         {
            JarInfo info = (JarInfo) iter.next();
            info.writeXML(root);
View Full Code Here


    }
    if (StringUtils.isEmpty(entity.getTitle())) {
      errors.add(Messages.get("title_is_empty"));
    }
    try {
      Document document = DocumentHelper.parseText(entity.getContent());
      if (!document.getRootElement().getName().equals("structure")) {
        errors.add(Messages.get("structure.invalid_xml"));
      }
    } catch (DocumentException e) {
      errors.add(Messages.get("parsing_error") + " " + e.getMessage());
    }
View Full Code Here

  @Override
  public List<PluginPropertyVO> getProperties(PluginEntity plugin) {
    List<PluginPropertyVO> result = new ArrayList<PluginPropertyVO>();
    try {
      Document doc = DocumentHelper.parseText(plugin.getConfigStructure());
      for (Element e : (List<Element>)doc.getRootElement().elements()) {
        if (e.getName().equals("param")) {
          PluginPropertyVO p = new PluginPropertyVO();
          if (e.attributeValue("name") == null) {
            logger.error("There must be name attribute for param tag.");
            continue;
View Full Code Here

    Element element = null;

    if (node instanceof Element) {
      element = (Element) node;
    } else if (node instanceof Document) {
      Document doc = (Document) node;
      element = doc.getRootElement();
    } else if (node instanceof Node) {
      element = ((Node) node).getParent();
    }

    if (element != null) {
View Full Code Here

        Node node = element.node(i);
        mod.fireRule(node);
      }
    } else if (input instanceof Document) {
      // iterate through all children
      Document document = (Document) input;
      for (int i = 0, size = document.nodeCount(); i < size; i++) {
        Node node = document.node(i);
        mod.fireRule(node);
      }
    } else if (input instanceof List) {
      List list = (List) input;
View Full Code Here

          if (modifiedElement != null) {
            // Restore parent + document
            modifiedElement.setDocument(origElement.getDocument());

            // Replace old with new element in parent
            Document doc = origElement.getDocument();
            doc.setRootElement(modifiedElement);
          }

          // Remove the old element
          origElement.detach();
        }
View Full Code Here

    {
        FileInputStream fileIS = new FileInputStream(fileName);
        ZipInputStream zipIS = new ZipInputStream(fileIS);

        ZipEntry entry;
        Document tocDoc = null;
        while ((entry = zipIS.getNextEntry()) != null) {
            if (entry.getName().compareTo(Package.DefaultPackageFileName) == 0) {
                SAXReader reader = new SAXReader();
                tocDoc = reader.read(zipIS);
                break;
            }
        }

        if (tocDoc == null) {
            return Collections.emptyList();
        }

        List<String> result = new ArrayList<String>();

        Element filesElement = tocDoc.getRootElement().element("files");
        List<Element> fileElementList = filesElement.elements("file");
        for (Element el : fileElementList) {
            String docFullName = el.getStringValue();

            if (patternFilter == null || docFullName.matches(patternFilter)) {
View Full Code Here

    {
        FileInputStream fileIS = new FileInputStream(fileName);
        ZipInputStream zipIS = new ZipInputStream(fileIS);

        ZipEntry entry;
        Document tocDoc = null;
        while ((entry = zipIS.getNextEntry()) != null) {
            if (entry.getName().compareTo(Package.DefaultPackageFileName) == 0) {
                SAXReader reader = new SAXReader();
                tocDoc = reader.read(zipIS);
                break;
            }
        }

        if (tocDoc == null) {
            return Collections.emptyList();
        }

        List<DocumentReference> result = new ArrayList<DocumentReference>();

        Pattern pattern = patternFilter == null ? null : Pattern.compile(patternFilter);

        Element filesElement = tocDoc.getRootElement().element("files");
        @SuppressWarnings("unchecked")
        List<Element> fileElementList = filesElement.elements("file");
        for (Element el : fileElementList) {
            String docFullName = el.getStringValue();
View Full Code Here

   * @param manifest the imsmanifest.xml file
   * @param itemStatus a Map containing the status of each item like "completed, not attempted, ..."
   */
  public ScormCPManifestTreeModel(File manifest, Map itemStatus) {
    this.itemStatus = itemStatus;
    Document doc = loadDocument(manifest);
    // get all organization elements. need to set namespace
    rootElement = doc.getRootElement();
    String nsuri = rootElement.getNamespace().getURI();
    nsuris.put( "ns", nsuri);

    XPath meta = rootElement.createXPath("//ns:organization");
    meta.setNamespaceURIs(nsuris);
View Full Code Here

  }
 
  private Document loadDocument(File documentF) {
    FileInputStream in = null;
    BufferedInputStream bis = null;
    Document doc = null;
    try {
      in = new FileInputStream(documentF);
      bis = new BufferedInputStream(in);
      XMLParser xmlParser = new XMLParser(new IMSEntityResolver());
      doc = xmlParser.parse(bis, false);
View Full Code Here

TOP

Related Classes of org.dom4j.Document

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.