Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need pretty-printing of XML once transforms happen #213

Open
sfloess opened this issue Mar 22, 2016 · 0 comments
Open

Need pretty-printing of XML once transforms happen #213

sfloess opened this issue Mar 22, 2016 · 0 comments

Comments

@sfloess
Copy link
Member

sfloess commented Mar 22, 2016

Once we have transforms performed, we need to run the xml through a transform for pretty printing due to limitations in the Saxon HE.

Here are some reasonable links:

Default Java transformer = com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl

Will need to use the saxon transform to blindly transform and the aforementioned transformer to pretty print:

    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
    transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");

    StringWriter stringWriter = new StringWriter();
    StreamResult streamResult = new StreamResult(stringWriter);

    transformer.transform(new StringSource(xml), streamResult);

    System.out.println(stringWriter.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant