Package org.dom4j.io

Examples of org.dom4j.io.SAXReader


public class XmlSerializer implements Serializer {

  public Document deserialize(InputStream in) throws IOException {
    try {
      return new SAXReader().read(in);
    } catch (DocumentException e) {
      throw new RuntimeException("Error while parsing stream", e);
    }
  }
View Full Code Here


   
    @Override
    public void prepare(FlowProcess process, OperationCall<NullContext> opCall) {
        super.prepare(process, opCall);
       
        _reader = new SAXReader(new Parser());
        _reader.setXMLFilter(new DowngradeXmlFilter(_removeNamespaces));
        _reader.setEncoding("UTF-8");
        _input = new ParsedDatum();
    }
View Full Code Here

      log.info("Loading mods from " + modsUrl);
      URL url = new URL(modsUrl);
      URLConnection conn = url.openConnection();
      conn.setUseCaches(false);

      SAXReader reader = new SAXReader();
      Document document = reader.read(conn.getInputStream());
      Element root = document.getRootElement();

      for (Iterator i = root.elementIterator("mod"); i.hasNext();) {
        final Element mod = (Element) i.next();
        JMenuItem mi = new JMenuItem(mod.element("name").getTextTrim());
View Full Code Here

        // configure a non-validating parser that ignores DTD
        SAXParser sp = new SAXParser();
//                sp.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false);

        try {
            return new SAXReader(sp).read(
                    new InputStreamReader(page.getResponseBodyAsStream(), page.getResponseCharSet()));
        } catch (DocumentException e) {
            throw (IOException)new IOException("Failed to parse the response HTML into DOM").initCause(e);
        }
    }
View Full Code Here

    {
        this.documentType = type;
        this.xmlUrl = url;

        InputStream in = null;
        SAXReader reader = new SAXReader();
       
        try
        {
            in = url.openStream();
            InputStreamReader inReader = new InputStreamReader( in, "UTF-8" );
            LatinEntityResolutionReader latinReader = new LatinEntityResolutionReader( inReader );
            this.document = reader.read( latinReader );
        }
        catch ( DocumentException e )
        {
            throw new XMLException( "Unable to parse " + documentType + " xml " + xmlUrl + ": " + e.getMessage(), e );
        }
View Full Code Here

        return schema;
    }

    public Document parseSchema( InputStream file ) throws DocumentException {
        SAXReader reader = new SAXReader();
        Document document = reader.read( file );

        return document;
    }
View Full Code Here

        readXML( xmlRoot );
    }

    private Document parseXML( URL file ) throws DocumentException {
        SAXReader reader = new SAXReader();
        Document document = reader.read( file );

        return document;
    }
View Full Code Here

   *             Throws if the relationship part is invalid.
   */
  private void parseRelationshipsPart(PackagePart relPart)
      throws InvalidFormatException {
    try {
      SAXReader reader = new SAXReader();
      logger.log(POILogger.DEBUG, "Parsing relationship: " + relPart.getPartName());
      Document xmlRelationshipsDoc = reader
          .read(relPart.getInputStream());

      // Browse default types
      Element root = xmlRelationshipsDoc.getRootElement();

View Full Code Here

   *             invalid.
   */
  private void parseContentTypesFile(InputStream in)
      throws InvalidFormatException {
    try {
      SAXReader xmlReader = new SAXReader();
      Document xmlContentTypetDoc = xmlReader.read(in);

      // Default content types
      List defaultTypes = xmlContentTypetDoc.getRootElement().elements(
          DEFAULT_TAG_NAME);
      Iterator elementIteratorDefault = defaultTypes.iterator();
View Full Code Here

      } else
        throw new IOException(
            "Error while trying to get the part input stream.");
    }

    SAXReader xmlReader = new SAXReader();
    Document xmlDoc;
    try {
      xmlDoc = xmlReader.read(in);

      /* Check OPC compliance */

      // Rule M4.2, M4.3, M4.4 and M4.5/
      checkElementForOPCCompliance(xmlDoc.getRootElement());
View Full Code Here

TOP

Related Classes of org.dom4j.io.SAXReader

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.