Java 类org.jdom.output.SAXOutputter 实例源码

项目:gate-core    文件:CreoleRegisterImpl.java   
private void processFullCreoleXmlTree(Plugin plugin,
    Document jdomDoc, CreoleAnnotationHandler annotationHandler)
    throws GateException, IOException, JDOMException {
  // now we can process any annotations on the new classes
  // and augment the XML definition
  annotationHandler.processAnnotations(jdomDoc);

  // debugging
  if(DEBUG) {
    XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat());
    xmlOut.output(jdomDoc, System.out);
  }

  // finally, parse the augmented definition with the normal parser
  DefaultHandler handler =
      new CreoleXmlHandler(this, plugin);
  SAXOutputter outputter =
      new SAXOutputter(handler, handler, handler, handler);
  outputter.output(jdomDoc);
  if(DEBUG) {
    Out.prln("done parsing " + plugin);
  }
}
项目:pathvisio    文件:GpmlFormatAbstract.java   
/**
 * validates a JDOM document against the xml-schema definition specified by 'xsdFile'
 * @param doc the document to validate
 */
public void validateDocument(Document doc) throws ConverterException
{
    ClassLoader cl = Pathway.class.getClassLoader();
    InputStream is = cl.getResourceAsStream(xsdFile);
    if(is != null) {
        Schema schema;
        try {
            SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            StreamSource ss = new StreamSource (is);
            schema = factory.newSchema(ss);
            ValidatorHandler vh =  schema.newValidatorHandler();
            SAXOutputter so = new SAXOutputter(vh);
            so.output(doc);
            // If no errors occur, the file is valid according to the gpml xml schema definition
            Logger.log.info("Document is valid according to the xml schema definition '" +
                    xsdFile.toString() + "'");
        } catch (SAXException se) {
            Logger.log.error("Could not parse the xml-schema definition", se);
            throw new ConverterException (se);
        } catch (JDOMException je) {
            Logger.log.error("Document is invalid according to the xml-schema definition!: " +
                    je.getMessage(), je);
            XMLOutputter xmlcode = new XMLOutputter(Format.getPrettyFormat());

            Logger.log.error("The invalid XML code:\n" + xmlcode.outputString(doc));
            throw new ConverterException (je);
        }
    } else {
        Logger.log.error("Document is not validated because the xml schema definition '" +
                xsdFile + "' could not be found in classpath");
        throw new ConverterException ("Document is not validated because the xml schema definition '" +
                xsdFile + "' could not be found in classpath");
    }
}
项目:wso2-axis2    文件:StockClient2.java   
public XMLStreamReader getReader() throws XMLStreamException {
    SAXOMBuilder builder = new SAXOMBuilder();
    SAXOutputter outputter = new SAXOutputter();
    outputter.setContentHandler(builder);
    outputter.setEntityResolver(builder);
    outputter.setDTDHandler(builder);
    outputter.setEntityResolver(builder);
    return builder.getRootElement().getXMLStreamReader();
}