Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Generic way to set indent-amount on Transformer?

843834Oct 3 2003 — edited Oct 6 2003
Does anyone know if there is a generic way to set the indent-amount on a transformer? I'm guessing the property below is specific to apache transformers. I believe we're using an apache transformer by default, but what if the default changes in the future? Is there a way to identify which transformer you're using and set an appropriate custom property?
TransformerFactory tf = TransformerFactory.newInstance();
if (tf.getFeature(SAXTransformerFactory.FEATURE) == false) {
    throw new CISException(ErrorCodes.SAX_TRANSFORMER, "");
}
SAXTransformerFactory stf = (SAXTransformerFactory)tf;
TransformerHandler hd = stf.newTransformerHandler();
Transformer serializer = hd.getTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
return hd;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 3 2003
Added on Oct 3 2003
3 comments
402 views