Used to supply options for loading, saving, and compiling, and validating.
There are two styles for using XmlOptions: multiline setup, and single-line use. Here are two examples. First, multiline style:
XmlOptions opts = new XmlOptions(); opts.setSavePrettyPrint(); opts.setSavePrettyPrintIndent(4); System.out.println(xobj.xmlText(opts));
The alternative is single-line usage:
System.out.println(xobj.xmlText( new XmlOptions().setSavePrettyPrint().setSavePrettyPrintIndent(4)));
Table showing where each option gets used. Note that:
- options available for
newInstance
methods will also apply for parse
methods - options used for
validate
methods are also used for compile
methods, since compilation usually implies validation against Schema for Schemas
newInstance methods | parse methods | validate methods | compile methods | save and xmlText methods |
setDocumentType setDocumentSourceName setValidateOnSet setUnsynchronized | setLoad*** setEntityResolver | setErrorListener setValidateTreatLaxAsSkip | setErrorListener setCompile*** setEntityResolver setGenerateJavaVersion | setSave*** setUseDefaultNamespace setCharacterEncoding |