Setting a stylesheet ref when outputting XML using SAXTransformerFactory
659725Sep 27 2012 — edited Sep 27 2012Hello, I am using SAXTransformerFactory to output an XML file but can't figure out how to output the stylesheet setting, for example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ectd:ectd SYSTEM "util/dtd/ich-ectd-3-2.dtd">
<?xml-stylesheet type="text/xsl" href="util/style/ectd-2-0.xsl"?>
I am using the following code to get the first two lines, I just can't see how to output the third line above.
SAXTransformerFactory mTransformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
TransformerHandler handler = mTransformerFactory.newTransformerHandler();
Transformer mTransformer = handler.getTransformer();
mTransformer.setOutputProperty(OutputKeys.VERSION, "1.0");
mTransformer.setOutputProperty(OutputKeys.ENCODING, IBF_UtilXML.XML_ENCODING_UTF8);
mTransformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "util/dtd/ich-ectd-3-2.dtd");
I believe I found an example using a DOM approach but I would much prefer using SAX. Any assistance on outputting this line would be most appreciated:
<?xml-stylesheet type="text/xsl" href="util/style/ectd-2-0.xsl"?>
Thanks