Package org.jdom2

Examples of org.jdom2.Document


   */
  public MissionsWriter(String fileName) {
    missionsName = new ArrayList<String>();
    missions = new ArrayList<String>();

    xml = new Document();

    this.fileName = new String(fileName + ".xml");
  }
View Full Code Here


        XMLOutputter xmlOutput = new XMLOutputter();
        // display nice nice
        xmlOutput.setFormat(Format.getPrettyFormat());

        //parse the document
        Document doc = parser.build(originalPomFile);
        Element versionElem = findVersionElement(doc);
        versionElem.setText(newVersion);
        xmlOutput.output(doc, writer);
        writer.flush();
        writer.close();
View Full Code Here

    SAXBuilder saxBuilder = createSAXBuilder();
    try {
      if (_xmlHealerOn) {
        reader = new XmlFixerReader(reader);
      }
      Document document = saxBuilder.build(reader);
      return build(document);
    } catch (JDOMParseException ex) {
      throw new ParsingFeedException("Invalid XML: " + ex.getMessage(), ex);
    } catch (IllegalArgumentException ex) {
      throw ex;
View Full Code Here

   *
   */
  public WireFeed build(InputSource is) throws IllegalArgumentException, FeedException {
    SAXBuilder saxBuilder = createSAXBuilder();
    try {
      Document document = saxBuilder.build(is);
      return build(document);
    } catch (JDOMParseException ex) {
      throw new ParsingFeedException("Invalid XML: " + ex.getMessage(), ex);
    } catch (IllegalArgumentException ex) {
      throw ex;
View Full Code Here

   * @throws FeedException
   *             thrown if the XML representation for the feed could not be created.
   *
   */
  public String outputString(WireFeed feed, boolean prettyPrint) throws IllegalArgumentException, FeedException {
    Document doc = outputJDom(feed);
    String encoding = feed.getEncoding();
    Format format = prettyPrint ? Format.getPrettyFormat() : Format.getCompactFormat();
    if (encoding != null) {
      format.setEncoding(encoding);
    }
View Full Code Here

   * @throws FeedException
   *             thrown if the XML representation for the feed could not be created.
   *
   */
  public void output(WireFeed feed, Writer writer, boolean prettyPrint) throws IllegalArgumentException, IOException, FeedException {
    Document doc = outputJDom(feed);
    String encoding = feed.getEncoding();
    Format format = prettyPrint ? Format.getPrettyFormat() : Format.getCompactFormat();
    if (encoding != null) {
      format.setEncoding(encoding);
    }
View Full Code Here

   * @throws FeedException
   *             thrown if the W3C DOM document for the feed could not be created.
   *
   */
  public org.w3c.dom.Document outputW3CDom(WireFeed feed) throws IllegalArgumentException, FeedException {
    Document doc = outputJDom(feed);
    DOMOutputter outputter = new DOMOutputter();
    try {
      return outputter.output(doc);
    } catch (JDOMException jdomEx) {
      throw new FeedException("Could not create DOM", jdomEx);
View Full Code Here

   *
   */
  public WireFeed build(org.w3c.dom.Document document) throws IllegalArgumentException, FeedException {
    DOMBuilder domBuilder = new DOMBuilder();
    try {
      Document jdomDoc = domBuilder.build(document);
      return build(jdomDoc);
    } catch (IllegalArgumentException ex) {
      throw ex;
    } catch (Exception ex) {
      throw new ParsingFeedException("Invalid XML", ex);
View Full Code Here

    protected Namespace getFeedNamespace() {
        return Namespace.NO_NAMESPACE;
    }

    protected Document createDocument(Element root) {
        return new Document(root);
    }
View Full Code Here

   * Parse entry from reader.
   */
  public static Entry parseEntry(Reader rd, String baseURI) throws JDOMException, IOException, IllegalArgumentException, FeedException {
    // Parse entry into JDOM tree
    SAXBuilder builder = new SAXBuilder();
    Document entryDoc = builder.build(rd);
    Element fetchedEntryElement = entryDoc.getRootElement();
    fetchedEntryElement.detach();

    // Put entry into a JDOM document with 'feed' root so that Rome can handle it
    Feed feed = new Feed();
    feed.setFeedType("atom_1.0");
    WireFeedOutput wireFeedOutput = new WireFeedOutput();
    Document feedDoc = wireFeedOutput.outputJDom(feed);
    feedDoc.getRootElement().addContent(fetchedEntryElement);

    if (baseURI != null) {
      feedDoc.getRootElement().setAttribute("base", baseURI, Namespace.XML_NAMESPACE);
    }

    WireFeedInput input = new WireFeedInput();
    Feed parsedFeed = (Feed) input.build(feedDoc);
    return (Entry) parsedFeed.getEntries().get(0);
View Full Code Here

TOP

Related Classes of org.jdom2.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.