in xml2fastinfoset-plugin/src/main/java/org/apache/cxf/maven_plugin/xml2fastinfoset/XML2FastInfosetCompilerMojo.java [204:226]
private void dehydrate(InputStream input, OutputStream output) throws ParserConfigurationException,
SAXException, IOException {
// Create Fast Infoset SAX serializer
SAXDocumentSerializer saxDocumentSerializer = new SAXDocumentSerializer();
// Set the output stream
saxDocumentSerializer.setOutputStream(output);
// Instantiate JAXP SAX parser factory
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
saxParserFactory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
saxParserFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
/*
* Set parser to be namespace aware Very important to do otherwise
* invalid FI documents will be created by the SAXDocumentSerializer
*/
saxParserFactory.setNamespaceAware(true);
// Instantiate the JAXP SAX parser
SAXParser saxParser = saxParserFactory.newSAXParser();
// Set the lexical handler
saxParser.setProperty("http://xml.org/sax/properties/lexical-handler", saxDocumentSerializer);
// Parse the XML document and convert to a fast infoset document
saxParser.parse(input, saxDocumentSerializer);
}