Class XmlOptions
- All Implemented Interfaces:
Serializable
public class XmlOptions extends Object implements Serializable
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 forparse
methods - options used for
validate
methods are also used forcompile
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
setValidateStrict |
setErrorListener setCompile*** setEntityResolver setBaseURI setGenerateJavaVersion |
setSave*** setUseDefaultNamespace setCharacterEncoding |
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
XmlOptions.BeanMethod
static class
XmlOptions.XmlOptionsKeys
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_ENTITY_EXPANSION_LIMIT
-
Constructor Summary
Constructors Constructor Description XmlOptions()
Construct a new blank XmlOptions.XmlOptions(XmlOptions other)
Construct a new XmlOptions, copying the options. -
Method Summary
Modifier and Type Method Description Object
get(XmlOptions.XmlOptionsKeys option)
Used to get a generic optionURI
getBaseURI()
String
getCharacterEncoding()
Set<String>
getCompileMdefNamespaces()
Set<XmlOptions.BeanMethod>
getCompilePartialMethod()
Map<QName,QName>
getCompileSubstituteNames()
String
getDocumentSourceName()
SchemaType
getDocumentType()
int
getEntityExpansionLimit()
EntityResolver
getEntityResolver()
Collection<XmlError>
getErrorListener()
Map<String,String>
getLoadAdditionalNamespaces()
Integer
getLoadEntityBytesLimit()
QName
getLoadReplaceDocumentElement()
Map<String,String>
getLoadSubstituteNamespaces()
XMLReader
getLoadUseXMLReader()
Saaj
getSaaj()
Integer
getSaveCDataEntityCountThreshold()
Integer
getSaveCDataLengthThreshold()
String
getSaveFilterProcinst()
Map<String,String>
getSaveImplicitNamespaces()
Integer
getSavePrettyPrintIndent()
Integer
getSavePrettyPrintOffset()
XmlOptionCharEscapeMap
getSaveSubstituteCharacters()
Map<String,String>
getSaveSuggestedPrefixes()
QName
getSaveSyntheticDocumentElement()
SchemaCodePrinter
getSchemaCodePrinter()
Object
getUseSameLocale()
String
getXqueryCurrentNodeVar()
Map<String,Object>
getXqueryVariables()
boolean
hasOption(XmlOptions.XmlOptionsKeys option)
Used to test a generic optionboolean
isAttributeValidationCompatMode()
boolean
isCompileAnnotationAsJavadoc()
boolean
isCompileDownloadUrls()
boolean
isCompileNoAnnotations()
boolean
isCompileNoPvrRule()
boolean
isCompileNoUpaRule()
boolean
isCompileNoValidation()
boolean
isCompilePartialTypesystem()
boolean
isCopyUseNewSynchronizationDomain()
boolean
isLoadDTDGrammar()
boolean
isLoadExternalDTD()
boolean
isLoadLineNumbers()
boolean
isLoadLineNumbersEndElement()
boolean
isLoadMessageDigest()
boolean
isLoadStripComments()
boolean
isLoadStripProcinsts()
boolean
isLoadTrimTextBuffer()
boolean
isLoadUseDefaultResolver()
boolean
isLoadUseLocaleCharUtil()
boolean
isSaveAggressiveNamespaces()
boolean
isSaveInner()
boolean
isSaveNamespacesFirst()
boolean
isSaveNoXmlDecl()
boolean
isSaveOptimizeForSpeed()
boolean
isSaveOuter()
boolean
isSavePrettyPrint()
boolean
isSaveSaxNoNSDeclsInAttributes()
boolean
isSaveUseOpenFrag()
boolean
isSetLoadStripWhitespace()
boolean
isUnsynchronized()
boolean
isUseCDataBookmarks()
boolean
isUseDefaultNamespace()
boolean
isValidateOnSet()
boolean
isValidateStrict()
boolean
isValidateTextOnly()
boolean
isValidateTreatLaxAsSkip()
boolean
isXPathUseSaxon()
boolean
isXPathUseXmlBeans()
static XmlOptions
maskNull(XmlOptions o)
If passed null, returns an empty options object.void
remove(XmlOptions.XmlOptionsKeys option)
XmlOptions
setAttributeValidationCompatMode(boolean attributeValidationCompatMode)
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.XmlOptions
setCharacterEncoding(String encoding)
When writing a document, this sets the character encoding to use.XmlOptions
setCompileAnnotationAsJavadoc()
XmlOptions
setCompileAnnotationAsJavadoc(boolean useAnnotationAsJavadoc)
When generating the schema sources, copy over the schema annotations to the javadoc.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.XmlOptions
setCompileDownloadUrls(boolean b)
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.XmlOptions
setCompileNoAnnotations()
if this option is set, the schema compiler will skip annotations when processing Schema components.XmlOptions
setCompileNoAnnotations(boolean b)
XmlOptions
setCompileNoPvrRule()
If this option is set, the particle valid (restriciton) rule is not enforced when building aSchemaTypeSystem
.XmlOptions
setCompileNoPvrRule(boolean b)
XmlOptions
setCompileNoUpaRule()
If this option is set, the unique particle attribution rule is not enforced when building aSchemaTypeSystem
.XmlOptions
setCompileNoUpaRule(boolean b)
XmlOptions
setCompileNoValidation()
If this option is set, validation is not done on the Schema XmlBeans when building aSchemaTypeSystem
void
setCompilePartialMethod(Set<XmlOptions.BeanMethod> list)
XmlOptions
setCompilePartialTypesystem()
XmlOptions
setCompilePartialTypesystem(boolean compilePartialTypesystem)
XmlOptions
setCompileSubstituteNames(Map<QName,QName> nameMap)
This option allows forQName
substitution during schema compilation.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.XmlOptions
setDocumentSourceName(String documentSourceName)
This option sets the document source name into the xml store when parsing a document.XmlOptions
setDocumentType(SchemaType type)
When parsing a document, this sets the type of the root element.XmlOptions
setEntityExpansionLimit(int entityExpansionLimit)
Sets the maximum number of entity expansions allowed during parsing.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.XmlOptions
setErrorListener(Collection<XmlError> c)
Sets a collection object for collectingXmlError
objects during parsing, validation, and compilation.XmlOptions
setLoadAdditionalNamespaces(Map<String,String> nses)
Set additional namespace mappings to be added when parsing a document.XmlOptions
setLoadDTDGrammar(boolean loadDTDGrammar)
Controls whether DTD grammar is loaded during parsing.XmlOptions
setLoadEntityBytesLimit(int entityBytesLimit)
Sets the maximum number of bytes allowed when an Entity is expanded during parsing.XmlOptions
setLoadExternalDTD(boolean loadExternalDTD)
Controls whether external DTDs are loaded during parsing.XmlOptions
setLoadLineNumbers()
If this option is set, line number annotations are placed in the store when parsing a document.XmlOptions
setLoadLineNumbers(boolean b)
XmlOptions
setLoadLineNumbersEndElement()
If this option is set, line number annotations are placed in the store when parsing a document.XmlOptions
setLoadLineNumbersEndElement(boolean b)
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.XmlOptions
setLoadMessageDigest(boolean b)
XmlOptions
setLoadReplaceDocumentElement(QName replacement)
If this option is set, the document element is replaced with the given QName when parsing.XmlOptions
setLoadStripComments()
If this option is set, all comments are stripped when parsing a document.XmlOptions
setLoadStripComments(boolean b)
XmlOptions
setLoadStripProcinsts()
If this option is set, all processing instructions are stripped when parsing a document.XmlOptions
setLoadStripProcinsts(boolean b)
XmlOptions
setLoadStripWhitespace()
If this option is set, all insignificant whitespace is stripped when parsing a document.XmlOptions
setLoadStripWhitespace(boolean b)
XmlOptions
setLoadSubstituteNamespaces(Map<String,String> substNamespaces)
This option sets a map of namespace uri substitutions that happen when parsing a document.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.XmlOptions
setLoadTrimTextBuffer(boolean b)
XmlOptions
setLoadUseDefaultResolver()
By default, XmlBeans does not resolve entities when parsing xml documents (unless an explicit entity resolver is specified).XmlOptions
setLoadUseDefaultResolver(boolean b)
XmlOptions
setLoadUseLocaleCharUtil(boolean useCharUtil)
XmlOptions
setLoadUseXMLReader(XMLReader xmlReader)
By default, XmlBeans creates a JAXP parser, other parsers can be used by providing an XMLReader.XmlOptions
setSaaj(Saaj saaj)
XmlOptions
setSaveAggressiveNamespaces()
Causes the saver to reduce the number of namespace prefix declarations.XmlOptions
setSaveAggressiveNamespaces(boolean b)
XmlOptions
setSaveCDataEntityCountThreshold(int cdataEntityCountThreshold)
This option controls when saving will use CDATA blocks.XmlOptions
setSaveCDataLengthThreshold(int cdataLengthThreshold)
This option controls when saving will use CDATA blocks.XmlOptions
setSaveFilterProcinst(String filterProcinst)
This option causes the saver to filter a Processing Instruction with the given targetXmlOptions
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.XmlOptions
setSaveInner()
This option controls whether saving begins on the element or its contentsXmlOptions
setSaveInner(boolean b)
XmlOptions
setSaveNamespacesFirst()
This option will cause the saver to save namespace attributes first.XmlOptions
setSaveNamespacesFirst(boolean b)
XmlOptions
setSaveNoXmlDecl()
This option controls whether saving saves out the XML declaration (XmlOptions
setSaveNoXmlDecl(boolean b)
XmlOptions
setSaveOptimizeForSpeed(boolean saveOptimizeForSpeed)
XmlOptions
setSaveOuter()
This option controls whether saving begins on the element or its contentsXmlOptions
setSaveOuter(boolean b)
XmlOptions
setSavePrettyPrint()
This option will cause the saver to reformat white space for easier reading.XmlOptions
setSavePrettyPrint(boolean b)
XmlOptions
setSavePrettyPrintIndent(int indent)
When used withsetSavePrettyPrint
this sets the indent amount to use.XmlOptions
setSavePrettyPrintOffset(int offset)
When used withsetSavePrettyPrint
this sets the offset amount to use.XmlOptions
setSaveSaxNoNSDeclsInAttributes()
This option controls whether namespace declarations are included as attributes in the startElement event.XmlOptions
setSaveSaxNoNSDeclsInAttributes(boolean b)
XmlOptions
setSaveSubstituteCharacters(XmlOptionCharEscapeMap characterReplacementMap)
This option causes the saver to replace characters with other values in the output stream.XmlOptions
setSaveSuggestedPrefixes(Map<String,String> suggestedPrefixes)
A map of hints to pass to the saver for which prefixes to use for which namespace URI.XmlOptions
setSaveSyntheticDocumentElement(QName name)
This option causes the saver to wrap the current fragment in an element with the given name.XmlOptions
setSaveUseOpenFrag()
When saving a fragment, this option changes the qname of the synthesized root element.XmlOptions
setSaveUseOpenFrag(boolean b)
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.XmlOptions
setUnsynchronized()
This option controls whether or not operations on XmlBeans are thread safe.XmlOptions
setUnsynchronized(boolean b)
XmlOptions
setUseCDataBookmarks()
Use this option when parsing and saving XML documents.XmlOptions
setUseDefaultNamespace()
If this option is set, the saver will try to use the default namespace for the most commonly used URI.XmlOptions
setUseDefaultNamespace(boolean b)
XmlOptions
setUseSameLocale(Object localeOrXmlTokenSource)
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.XmlOptions
setValidateOnSet(boolean b)
XmlOptions
setValidateStrict()
Performs additional validation checks that are disabled by default for better compatibility.XmlOptions
setValidateStrict(boolean b)
XmlOptions
setValidateTextOnly()
XmlOptions
setValidateTextOnly(boolean b)
XmlOptions
setValidateTreatLaxAsSkip()
Instructs the validator to skip elements matching anparticle with contentModel="lax". XmlOptions
setValidateTreatLaxAsSkip(boolean b)
XmlOptions
setXPathUseSaxon()
XmlOptions
setXPathUseSaxon(boolean xpathUseSaxon)
XmlOptions
setXPathUseXmlBeans()
XmlOptions
setXPathUseXmlBeans(boolean xpathUseXmlBeans)
XmlOptions
setXqueryCurrentNodeVar(String varName)
Sets the name of the variable that represents the current node in a query expression.XmlOptions
setXqueryVariables(Map<String,Object> varMap)
Map the names and values of external variables in an xquery expression.
-
Field Details
-
DEFAULT_ENTITY_EXPANSION_LIMIT
public static final int DEFAULT_ENTITY_EXPANSION_LIMIT- See Also:
- Constant Field Values
-
-
Constructor Details
-
XmlOptions
public XmlOptions()Construct a new blank XmlOptions. -
XmlOptions
Construct a new XmlOptions, copying the options.
-
-
Method Details
-
setSaveNamespacesFirst
This option will cause the saver to save namespace attributes first. -
setSaveNamespacesFirst
-
isSaveNamespacesFirst
public boolean isSaveNamespacesFirst() -
setSavePrettyPrint
This option will cause the saver to reformat white space for easier reading. -
setSavePrettyPrint
-
isSavePrettyPrint
public boolean isSavePrettyPrint() -
setSavePrettyPrintIndent
When used withsetSavePrettyPrint
this sets the indent amount to use.- Parameters:
indent
- the indent amount to use- See Also:
setSavePrettyPrint()
,XmlTokenSource.save(java.io.File, XmlOptions)
,XmlTokenSource.xmlText(XmlOptions)
-
getSavePrettyPrintIndent
-
setSavePrettyPrintOffset
When used withsetSavePrettyPrint
this sets the offset amount to use.- Parameters:
offset
- the offset amount to use- See Also:
setSavePrettyPrint()
,XmlTokenSource.save(java.io.File, XmlOptions)
,XmlTokenSource.xmlText(XmlOptions)
-
getSavePrettyPrintOffset
-
setCharacterEncoding
When writing a document, this sets the character encoding to use.- Parameters:
encoding
- the character encoding- See Also:
XmlObject.Factory#parse(java.io.File, XmlOptions)
,XmlTokenSource.save(java.io.File, XmlOptions)
-
getCharacterEncoding
-
setDocumentType
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'sQName
.- Parameters:
type
- The root element's document type.- See Also:
XmlObject.Factory#parse(java.io.File, XmlOptions)
-
getDocumentType
-
setErrorListener
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 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 withXmlError
objects viaCollection.add(E)
- See Also:
XmlError
,XmlObject.Factory#parse(java.io.File, XmlOptions)
,XmlObject.validate(XmlOptions)
,XmlBeans.compileXsd(org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.SchemaTypeLoader, org.apache.xmlbeans.XmlOptions)
,setLoadLineNumbers()
-
getErrorListener
-
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. -
setSaveAggressiveNamespaces
-
isSaveAggressiveNamespaces
public boolean isSaveAggressiveNamespaces() -
setSaveSyntheticDocumentElement
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:
XmlTokenSource.save(java.io.File, XmlOptions)
,XmlTokenSource.xmlText(XmlOptions)
-
getSaveSyntheticDocumentElement
-
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. -
setUseDefaultNamespace
-
isUseDefaultNamespace
public boolean isUseDefaultNamespace() -
setSaveImplicitNamespaces
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:
XmlTokenSource.save(java.io.File, XmlOptions)
,XmlTokenSource.xmlText(XmlOptions)
-
getSaveImplicitNamespaces
-
setSaveSuggestedPrefixes
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:
XmlTokenSource.save(java.io.File, XmlOptions)
,XmlTokenSource.xmlText(XmlOptions)
-
getSaveSuggestedPrefixes
-
setSaveFilterProcinst
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:
XmlTokenSource.save(java.io.File, XmlOptions)
,XmlTokenSource.xmlText(XmlOptions)
-
getSaveFilterProcinst
-
setSaveSubstituteCharacters
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:
XmlTokenSource.save(java.io.File, XmlOptions)
,XmlTokenSource.xmlText(XmlOptions)
,XmlOptionCharEscapeMap
-
getSaveSubstituteCharacters
-
setSaveUseOpenFrag
When saving a fragment, this option changes the qname of the synthesized root element. Normally <xml-fragment> is used. -
setSaveUseOpenFrag
-
isSaveUseOpenFrag
public boolean isSaveUseOpenFrag() -
setSaveOuter
This option controls whether saving begins on the element or its contents -
setSaveOuter
-
isSaveOuter
public boolean isSaveOuter() -
setSaveInner
This option controls whether saving begins on the element or its contents -
setSaveInner
-
isSaveInner
public boolean isSaveInner() -
setSaveNoXmlDecl
This option controls whether saving saves out the XML declaration ( -
setSaveNoXmlDecl
-
isSaveNoXmlDecl
public boolean isSaveNoXmlDecl() -
setSaveCDataLengthThreshold
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: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:
setSaveCDataEntityCountThreshold(int)
-
getSaveCDataLengthThreshold
-
setSaveCDataEntityCountThreshold
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:
setSaveCDataLengthThreshold(int)
-
getSaveCDataEntityCountThreshold
-
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 = XmlObject.Factory.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:
CDataBookmark
,CDataBookmark.CDATA_BOOKMARK
-
isUseCDataBookmarks
public boolean isUseCDataBookmarks() -
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
-
isSaveSaxNoNSDeclsInAttributes
public boolean isSaveSaxNoNSDeclsInAttributes() -
setLoadReplaceDocumentElement
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:
XmlObject.Factory#parse(java.io.File, XmlOptions)
-
getLoadReplaceDocumentElement
-
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:
XmlObject.Factory#parse(java.io.File, XmlOptions)
-
setLoadStripWhitespace
-
isSetLoadStripWhitespace
public boolean isSetLoadStripWhitespace() -
setLoadStripComments
If this option is set, all comments are stripped when parsing a document.- See Also:
XmlObject.Factory#parse(java.io.File, XmlOptions)
-
setLoadStripComments
-
isLoadStripComments
public boolean isLoadStripComments() -
setLoadStripProcinsts
If this option is set, all processing instructions are stripped when parsing a document.- See Also:
XmlObject.Factory#parse(java.io.File, XmlOptions)
-
setLoadStripProcinsts
-
isLoadStripProcinsts
public boolean isLoadStripProcinsts() -
setLoadLineNumbers
If this option is set, line number annotations are placed in the store when parsing a document. This is particularly useful when you wantXmlError
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:
XmlObject.Factory#parse(java.io.File, XmlOptions)
,XmlError
-
setLoadLineNumbers
-
isLoadLineNumbers
public boolean isLoadLineNumbers() -
setLoadLineNumbersEndElement
If this option is set, line number annotations are placed in the store when parsing a document. This is particularly useful when you wantXmlError
objects to contain line numbers. Use the option to load line numbers at the end of an element. -
setLoadLineNumbersEndElement
-
isLoadLineNumbersEndElement
public boolean isLoadLineNumbersEndElement() -
setLoadSubstituteNamespaces
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:
XmlObject.Factory#parse(java.io.File, XmlOptions)
-
getLoadSubstituteNamespaces
-
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:
XmlObject.Factory#parse(java.io.File, XmlOptions)
-
setLoadTrimTextBuffer
-
isLoadTrimTextBuffer
public boolean isLoadTrimTextBuffer() -
setLoadAdditionalNamespaces
Set additional namespace mappings to be added when parsing a document.- Parameters:
nses
- additional namespace mappings- See Also:
XmlObject.Factory#parse(java.io.File, XmlOptions)
-
getLoadAdditionalNamespaces
-
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:
XmlObject.Factory#parse(java.io.File, XmlOptions)
-
setLoadMessageDigest
-
isLoadMessageDigest
public boolean isLoadMessageDigest() -
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:
XmlObject.Factory#parse(java.io.File, XmlOptions)
-
setLoadUseDefaultResolver
-
isLoadUseDefaultResolver
public boolean isLoadUseDefaultResolver() -
setLoadUseXMLReader
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:
XmlObject.Factory#parse(java.io.File, XmlOptions)
-
getLoadUseXMLReader
-
setXqueryCurrentNodeVar
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:
XmlObject.execQuery(java.lang.String)
,XmlCursor.execQuery(java.lang.String)
-
getXqueryCurrentNodeVar
-
setXqueryVariables
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:
XmlObject.execQuery(java.lang.String)
,XmlCursor.execQuery(java.lang.String)
-
getXqueryVariables
-
setDocumentSourceName
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:
XmlObject.Factory#parse(java.lang.String, XmlOptions)
-
getDocumentSourceName
-
setCompileSubstituteNames
This option allows forQName
substitution during schema compilation.- Parameters:
nameMap
- a map fromQName
s to substituteQName
s.- See Also:
XmlBeans.compileXsd(org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.SchemaTypeLoader, org.apache.xmlbeans.XmlOptions)
-
getCompileSubstituteNames
-
setCompileNoValidation
If this option is set, validation is not done on the Schema XmlBeans when building aSchemaTypeSystem
-
isCompileNoValidation
public boolean isCompileNoValidation() -
setCompileNoUpaRule
If this option is set, the unique particle attribution rule is not enforced when building aSchemaTypeSystem
. See Appendix H of the XML Schema specification for information on the UPA rule. -
setCompileNoUpaRule
-
isCompileNoUpaRule
public boolean isCompileNoUpaRule() -
setCompileNoPvrRule
If this option is set, the particle valid (restriciton) rule is not enforced when building aSchemaTypeSystem
. See Section 3.9.6 of the XML Schema specification for information on the PVR rule. -
setCompileNoPvrRule
-
isCompileNoPvrRule
public boolean isCompileNoPvrRule() -
setCompileNoAnnotations
if this option is set, the schema compiler will skip annotations when processing Schema components. -
setCompileNoAnnotations
-
isCompileNoAnnotations
public boolean isCompileNoAnnotations() -
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. -
setCompileDownloadUrls
-
isCompileDownloadUrls
public boolean isCompileDownloadUrls() -
setCompileMdefNamespaces
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:
XmlBeans.compileXsd(org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.SchemaTypeLoader, org.apache.xmlbeans.XmlOptions)
-
getCompileMdefNamespaces
-
setCompilePartialTypesystem
-
setCompilePartialTypesystem
-
isCompilePartialTypesystem
public boolean isCompilePartialTypesystem() -
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:
XmlObject.Factory#parse(java.io.File, XmlOptions)
-
setValidateOnSet
-
isValidateOnSet
public boolean isValidateOnSet() -
setValidateTreatLaxAsSkip
Instructs the validator to skip elements matching anparticle 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
-
isValidateTreatLaxAsSkip
public boolean isValidateTreatLaxAsSkip() -
setValidateStrict
Performs additional validation checks that are disabled by default for better compatibility. -
setValidateStrict
-
isValidateStrict
public boolean isValidateStrict() -
setValidateTextOnly
-
setValidateTextOnly
-
isValidateTextOnly
public boolean isValidateTextOnly() -
setUnsynchronized
This option controls whether or not operations on XmlBeans are thread safe. When not on, all XmlBean operations will be syncronized. This provides for multiple thread the ability to access a single XmlBeans simultainously, but has a perf impact. If set, then only one thread may access an XmlBean. -
setUnsynchronized
-
isUnsynchronized
public boolean isUnsynchronized() -
setEntityResolver
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.
-
getEntityResolver
-
setBaseURI
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:
XmlBeans.compileXsd(org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.SchemaTypeLoader, org.apache.xmlbeans.XmlOptions)
-
getBaseURI
-
setSchemaCodePrinter
If this option is set when compiling a schema, then the given SchemaTypeCodePrinter.Printer will be used to generate the Java code. -
getSchemaCodePrinter
-
setCopyUseNewSynchronizationDomain
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:
XmlObject.copy()
-
isCopyUseNewSynchronizationDomain
public boolean isCopyUseNewSynchronizationDomain() -
setUseSameLocale
-
getUseSameLocale
-
setLoadEntityBytesLimit
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
-
setEntityExpansionLimit
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
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
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() -
setSaveOptimizeForSpeed
-
isSaveOptimizeForSpeed
public boolean isSaveOptimizeForSpeed() -
setSaaj
-
getSaaj
-
setLoadUseLocaleCharUtil
-
isLoadUseLocaleCharUtil
public boolean isLoadUseLocaleCharUtil() -
setXPathUseSaxon
-
setXPathUseSaxon
-
isXPathUseSaxon
public boolean isXPathUseSaxon() -
setXPathUseXmlBeans
-
setXPathUseXmlBeans
-
isXPathUseXmlBeans
public boolean isXPathUseXmlBeans() -
setCompileAnnotationAsJavadoc
-
setCompileAnnotationAsJavadoc
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 tofalse
-
isCompileAnnotationAsJavadoc
public boolean isCompileAnnotationAsJavadoc() -
setAttributeValidationCompatMode
-
isAttributeValidationCompatMode
public boolean isAttributeValidationCompatMode() -
getCompilePartialMethod
- Returns:
- the list of methods to be generated in the XmlBean or
null
for all
-
setCompilePartialMethod
-
maskNull
If passed null, returns an empty options object. Otherwise, returns its argument. -
hasOption
Used to test a generic option -
get
Used to get a generic option -
remove
-