Package org.jdom2.output

Examples of org.jdom2.output.XMLOutputter


            format = Format.getCompactFormat();
        }
        if (encoding != null) {
            format.setEncoding(encoding);
        }
        final XMLOutputter outputter = new XMLOutputter(format);
        outputter.output(doc, writer);
    }
View Full Code Here


    @Override
    protected Description parseItemDescription(final Element rssRoot, final Element eDesc) {
        final Description desc = new Description();
        final StringBuilder sb = new StringBuilder();
        final XMLOutputter xmlOut = new XMLOutputter();
        for (final Content c : eDesc.getContent()) {
            switch (c.getCType()) {
                case Text:
                case CDATA:
                    sb.append(c.getValue());
                    break;
                case EntityRef:
                    LOG.debug("Entity: {}", c.getValue());
                    sb.append(c.getValue());
                    break;
                case Element:
                    sb.append(xmlOut.outputString((Element) c));
                    break;
                default:
                    // ignore
                    break;
            }
View Full Code Here

            value = Base64.decode(e.getText());

        } else if (mode.equals(Content.XML)) {

            final XMLOutputter outputter = new XMLOutputter();
            final List<org.jdom2.Content> contents = e.getContent();
            for (final org.jdom2.Content content : contents) {
                if (content instanceof Element) {
                    final Element element = (Element) content;
                    if (element.getNamespace().equals(getAtomNamespace())) {
                        element.setNamespace(Namespace.NO_NAMESPACE);
                    }
                }

            }
            value = outputter.outputString(contents);

        }

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

        }

        String value = null;
        if (type.equals(Content.XHTML) || type.indexOf("/xml") != -1 || type.indexOf("+xml") != -1) {
            // XHTML content needs special handling
            final XMLOutputter outputter = new XMLOutputter();
            final List<org.jdom2.Content> contents = e.getContent();
            for (final org.jdom2.Content content : contents) {
                if (content instanceof Element) {
                    final Element element = (Element) content;
                    if (element.getNamespace().equals(getAtomNamespace())) {
                        element.setNamespace(Namespace.NO_NAMESPACE);
                    }
                }
            }
            value = outputter.outputString(contents);
        } else {
            // Everything else comes in verbatim
            value = e.getText();
        }
View Full Code Here

        final Document feedDoc = wireFeedOutput.outputJDom(feed1);

        // Grab entry element from feed and get JDOM to serialize it
        final Element entryElement = feedDoc.getRootElement().getChildren().get(0);

        final XMLOutputter outputter = new XMLOutputter();
        outputter.output(entryElement, writer);
    }
View Full Code Here

            .getY())));
        point.setAttribute(new Attribute("T", String.valueOf((int) p
            .getT())));
        doc.getRootElement().addContent(point);
      }
      XMLOutputter xmlOutput = new XMLOutputter();
      xmlOutput.setFormat(Format.getPrettyFormat());
     
      // TODO: We will have to change how to save the file. Because when
      // we will have a executable JAR file, it will be impossible to
      // dynamically add new files into it (well I'm pretty sure about that,
      // but maybe I'm wrong ?)
      // One way to bypass this limitation : When we're executing the app with
      // the JAR file :
      // 1. Create a temporary directory
      // 2. Add the new files (like new gesture files)
      // 3. Add into the exiting application listener, either :
      // 4.1. Recreate a jar file with the new files, and delete the old one
      // (and the temp directory).
      // 4.2. Execute the jar command with the 'u' option, which you can use
      // to update the contents of an existing JAR file.
      xmlOutput.output(doc, new FileWriter(filename));

    } catch (IOException e1) {
      success = false;
    }
View Full Code Here

                    Element newPlay = new Element("play");
                    saveNewPlay(newPlay, cPlay, args);
                    newPlayer.addContent(newPlay);
                    rootNode.addContent(newPlayer);
                }
                XMLOutputter xmlOutput = new XMLOutputter();

                xmlOutput.setFormat(Format.getPrettyFormat());
                xmlOutput.output(document, new FileWriter(gameFile));
                System.out.println("Games file updated!");
            } catch (IOException e) {
                System.out.println(e.getMessage());
            } catch (JDOMException jdome) {
                System.out.println(jdome.getMessage());
            }
        } else {
            System.out.println("Games file doesn't exist!");
            System.out.println("Create new games file");
            try {
                Element plays = new Element("plays");
                Document doc = new Document(plays);

                Element newPlayer = new Element("player");
                newPlayer.setAttribute(new Attribute("id", cPlay.getOwner()));
                Element newPlay = new Element("play");
                saveNewPlay(newPlay, cPlay, args);
                newPlayer.addContent(newPlay);
                doc.getRootElement().addContent(newPlayer);

                XMLOutputter xmlOutput = new XMLOutputter();

                xmlOutput.setFormat(Format.getPrettyFormat());
                xmlOutput.output(doc, new FileWriter(gameFile));

                System.out.println("Game file Created & updated!");
            } catch (IOException e) {
                System.out.println(e.getMessage());
            }
View Full Code Here

            System.out.println("Player file doesn't exist!");
            try {
                Element players = new Element("players");
                Document doc = new Document(players);

                XMLOutputter xmlOutput = new XMLOutputter();

                xmlOutput.setFormat(Format.getPrettyFormat());
                xmlOutput.output(doc, new FileWriter(playerFile));

                System.out.println("Player file Created!");
            } catch (IOException e) {
                System.out.println(e.getMessage());
            }
View Full Code Here

            pl.addContent(new Element("uuid").setText(player.getPlayerID()));
            pl.addContent(new Element("email").setText(player.getPlayerEmail()));
            pl.addContent(new Element("password").setText(player.getPlayerPassword()));
            doc.getRootElement().addContent(pl);

            XMLOutputter xmlOutput = new XMLOutputter();

            xmlOutput.setFormat(Format.getPrettyFormat());
            xmlOutput.output(doc, new FileWriter("players.xml"));

            System.out.println("Player file Updated!");

        } catch (IOException e) {
            e.printStackTrace();
View Full Code Here

                Document document = domBuilder.build((org.w3c.dom.Document) node);
                return document.getRootElement();
            }
        }
        // we have no other option than to transform
        JDOMResult jdomResult = new JDOMResult();
        transform(requestPayload, jdomResult);
        return jdomResult.getDocument().getRootElement();
    }
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.