Class XmlOptions

java.lang.Object
org.apache.xmlbeans.XmlOptions
All Implemented Interfaces:
Serializable

public class XmlOptions extends Object implements Serializable
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
Option matrix
newInstance methods parse methods validate methods compile methods save and xmlTextmethods
setDocumentType
setDocumentSourceName
setValidateOnSet
setUnsynchronized
setLoad***
setEntityResolver
setErrorListener
setValidateTreatLaxAsSkip setValidateStrict
setErrorListener
setCompile***
setEntityResolver
setBaseURI
setGenerateJavaVersion
setSave***
setUseDefaultNamespace
setCharacterEncoding
See Also:
  • Field Details

    • DEFAULT_ENTITY_EXPANSION_LIMIT

      public static final int DEFAULT_ENTITY_EXPANSION_LIMIT
      See Also:
  • Constructor Details

    • XmlOptions

      public XmlOptions()
      Construct a new blank XmlOptions.
    • XmlOptions

      public XmlOptions(XmlOptions other)
      Construct a new XmlOptions, copying the options.
  • Method Details

    • setSaveNamespacesFirst

      public XmlOptions setSaveNamespacesFirst()
      This option will cause the saver to save namespace attributes first.
      See Also:
    • setSaveNamespacesFirst

      public XmlOptions setSaveNamespacesFirst(boolean b)
    • isSaveNamespacesFirst

      public boolean isSaveNamespacesFirst()
    • setSavePrettyPrint

      public XmlOptions setSavePrettyPrint()
      This option will cause the saver to reformat white space for easier reading.
      See Also:
    • setSavePrettyPrint

      public XmlOptions setSavePrettyPrint(boolean b)
    • isSavePrettyPrint

      public boolean isSavePrettyPrint()
    • setSavePrettyPrintIndent

      public XmlOptions setSavePrettyPrintIndent(int indent)
      When used with setSavePrettyPrint this sets the indent amount to use.
      Parameters:
      indent - the indent amount to use
      See Also:
    • getSavePrettyPrintIndent

      public Integer getSavePrettyPrintIndent()
    • setSavePrettyPrintOffset

      public XmlOptions setSavePrettyPrintOffset(int offset)
      When used with setSavePrettyPrint this sets the offset amount to use.
      Parameters:
      offset - the offset amount to use
      See Also:
    • getSavePrettyPrintOffset

      public Integer getSavePrettyPrintOffset()
    • setCharacterEncoding

      public XmlOptions setCharacterEncoding(String encoding)
      When writing a document, this sets the character encoding to use.
      Parameters:
      encoding - the character encoding
      See Also:
    • getCharacterEncoding

      public String getCharacterEncoding()
    • setDocumentType

      public XmlOptions setDocumentType(SchemaType type)
      When parsing a document, this sets the type of the root element. If this is set, the parser will not try to guess the type based on the document's QName.
      Parameters:
      type - The root element's document type.
      See Also:
    • getDocumentType

      public SchemaType getDocumentType()
    • setErrorListener

      public XmlOptions setErrorListener(Collection<XmlError> c)

      Sets a collection object for collecting XmlError objects during parsing, validation, and compilation. When set, the collection will contain all the errors after the operation takes place. Notice that the errors will only have line numbers if the document was loaded with line numbers enabled.

      The following simple example illustrates using an error listener during validation.

      
       // Create an XmlOptions instance and set the error listener.
       XmlOptions validateOptions = new XmlOptions();
       ArrayList<XmlError> errorList = new ArrayList<>();
       validateOptions.setErrorListener(errorList);
      
       // Validate the XML.
       boolean isValid = newEmp.validate(validateOptions);
      
       // If the XML isn't valid, loop through the listener's contents,
       // printing contained messages.
       if (!isValid)
       {
            for (int i = 0; i < errorList.size(); i++)
            {
                XmlError error = (XmlError)errorList.get(i);
      
                System.out.println("\n");
                System.out.println("Message: " + error.getMessage() + "\n");
                System.out.println("Location of invalid XML: " +
                    error.getCursorLocation().xmlText() + "\n");
            }
       }
       
      Parameters:
      c - A collection that will be filled with XmlError objects via Collection.add(E)
      See Also:
    • getErrorListener

      public Collection<XmlError> getErrorListener()
    • setSaveAggressiveNamespaces

      public XmlOptions setSaveAggressiveNamespaces()
      Causes the saver to reduce the number of namespace prefix declarations. The saver will do this by passing over the document twice, first to collect the set of needed namespace declarations, and then second to actually save the document with the declarations collected at the root.
      See Also:
    • setSaveAggressiveNamespaces

      public XmlOptions setSaveAggressiveNamespaces(boolean b)
    • isSaveAggressiveNamespaces

      public boolean isSaveAggressiveNamespaces()
    • setSaveSyntheticDocumentElement

      public XmlOptions setSaveSyntheticDocumentElement(QName name)
      This option causes the saver to wrap the current fragment in an element with the given name.
      Parameters:
      name - the name to use for the top level element
      See Also:
    • getSaveSyntheticDocumentElement

      public QName getSaveSyntheticDocumentElement()
    • setUseDefaultNamespace

      public XmlOptions setUseDefaultNamespace()
      If this option is set, the saver will try to use the default namespace for the most commonly used URI. If it is not set the saver will always created named prefixes.
      See Also:
    • setUseDefaultNamespace

      public XmlOptions setUseDefaultNamespace(boolean b)
    • isUseDefaultNamespace

      public boolean isUseDefaultNamespace()
    • setSaveImplicitNamespaces

      public XmlOptions setSaveImplicitNamespaces(Map<String,String> implicitNamespaces)
      If namespaces have already been declared outside the scope of the fragment being saved, this allows those mappings to be passed down to the saver, so the prefixes are not re-declared.
      Parameters:
      implicitNamespaces - a map of prefixes to uris that can be used by the saver without being declared
      See Also:
    • getSaveImplicitNamespaces

      public Map<String,String> getSaveImplicitNamespaces()
    • setSaveSuggestedPrefixes

      public XmlOptions setSaveSuggestedPrefixes(Map<String,String> suggestedPrefixes)
      A map of hints to pass to the saver for which prefixes to use for which namespace URI.
      Parameters:
      suggestedPrefixes - a map from URIs to prefixes
      See Also:
    • getSaveSuggestedPrefixes

      public Map<String,String> getSaveSuggestedPrefixes()
    • setSaveFilterProcinst

      public XmlOptions setSaveFilterProcinst(String filterProcinst)
      This option causes the saver to filter a Processing Instruction with the given target
      Parameters:
      filterProcinst - the name of a Processing Instruction to filter on save
      See Also:
    • getSaveFilterProcinst

      public String getSaveFilterProcinst()
    • setSaveSubstituteCharacters

      public XmlOptions setSaveSubstituteCharacters(XmlOptionCharEscapeMap characterReplacementMap)
      This option causes the saver to replace characters with other values in the output stream. It is intended to be used for escaping non-standard characters during output.
      Parameters:
      characterReplacementMap - is an XmlOptionCharEscapeMap containing the characters to be escaped.
      See Also:
    • getSaveSubstituteCharacters

      public XmlOptionCharEscapeMap getSaveSubstituteCharacters()
    • setSaveUseOpenFrag

      public XmlOptions setSaveUseOpenFrag()
      When saving a fragment, this option changes the qname of the synthesized root element. Normally <xml-fragment> is used.
      See Also:
    • setSaveUseOpenFrag

      public XmlOptions setSaveUseOpenFrag(boolean b)
    • isSaveUseOpenFrag

      public boolean isSaveUseOpenFrag()
    • setSaveOuter

      public XmlOptions setSaveOuter()
      This option controls whether saving begins on the element or its contents
      See Also:
    • setSaveOuter

      public XmlOptions setSaveOuter(boolean b)
    • isSaveOuter

      public boolean isSaveOuter()
    • setSaveInner

      public XmlOptions setSaveInner()
      This option controls whether saving begins on the element or its contents
      See Also:
    • setSaveInner

      public XmlOptions setSaveInner(boolean b)
    • isSaveInner

      public boolean isSaveInner()
    • setSaveNoXmlDecl

      public XmlOptions setSaveNoXmlDecl()
      This option controls whether saving saves out the XML declaration <?xml ... ?>
      See Also:
    • setSaveNoXmlDecl

      public XmlOptions setSaveNoXmlDecl(boolean b)
    • isSaveNoXmlDecl

      public boolean isSaveNoXmlDecl()
    • setSaveCDataLengthThreshold

      public XmlOptions setSaveCDataLengthThreshold(int cdataLengthThreshold)
      This option controls when saving will use CDATA blocks. CDATA will be used if the folowing condition is true:
      textLength > cdataLengthThreshold && entityCount > cdataEntityCountThreshold
      The default value of cdataLengthThreshold is 32.

      Use the folowing values for these cases:
      Option matrix
      Scenario cdataLengthThreshold cdataEntityCountThreshold
      Every text is CDATA 0 -1
      Only text that has an entity is CDATA 0 0
      Only text longer than x chars is CDATA x -1
      Only text that has y entitazable chars is CDATA 0 y
      Only text longer than x chars and has y entitazable chars is CDATA x y
      See Also:
    • getSaveCDataLengthThreshold

      public Integer getSaveCDataLengthThreshold()
    • setSaveCDataEntityCountThreshold

      public XmlOptions setSaveCDataEntityCountThreshold(int cdataEntityCountThreshold)
      This option controls when saving will use CDATA blocks. CDATA will be used if the folowing condition is true:
      textLength > cdataLengthThreshold && entityCount > cdataEntityCountThreshold
      The default value of cdataEntityCountThreshold is 5.
      See Also:
    • getSaveCDataEntityCountThreshold

      public Integer getSaveCDataEntityCountThreshold()
    • setUseCDataBookmarks

      public XmlOptions setUseCDataBookmarks()

      Use this option when parsing and saving XML documents.

      For parsing this option will annotate the text fields in the store with CDataBookmark.

      For saving this option will save the text fields annotated with CDataBookmark as CDATA XML text.
      Note: The SaveCDataEntityCountThreshold and SaveCDataLengthThreshold options and their default values still apply.

      Note: Due to the store representation, a CDATA will not be recognized if it is imediately after non CDATA text and all text following it will be considered CDATA.
      Example:

      
       <a><![CDATA[cdata text]]></a>               - is considered as: <a><![CDATA[cdata text]]></a>
       <b><![CDATA[cdata text]]> regular text</b>  - is considered as: <b><![CDATA[cdata text regular text]]></b>
       <c>text <![CDATA[cdata text]]></c>          - is considered as: <c>text cdata text</c>
       

      Sample code:

      
       String xmlText = "<a>\n" +
       "<a><![CDATA[cdata text]]></a>\n" +
       "<b><![CDATA[cdata text]]> regular text</b>\n" +
       "<c>text <![CDATA[cdata text]]></c>\n" +
       "</a>";
       System.out.println(xmlText);
      
       XmlOptions opts = new XmlOptions();
       opts.setUseCDataBookmarks();
      
       XmlObject xo = org.apache.xmlbeans.impl.schema.XmlObjectFactory.parse( xmlText , opts);
      
       System.out.println("xo1:\n" + xo.xmlText(opts));
       System.out.println("\n");
      
       opts.setSavePrettyPrint();
       System.out.println("xo2:\n" + xo.xmlText(opts));
       
      See Also:
    • isUseCDataBookmarks

      public boolean isUseCDataBookmarks()
    • setSaveSaxNoNSDeclsInAttributes

      public XmlOptions setSaveSaxNoNSDeclsInAttributes()
      This option controls whether namespace declarations are included as attributes in the startElement event. By default, up to and including XMLBeans 2.3.0 they were included, in subsequent versions, they are no longer included.
    • setSaveSaxNoNSDeclsInAttributes

      public XmlOptions setSaveSaxNoNSDeclsInAttributes(boolean b)
    • isSaveSaxNoNSDeclsInAttributes

      public boolean isSaveSaxNoNSDeclsInAttributes()
    • setLoadReplaceDocumentElement

      public XmlOptions setLoadReplaceDocumentElement(QName replacement)
      If this option is set, the document element is replaced with the given QName when parsing. If null is supplied, the document element is removed.
      See Also:
    • getLoadReplaceDocumentElement

      public QName getLoadReplaceDocumentElement()
    • setLoadStripWhitespace

      public XmlOptions setLoadStripWhitespace()
      If this option is set, all insignificant whitespace is stripped when parsing a document. Can be used to save memory on large documents when you know there is no mixed content.
      See Also:
    • setLoadStripWhitespace

      public XmlOptions setLoadStripWhitespace(boolean b)
    • isSetLoadStripWhitespace

      public boolean isSetLoadStripWhitespace()
    • setLoadStripComments

      public XmlOptions setLoadStripComments()
      If this option is set, all comments are stripped when parsing a document.
      See Also:
    • setLoadStripComments

      public XmlOptions setLoadStripComments(boolean b)
    • isLoadStripComments

      public boolean isLoadStripComments()
    • setLoadStripProcinsts

      public XmlOptions setLoadStripProcinsts()
      If this option is set, all processing instructions are stripped when parsing a document.
      See Also:
    • setLoadStripProcinsts

      public XmlOptions setLoadStripProcinsts(boolean b)
    • isLoadStripProcinsts

      public boolean isLoadStripProcinsts()
    • setLoadLineNumbers

      public XmlOptions setLoadLineNumbers()
      If this option is set, line number annotations are placed in the store when parsing a document. This is particularly useful when you want XmlError objects to contain line numbers.
      Note: This adds line numbers info only for start tags. For line number info on end tags use: setLoadLineNumbersEndElement()
      See Also:
    • setLoadLineNumbers

      public XmlOptions setLoadLineNumbers(boolean b)
    • isLoadLineNumbers

      public boolean isLoadLineNumbers()
    • setLoadLineNumbersEndElement

      public XmlOptions setLoadLineNumbersEndElement()
      If this option is set, line number annotations are placed in the store when parsing a document. This is particularly useful when you want XmlError objects to contain line numbers. Use the option to load line numbers at the end of an element.
    • setLoadLineNumbersEndElement

      public XmlOptions setLoadLineNumbersEndElement(boolean b)
    • isLoadLineNumbersEndElement

      public boolean isLoadLineNumbersEndElement()
    • setLoadSubstituteNamespaces

      public XmlOptions setLoadSubstituteNamespaces(Map<String,String> substNamespaces)
      This option sets a map of namespace uri substitutions that happen when parsing a document.

      This is particularly useful if you have documents that use no namespace, but you wish to avoid the name collision problems that occur when you introduce schema definitions without a target namespace.

      By mapping the empty string "" (the absence of a URI) to a specific namespace, you can force the parser to behave as if a no-namespace document were actually in the specified namespace. This allows you to type the instance according to a schema in a nonempty namespace, and therefore avoid the problematic practice of using schema definitions without a target namespace.

      Parameters:
      substNamespaces - a map of document URIs to replacement URIs
      See Also:
    • getLoadSubstituteNamespaces

      public Map<String,String> getLoadSubstituteNamespaces()
    • setLoadTrimTextBuffer

      public XmlOptions setLoadTrimTextBuffer()
      If this option is set, the underlying xml text buffer is trimmed immediately after parsing a document resulting in a smaller memory footprint. Use this option if you are loading a large number of unchanging documents that will stay in memory for some time.
      See Also:
    • setLoadTrimTextBuffer

      public XmlOptions setLoadTrimTextBuffer(boolean b)
    • isLoadTrimTextBuffer

      public boolean isLoadTrimTextBuffer()
    • setLoadAdditionalNamespaces

      public XmlOptions setLoadAdditionalNamespaces(Map<String,String> nses)
      Set additional namespace mappings to be added when parsing a document.
      Parameters:
      nses - additional namespace mappings
      See Also:
    • getLoadAdditionalNamespaces

      public Map<String,String> getLoadAdditionalNamespaces()
    • setLoadMessageDigest

      public XmlOptions setLoadMessageDigest()
      If this option is set when loading from an InputStream or File, then the loader will compute a 160-bit SHA-1 message digest of the XML file while loading it and make it available via XmlObject.documentProperties().getMessageDigest();
      The schema compiler uses message digests to detect and eliminate duplicate imported xsd files.
      See Also:
    • setLoadMessageDigest

      public XmlOptions setLoadMessageDigest(boolean b)
    • isLoadMessageDigest

      public boolean isLoadMessageDigest()
    • setLoadUseDefaultResolver

      public XmlOptions setLoadUseDefaultResolver()
      By default, XmlBeans does not resolve entities when parsing xml documents (unless an explicit entity resolver is specified). Use this option to turn on entity resolving by default.
      See Also:
    • setLoadUseDefaultResolver

      public XmlOptions setLoadUseDefaultResolver(boolean b)
    • isLoadUseDefaultResolver

      public boolean isLoadUseDefaultResolver()
    • setLoadUseXMLReader

      public XmlOptions setLoadUseXMLReader(XMLReader xmlReader)
      By default, XmlBeans creates a JAXP parser, other parsers can be used by providing an XMLReader. For using the default JDK's SAX parser use: xmlOptions.setLoadUseXMLReader( SAXParserFactory.newInstance().newSAXParser().getXMLReader() );
      See Also:
    • getLoadUseXMLReader

      public XMLReader getLoadUseXMLReader()
    • setXqueryCurrentNodeVar

      public XmlOptions setXqueryCurrentNodeVar(String varName)
      Sets the name of the variable that represents the current node in a query expression.
      Parameters:
      varName - The new variable name to use for the query.
      See Also:
    • getXqueryCurrentNodeVar

      public String getXqueryCurrentNodeVar()
    • setXqueryVariables

      public XmlOptions setXqueryVariables(Map<String,Object> varMap)
      Map the names and values of external variables in an xquery expression. The keys of the map are the variable names in the query without the '$' prefix. The values of the map are objects and can be any of the primitive wrapper classes, String, XmlObject, or XmlCursor. The mapping only applies to xquery and has no effect on xpath expressions.
      Parameters:
      varMap - a map from Strings to variable instances.
      See Also:
    • getXqueryVariables

      public Map<String,Object> getXqueryVariables()
    • setDocumentSourceName

      public XmlOptions setDocumentSourceName(String documentSourceName)
      This option sets the document source name into the xml store when parsing a document. If a document is parsed from a File or URI, it is automatically set to the URI of the source; otherwise, for example, when parsing a String, you can use this option to specify the source name yourself.
      See Also:
    • getDocumentSourceName

      public String getDocumentSourceName()
    • setCompileSubstituteNames

      public XmlOptions setCompileSubstituteNames(Map<QName,QName> nameMap)
      This option allows for QName substitution during schema compilation.
      Parameters:
      nameMap - a map from QNames to substitute QNames.
      See Also:
    • getCompileSubstituteNames

      public Map<QName,QName> getCompileSubstituteNames()
    • setCompileNoValidation

      public XmlOptions setCompileNoValidation()
      If this option is set, validation is not done on the Schema XmlBeans when building a SchemaTypeSystem
      See Also:
    • isCompileNoValidation

      public boolean isCompileNoValidation()
    • setCompileNoUpaRule

      public XmlOptions setCompileNoUpaRule()
      If this option is set, the unique particle attribution rule is not enforced when building a SchemaTypeSystem. See Appendix H of the XML Schema specification for information on the UPA rule.
      See Also:
    • setCompileNoUpaRule

      public XmlOptions setCompileNoUpaRule(boolean b)
    • isCompileNoUpaRule

      public boolean isCompileNoUpaRule()
    • setCompileNoPvrRule

      public XmlOptions setCompileNoPvrRule()
      If this option is set, the particle valid (restriciton) rule is not enforced when building a SchemaTypeSystem. See Section 3.9.6 of the XML Schema specification for information on the PVR rule.
      See Also:
    • setCompileNoPvrRule

      public XmlOptions setCompileNoPvrRule(boolean b)
    • isCompileNoPvrRule

      public boolean isCompileNoPvrRule()
    • setCompileNoAnnotations

      public XmlOptions setCompileNoAnnotations()
      if this option is set, the schema compiler will skip annotations when processing Schema components.
      See Also:
    • setCompileNoAnnotations

      public XmlOptions setCompileNoAnnotations(boolean b)
    • isCompileNoAnnotations

      public boolean isCompileNoAnnotations()
    • setCompileDownloadUrls

      public XmlOptions setCompileDownloadUrls()
      If this option is set, then the schema compiler will try to download schemas that appear in imports and includes from network based URLs.
      See Also:
    • setCompileDownloadUrls

      public XmlOptions setCompileDownloadUrls(boolean b)
    • isCompileDownloadUrls

      public boolean isCompileDownloadUrls()
    • setCompileMdefNamespaces

      public XmlOptions setCompileMdefNamespaces(Set<String> mdefNamespaces)
      If this option is set, then the schema compiler will permit and ignore multiple definitions of the same component (element, attribute, type, etc) names in the given namespaces. If multiple definitions with the same name appear, the definitions that happen to be processed last will be ignored.
      Parameters:
      mdefNamespaces - a set of namespace URIs as Strings
      See Also:
    • getCompileMdefNamespaces

      public Set<String> getCompileMdefNamespaces()
    • setCompilePartialTypesystem

      public XmlOptions setCompilePartialTypesystem()
    • setCompilePartialTypesystem

      public XmlOptions setCompilePartialTypesystem(boolean compilePartialTypesystem)
    • isCompilePartialTypesystem

      public boolean isCompilePartialTypesystem()
    • setValidateOnSet

      public XmlOptions setValidateOnSet()
      If this option is set when an instance is created, then value facets will be checked on each call to a setter or getter method on instances of XmlObject within the instance document. If the facets are not satisfied, then an unchecked exception is thrown immediately. This option is useful for finding code that is introducing invalid values in an XML document, but it slows performance.
      See Also:
    • setValidateOnSet

      public XmlOptions setValidateOnSet(boolean b)
    • isValidateOnSet

      public boolean isValidateOnSet()
    • setValidateTreatLaxAsSkip

      public XmlOptions setValidateTreatLaxAsSkip()
      Instructs the validator to skip elements matching an <any> particle with contentModel="lax". This is useful because, in certain situations, XmlBeans will find types on the classpath that the document author did not anticipate.
    • setValidateTreatLaxAsSkip

      public XmlOptions setValidateTreatLaxAsSkip(boolean b)
    • isValidateTreatLaxAsSkip

      public boolean isValidateTreatLaxAsSkip()
    • setValidateStrict

      public XmlOptions setValidateStrict()
      Performs additional validation checks that are disabled by default for better compatibility.
    • setValidateStrict

      public XmlOptions setValidateStrict(boolean b)
    • isValidateStrict

      public boolean isValidateStrict()
    • setValidateTextOnly

      public XmlOptions setValidateTextOnly()
    • setValidateTextOnly

      public XmlOptions setValidateTextOnly(boolean b)
    • isValidateTextOnly

      public boolean isValidateTextOnly()
    • setUnsynchronized

      public XmlOptions setUnsynchronized()
      This option controls whether or not operations on XmlBeans are thread safe. When not on, all XmlBean operations will be synchronized. This provides for multiple thread the ability to access a single XmlBeans simultaneously, but has a perf impact. If set, then only one thread may access an XmlBean.
    • setUnsynchronized

      public XmlOptions setUnsynchronized(boolean b)
    • isUnsynchronized

      public boolean isUnsynchronized()
    • setEntityResolver

      public XmlOptions setEntityResolver(EntityResolver resolver)
      If this option is set when compiling a schema, then the given EntityResolver will be consulted in order to resolve any URIs while downloading imported schemas.

      EntityResolvers are currently only used by compileXsd; they are not consulted by other functions, for example, parse. This will likely change in the future.

      See Also:
    • getEntityResolver

      public EntityResolver getEntityResolver()
    • setBaseURI

      public XmlOptions setBaseURI(URI baseURI)
      If this option is set when compiling a schema, then the given URI will be considered as base URI when deciding the directory structure for saving the sources inside the generated JAR file.
      Parameters:
      baseURI - the URI to be considered as "base"
      See Also:
    • getBaseURI

      public URI getBaseURI()
    • setSchemaCodePrinter

      public XmlOptions setSchemaCodePrinter(SchemaCodePrinter printer)
      If this option is set when compiling a schema, then the given SchemaTypeCodePrinter.Printer will be used to generate the Java code.
      See Also:
    • getSchemaCodePrinter

      public SchemaCodePrinter getSchemaCodePrinter()
    • setCopyUseNewSynchronizationDomain

      public XmlOptions setCopyUseNewSynchronizationDomain(boolean useNewSyncDomain)
      If this option is set to true, the return of XmlObject.copy() method will return an object in it's own synchronization domain, otherwise both objects will share the same synchronization domain, requiring explicit synchronization when concurent accessing the two objects.
      Parameters:
      useNewSyncDomain - A flag representing the usage of new domain
      See Also:
    • isCopyUseNewSynchronizationDomain

      public boolean isCopyUseNewSynchronizationDomain()
    • setUseSameLocale

      public XmlOptions setUseSameLocale(Object localeOrXmlTokenSource)
    • getUseSameLocale

      public Object getUseSameLocale()
    • setLoadEntityBytesLimit

      public XmlOptions setLoadEntityBytesLimit(int entityBytesLimit)
      Sets the maximum number of bytes allowed when an Entity is expanded during parsing. The default value is 10240 bytes.
      Parameters:
      entityBytesLimit - the maximum number of bytes allowed when an Entity is expanded during parsing
      Returns:
      this
    • getLoadEntityBytesLimit

      public Integer getLoadEntityBytesLimit()
    • setEntityExpansionLimit

      public XmlOptions setEntityExpansionLimit(int entityExpansionLimit)
      Sets the maximum number of entity expansions allowed during parsing. The default value is 2048.
      Parameters:
      entityExpansionLimit - the maximum number of entity expansions allowed during parsing
      Returns:
      this
    • getEntityExpansionLimit

      public int getEntityExpansionLimit()
    • setLoadDTDGrammar

      public XmlOptions setLoadDTDGrammar(boolean loadDTDGrammar)
      Controls whether DTD grammar is loaded during parsing. The default value is false.
      Parameters:
      loadDTDGrammar - true, if DTD grammar is loaded during parsing
      Returns:
      this
    • isLoadDTDGrammar

      public boolean isLoadDTDGrammar()
    • setLoadExternalDTD

      public XmlOptions setLoadExternalDTD(boolean loadExternalDTD)
      Controls whether external DTDs are loaded during parsing. The default value is false.
      Parameters:
      loadExternalDTD - true, if external DTDs are loaded during parsing
      Returns:
      this
    • isLoadExternalDTD

      public boolean isLoadExternalDTD()
    • setDisallowDocTypeDeclaration

      public XmlOptions setDisallowDocTypeDeclaration(boolean disallowDocTypeDeclaration)
      Controls whether DocType declarations are disallowed during XML parsing. If they are disallowed, the parser will throw an exception if a DocType declaration is encountered. The default value is false.
      Parameters:
      disallowDocTypeDeclaration - true, if DocType declarations are to be disallowed
      Returns:
      this
      Since:
      5.0.2
    • disallowDocTypeDeclaration

      public boolean disallowDocTypeDeclaration()
      Returns whether DocType declarations are disallowed during XML parsing. If they are disallowed, the parser will throw an exception if a DocType declaration is encountered. The default value is false.
      Returns:
      boolean
      Since:
      5.0.2
    • setSaveOptimizeForSpeed

      public XmlOptions setSaveOptimizeForSpeed(boolean saveOptimizeForSpeed)
    • isSaveOptimizeForSpeed

      public boolean isSaveOptimizeForSpeed()
    • setSaaj

      public XmlOptions setSaaj(Saaj saaj)
    • getSaaj

      public Saaj getSaaj()
    • setLoadUseLocaleCharUtil

      public XmlOptions setLoadUseLocaleCharUtil(boolean useCharUtil)
    • isLoadUseLocaleCharUtil

      public boolean isLoadUseLocaleCharUtil()
    • setXPathUseSaxon

      public XmlOptions setXPathUseSaxon()
    • setXPathUseSaxon

      public XmlOptions setXPathUseSaxon(boolean xpathUseSaxon)
    • isXPathUseSaxon

      public boolean isXPathUseSaxon()
    • setXPathUseXmlBeans

      public XmlOptions setXPathUseXmlBeans()
    • setXPathUseXmlBeans

      public XmlOptions setXPathUseXmlBeans(boolean xpathUseXmlBeans)
    • isXPathUseXmlBeans

      public boolean isXPathUseXmlBeans()
    • setCompileAnnotationAsJavadoc

      public XmlOptions setCompileAnnotationAsJavadoc()
    • setCompileAnnotationAsJavadoc

      public XmlOptions setCompileAnnotationAsJavadoc(boolean useAnnotationAsJavadoc)
      When generating the schema sources, copy over the schema annotations to the javadoc. Be aware basic code injection is filtered, but annotation based RCE aren't filtered. So think twice before activating this on untrusted schemas!
      Parameters:
      useAnnotationAsJavadoc - true = copy the annotation - defaults to false
    • isCompileAnnotationAsJavadoc

      public boolean isCompileAnnotationAsJavadoc()
    • setAttributeValidationCompatMode

      public XmlOptions setAttributeValidationCompatMode(boolean attributeValidationCompatMode)
    • isAttributeValidationCompatMode

      public boolean isAttributeValidationCompatMode()
    • getCompilePartialMethod

      public Set<XmlOptions.BeanMethod> getCompilePartialMethod()
      Returns:
      the list of methods to be generated in the XmlBean or null for all
    • setCompilePartialMethod

      public void setCompilePartialMethod(Set<XmlOptions.BeanMethod> list)
    • maskNull

      public static XmlOptions maskNull(XmlOptions o)
      If passed null, returns an empty options object. Otherwise, returns its argument.
    • hasOption

      public boolean hasOption(XmlOptions.XmlOptionsKeys option)
      Used to test a generic option
    • get

      public Object get(XmlOptions.XmlOptionsKeys option)
      Used to get a generic option
    • remove

      public void remove(XmlOptions.XmlOptionsKeys option)