java - org.w3c.dom.ls.LSSerialize - setting text wrapping, indentation size -
I am using the following code to indent a xml document which is provided to me as a string.
I am using the jdk implementation of org.w3c.dom.ls
, if this is the case.
public string format (string xml) {Try {Final InputSource src = New Input Source (New Stringer (XML)); Final node document = DocumentBuilderFactory.newInstance (). NewDocumentBuilder (). Parse (src) .getDocumentElement (); Keep the last boolean declaration = boolean.valof (xml.startsWith ("& lt ;? xml")); // it may be required: System.setProperty (DOMImplementationRegistry.PROPERTY, "com.sun.org.apache.xerces.internal.dom.DOMIfplementationSourceImpl"); Last DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance (); Last DOMImplementationLS impl = (DOMImplementationLS) Registry .getDOMImplementation ("LS"); Last LSSerializer Author = impl.createLSSerializer (); Writer.getDomConfig () SetParameter ("format-beautiful print", boolean. TRUE); // Set it to True Writer.getDomConfig () if the output needs to be decorated. SetParameter ("XML-Announcement", Maintenance); // Set this to true if the manifesto needs to be output return author. Written tossing (document); } Hold (exception e) {new runtime exception (e); }}
Is there any way to define any of the following:
- Size of indent
- Wrapping text or what I do or do not,
- If I want to wrap the text then the maximum line length
I have tried to look at Jawadox and online examples ... but no one Not even found example. I only looked at examples that use an old API, which is now deprecated.
Comments
Post a Comment