}
// bnux and XOM
BinaryXMLCodec codec = new BinaryXMLCodec();
NodeFactory bnuxFactory = null;
if (mode.startsWith("bnux")) {
if (mode.indexOf("NNF") >= 0) {
bnuxFactory = XOMUtil.getNullNodeFactory();
}
}
Builder builder = new Builder();
// Builder builder = BuilderPool.GLOBAL_POOL.getBuilder(false);
if (mode.equals("xom-V")) {
builder = new Builder(new NodeFactory() {});
}
if (mode.equals("xom-NNF")) {
builder = new Builder(XOMUtil.getNullNodeFactory());
}
// saxon
StaticQueryContext context = null;
Transformer saxonSerializer = null;
if (mode.equals("saxon")) {
context = new StaticQueryContext(new Configuration());
String clazz = "net.sf.saxon.TransformerFactoryImpl";
System.setProperty("javax.xml.transform.TransformerFactory", clazz);
saxonSerializer = TransformerFactory.newInstance().newTransformer();
}
// DOM
DocumentBuilder domBuilder = null;
Transformer domSerializer = null;
if (mode.equals("dom")) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setAttribute("http://apache.org/xml/features/dom/defer-node-expansion", Boolean.FALSE);
domBuilder = factory.newDocumentBuilder();
String clazz = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";
// String clazz = "org.apache.xalan.processor.TransformerFactoryImpl";
System.setProperty("javax.xml.transform.TransformerFactory", clazz);
domSerializer = TransformerFactory.newInstance().newTransformer();
System.err.println(domSerializer.getClass().getName());
}
// FastInfoSet
Object fiSerializer = null;
// XMLStreamWriter fiStaxSerializer = null;
Builder fiBuilder = null;
Method fiMethod = null;
XMLStreamReader fistaxReader = null;
Method fistaxMethod = null;
if (mode.startsWith("fi")) {
NodeFactory factory = null;
if (mode.indexOf("NNF") >= 0) factory = XOMUtil.getNullNodeFactory();
XMLReader parser = (XMLReader) Class.forName("com.sun.xml.fastinfoset.sax.SAXDocumentParser").newInstance();
fiBuilder = new Builder(parser, false, factory);
if (mode.indexOf("stax") >= 0) {
fiSerializer = (XMLStreamWriter) Class.forName("com.sun.xml.fastinfoset.stax.StAXDocumentSerializer").newInstance();
} else {
fiSerializer = (ContentHandler) Class.forName("com.sun.xml.fastinfoset.sax.SAXDocumentSerializer").newInstance();
}
if (mode.startsWith("fi1")) { // enable "full indexing"
Method method;
method = fiSerializer.getClass().getMethod(
"setAttributeValueSizeLimit", new Class[] {Integer.TYPE});
method.invoke(fiSerializer, new Object[] {new Integer(Integer.MAX_VALUE)});
method = fiSerializer.getClass().getMethod(
"setCharacterContentChunkSizeLimit", new Class[] {Integer.TYPE});
method.invoke(fiSerializer, new Object[] {new Integer(Integer.MAX_VALUE)});
}
fiMethod = fiSerializer.getClass().getMethod(
"setOutputStream", new Class[] { OutputStream.class});
if (mode.indexOf("stax") >= 0) {
fistaxReader = (XMLStreamReader) Class.forName("com.sun.xml.fastinfoset.stax.StAXDocumentParser").newInstance();
fistaxMethod = fistaxReader.getClass().getMethod(
"setInputStream", new Class[] { InputStream.class});
}
}
// StAX
Builder staxBuilder = null;
if (mode.indexOf("stax") >= 0) {
NodeFactory factory = null;
if (mode.indexOf("NNF") >= 0) factory = XOMUtil.getNullNodeFactory();
staxBuilder = StaxUtil.createBuilder(staxInputFactory, factory);
}
for (int j=5; j < args.length; j++) {