Package org.jdom2.output

Examples of org.jdom2.output.XMLOutputter


                tile.setAttribute("type", String.valueOf(tiles[x][y].getType()));
                root.addContent(tile);
            }
        }

        XMLOutputter output = new XMLOutputter();
        try {
            output.output(document, new FileOutputStream(new File("res/maps/map.xml")));
        } catch (FileNotFoundException ex) {
            Logger.getLogger(TileGrid.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(TileGrid.class.getName()).log(Level.SEVERE, null, ex);
        }
View Full Code Here


    private LinkedList<String> doFilter(String in, Set<String> xpaths) throws IOException {
        LinkedList<String> result = new LinkedList<String>();
        try {
            Document doc = new SAXBuilder(XMLReaders.NONVALIDATING).build(new StringReader(in));
            XMLOutputter out = new XMLOutputter();

            for (String xp : xpaths) {
                XPathExpression<Content> xpath = XPathFactory.instance().compile(xp, Filters.content());
                for (Content node : xpath.evaluate(doc)) {
                    if(node instanceof Element)
                        result.add(out.outputString((Element) node));
                    else if(node instanceof Text)
                        result.add(out.outputString((Text) node));
                }
            }
            return result;
        } catch (JDOMException xpe) {
            throw new IllegalArgumentException("error while processing xpath expressions: '" + xpaths + "'", xpe);
View Full Code Here

        Properties props = new Properties();
        createLog(props, mcss);
        resultsGroup.setAttribute("log", props.toString());

        // Save options
        XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat());
        String optionsStr = outputter.outputString(rootElement);
        resultsGroup.setAttribute("options", optionsStr);
        rootGroup.setAttribute("options", optionsStr);

        return rootGroup;
    }
View Full Code Here

        logProps.putAll(props.getPropertyMap());
        createLog(logProps);
        resultsGroup.setAttribute("log", props.toString());

        // Save options
        XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat());
        String optionsStr = outputter.outputString(rootElement);
        resultsGroup.setAttribute("options", optionsStr);
        rootGroup.setAttribute("options", optionsStr);

        return rootGroup;
    }
View Full Code Here

      // do nothing XML Parser took care of this
      value = e.getText();
    } else if (mode.equals(Content.BASE64)) {
      value = Base64.decode(e.getText());
    } else if (mode.equals(Content.XML)) {
      XMLOutputter outputter = new XMLOutputter();
      List eContent = e.getContent();
      Iterator i = eContent.iterator();
      while (i.hasNext()) {
        org.jdom2.Content c = (org.jdom2.Content) i.next();
        if (c instanceof Element) {
          Element eC = (Element) c;
          if (eC.getNamespace().equals(getAtomNamespace())) {
            ((Element) c).setNamespace(Namespace.NO_NAMESPACE);
          }
        }
      }
      value = outputter.outputString(eContent);
    }

    Content content = new Content();
    content.setType(type);
    content.setMode(mode);
View Full Code Here

                writer.write(intro);
            }

            Format format = Format.getRawFormat();
            format.setLineSeparator(eol);
            XMLOutputter out = new XMLOutputter(format);
            out.output(document.getRootElement(), writer);

            if (outtro != null)
            {
                writer.write(outtro);
            }
View Full Code Here

            // rewrite DOM as a string to find differences, since text outside the root element is not tracked
            StringWriter w = new StringWriter();
            Format format = Format.getRawFormat();
            format.setLineSeparator(eol);
            XMLOutputter out = new XMLOutputter(format);
            out.output(document.getRootElement(), w);

            int index = content.indexOf(w.toString());
            if (index >= 0)
            {
                intro = content.substring(0, index);
View Full Code Here

        try {
            Format prettyFormat = flags.contains(RepresentationFactory.PRETTY_PRINT)
                    ? Format.getPrettyFormat()
                    : Format.getCompactFormat();

            final XMLOutputter outputter = new XMLOutputter(prettyFormat);
            outputter.output(element, writer);
        } catch (IOException e) {
            throw new RepresentationException(e);
        }
    }
View Full Code Here

   * @see Document
   */
  public static void saveFile(String fileName, Document document) {
   
    try {
      XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat());
      xmlOutputter.output(document, new FileOutputStream(fileName));
    }
    catch(java.io.IOException e){}
  }
View Full Code Here

   * Write the tree create by creatTree in the file.
   *
   * @see MissionsWriter#creatTree()
   */
  public void writeDocument() {
    XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat());
    try {
      xout.output(xml, new FileOutputStream(fileName));
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
View Full Code Here

TOP

Related Classes of org.jdom2.output.XMLOutputter

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.