-
Notifications
You must be signed in to change notification settings - Fork 78
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
marshalling to string with pretty print #235
Comments
No, there is no such way at the moment. Jsonix uses |
I recently stumbled across this too and was hoping for an easy config option to output a pretty printed string. |
I've got something of a 'solution'. var xsltDoc = new DOMParser().parseFromString(
[
// describes how we want to modify the XML - indent everything
"<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>",
" <xsl:output omit-xml-declaration='no' indent='yes'/>",
" <xsl:template match='node()|@*'>",
" <xsl:copy>",
" <xsl:apply-templates select='node()|@*'/>",
" </xsl:copy>",
" </xsl:template>",
"</xsl:stylesheet>",
].join("\n"),
"application/xml"
);
var xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsltDoc);
var pretty_doc = xsltProcessor.transformToDocument(doc); One problem is that it will strip out CDATA sections. If you know ahead of time which you want to retain then you can add the following attribute to the xsl:output element |
As far as I can see, there is no way to marshalString to provide formatted output that would be suitable for saving to a file.
Am I missing something?
The text was updated successfully, but these errors were encountered: