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:
newInstance
methods will also
apply for parse
methodsvalidate
methods are also used for
compile
methods, since compilation usually implies
validation against Schema for SchemasnewInstance 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 |
Modifier and Type | Class and Description |
---|---|
static class |
XmlOptions.XmlOptionsKeys |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_ENTITY_EXPANSION_LIMIT |
Constructor and Description |
---|
XmlOptions()
Construct a new blank XmlOptions.
|
XmlOptions(XmlOptions other)
Construct a new XmlOptions, copying the options.
|
Modifier and Type | Method and Description |
---|---|
Object |
get(XmlOptions.XmlOptionsKeys option)
Used to get a generic option
|
URI |
getBaseURI() |
String |
getCharacterEncoding() |
Set<String> |
getCompileMdefNamespaces() |
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 option
|
boolean |
isAttributeValidationCompatMode() |
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 |
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 a
SchemaTypeSystem . |
XmlOptions |
setCompileNoPvrRule(boolean b) |
XmlOptions |
setCompileNoUpaRule()
If this option is set, the unique particle attribution rule is not
enforced when building a
SchemaTypeSystem . |
XmlOptions |
setCompileNoUpaRule(boolean b) |
XmlOptions |
setCompileNoValidation()
If this option is set, validation is not done on the Schema XmlBeans
when building a
SchemaTypeSystem |
XmlOptions |
setCompilePartialTypesystem() |
XmlOptions |
setCompilePartialTypesystem(boolean compilePartialTypesystem) |
XmlOptions |
setCompileSubstituteNames(Map<QName,QName> nameMap)
This option allows for
QName 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 collecting
XmlError 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 target
|
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.
|
XmlOptions |
setSaveInner()
This option controls whether saving begins on the element or its contents
|
XmlOptions |
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 contents
|
XmlOptions |
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 with
setSavePrettyPrint this sets the indent
amount to use. |
XmlOptions |
setSavePrettyPrintOffset(int offset)
When used with
setSavePrettyPrint 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 an
|
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.
|
public static final int DEFAULT_ENTITY_EXPANSION_LIMIT
public XmlOptions()
public XmlOptions(XmlOptions other)
public XmlOptions setSaveNamespacesFirst()
public XmlOptions setSaveNamespacesFirst(boolean b)
public boolean isSaveNamespacesFirst()
public XmlOptions setSavePrettyPrint()
public XmlOptions setSavePrettyPrint(boolean b)
public boolean isSavePrettyPrint()
public XmlOptions setSavePrettyPrintIndent(int indent)
setSavePrettyPrint
this sets the indent
amount to use.indent
- the indent amount to usesetSavePrettyPrint()
,
XmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
public Integer getSavePrettyPrintIndent()
public XmlOptions setSavePrettyPrintOffset(int offset)
setSavePrettyPrint
this sets the offset
amount to use.offset
- the offset amount to usesetSavePrettyPrint()
,
XmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
public Integer getSavePrettyPrintOffset()
public XmlOptions setCharacterEncoding(String encoding)
encoding
- the character encodingXmlObject.Factory.parse(java.io.File, XmlOptions)
,
XmlTokenSource.save(java.io.File, XmlOptions)
public String getCharacterEncoding()
public XmlOptions setDocumentType(SchemaType type)
QName
.type
- The root element's document type.XmlObject.Factory.parse(java.io.File, XmlOptions)
public SchemaType getDocumentType()
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 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"); } }
c
- A collection that will be filled with XmlError
objects
via Collection.add(E)
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()
public Collection<XmlError> getErrorListener()
public XmlOptions setSaveAggressiveNamespaces()
public XmlOptions setSaveAggressiveNamespaces(boolean b)
public boolean isSaveAggressiveNamespaces()
public XmlOptions setSaveSyntheticDocumentElement(QName name)
name
- the name to use for the top level elementXmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
public QName getSaveSyntheticDocumentElement()
public XmlOptions setUseDefaultNamespace()
public XmlOptions setUseDefaultNamespace(boolean b)
public boolean isUseDefaultNamespace()
public XmlOptions setSaveImplicitNamespaces(Map<String,String> implicitNamespaces)
implicitNamespaces
- a map of prefixes to uris that can be
used by the saver without being declaredXmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setSaveSuggestedPrefixes(Map<String,String> suggestedPrefixes)
suggestedPrefixes
- a map from URIs to prefixesXmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setSaveFilterProcinst(String filterProcinst)
filterProcinst
- the name of a Processing Instruction to filter
on saveXmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
public String getSaveFilterProcinst()
public XmlOptions setSaveSubstituteCharacters(XmlOptionCharEscapeMap characterReplacementMap)
characterReplacementMap
- is an XmlOptionCharEscapeMap containing
the characters to be escaped.XmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
,
XmlOptionCharEscapeMap
public XmlOptionCharEscapeMap getSaveSubstituteCharacters()
public XmlOptions setSaveUseOpenFrag()
public XmlOptions setSaveUseOpenFrag(boolean b)
public boolean isSaveUseOpenFrag()
public XmlOptions setSaveOuter()
public XmlOptions setSaveOuter(boolean b)
public boolean isSaveOuter()
public XmlOptions setSaveInner()
public XmlOptions setSaveInner(boolean b)
public boolean isSaveInner()
public XmlOptions setSaveNoXmlDecl()
public XmlOptions setSaveNoXmlDecl(boolean b)
public boolean isSaveNoXmlDecl()
public XmlOptions setSaveCDataLengthThreshold(int cdataLengthThreshold)
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 |
setSaveCDataEntityCountThreshold(int)
public Integer getSaveCDataLengthThreshold()
public XmlOptions setSaveCDataEntityCountThreshold(int cdataEntityCountThreshold)
setSaveCDataLengthThreshold(int)
public Integer getSaveCDataEntityCountThreshold()
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 = 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));
CDataBookmark
,
CDataBookmark.CDATA_BOOKMARK
public boolean isUseCDataBookmarks()
public XmlOptions setSaveSaxNoNSDeclsInAttributes()
public XmlOptions setSaveSaxNoNSDeclsInAttributes(boolean b)
public boolean isSaveSaxNoNSDeclsInAttributes()
public XmlOptions setLoadReplaceDocumentElement(QName replacement)
public QName getLoadReplaceDocumentElement()
public XmlOptions setLoadStripWhitespace()
public XmlOptions setLoadStripWhitespace(boolean b)
public boolean isSetLoadStripWhitespace()
public XmlOptions setLoadStripComments()
public XmlOptions setLoadStripComments(boolean b)
public boolean isLoadStripComments()
public XmlOptions setLoadStripProcinsts()
public XmlOptions setLoadStripProcinsts(boolean b)
public boolean isLoadStripProcinsts()
public XmlOptions setLoadLineNumbers()
XmlError
objects to contain
line numbers.
setLoadLineNumbersEndElement()
public XmlOptions setLoadLineNumbers(boolean b)
public boolean isLoadLineNumbers()
public XmlOptions setLoadLineNumbersEndElement()
XmlError
objects to contain
line numbers. Use the option to load line numbers at the end of an element.public XmlOptions setLoadLineNumbersEndElement(boolean b)
public boolean isLoadLineNumbersEndElement()
public XmlOptions setLoadSubstituteNamespaces(Map<String,String> substNamespaces)
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.
substNamespaces
- a map of document URIs to replacement URIsXmlObject.Factory.parse(java.io.File, XmlOptions)
public XmlOptions setLoadTrimTextBuffer()
public XmlOptions setLoadTrimTextBuffer(boolean b)
public boolean isLoadTrimTextBuffer()
public XmlOptions setLoadAdditionalNamespaces(Map<String,String> nses)
nses
- additional namespace mappingsXmlObject.Factory.parse(java.io.File, XmlOptions)
public XmlOptions setLoadMessageDigest()
public XmlOptions setLoadMessageDigest(boolean b)
public boolean isLoadMessageDigest()
public XmlOptions setLoadUseDefaultResolver()
public XmlOptions setLoadUseDefaultResolver(boolean b)
public boolean isLoadUseDefaultResolver()
public XmlOptions setLoadUseXMLReader(XMLReader xmlReader)
public XMLReader getLoadUseXMLReader()
public XmlOptions setXqueryCurrentNodeVar(String varName)
varName
- The new variable name to use for the query.XmlObject.execQuery(java.lang.String)
,
XmlCursor.execQuery(java.lang.String)
public String getXqueryCurrentNodeVar()
public XmlOptions setXqueryVariables(Map<String,Object> varMap)
varMap
- a map from Strings to variable instances.XmlObject.execQuery(java.lang.String)
,
XmlCursor.execQuery(java.lang.String)
public XmlOptions setDocumentSourceName(String documentSourceName)
public String getDocumentSourceName()
public XmlOptions setCompileSubstituteNames(Map<QName,QName> nameMap)
QName
substitution during schema compilation.nameMap
- a map from QName
s to substitute QName
s.XmlBeans.compileXsd(org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.SchemaTypeLoader, org.apache.xmlbeans.XmlOptions)
public XmlOptions setCompileNoValidation()
SchemaTypeSystem
public boolean isCompileNoValidation()
public XmlOptions setCompileNoUpaRule()
SchemaTypeSystem
. See
Appendix H of the XML Schema specification
for information on the UPA rule.public XmlOptions setCompileNoUpaRule(boolean b)
public boolean isCompileNoUpaRule()
public XmlOptions setCompileNoPvrRule()
SchemaTypeSystem
. See
Section 3.9.6 of the XML Schema specification
for information on the PVR rule.public XmlOptions setCompileNoPvrRule(boolean b)
public boolean isCompileNoPvrRule()
public XmlOptions setCompileNoAnnotations()
public XmlOptions setCompileNoAnnotations(boolean b)
public boolean isCompileNoAnnotations()
public XmlOptions setCompileDownloadUrls()
public XmlOptions setCompileDownloadUrls(boolean b)
public boolean isCompileDownloadUrls()
public XmlOptions setCompileMdefNamespaces(Set<String> mdefNamespaces)
mdefNamespaces
- a set of namespace URIs as StringsXmlBeans.compileXsd(org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.SchemaTypeLoader, org.apache.xmlbeans.XmlOptions)
public XmlOptions setCompilePartialTypesystem()
public XmlOptions setCompilePartialTypesystem(boolean compilePartialTypesystem)
public boolean isCompilePartialTypesystem()
public XmlOptions setValidateOnSet()
public XmlOptions setValidateOnSet(boolean b)
public boolean isValidateOnSet()
public XmlOptions setValidateTreatLaxAsSkip()
public XmlOptions setValidateTreatLaxAsSkip(boolean b)
public boolean isValidateTreatLaxAsSkip()
public XmlOptions setValidateStrict()
public XmlOptions setValidateStrict(boolean b)
public boolean isValidateStrict()
public XmlOptions setValidateTextOnly()
public XmlOptions setValidateTextOnly(boolean b)
public boolean isValidateTextOnly()
public XmlOptions setUnsynchronized()
public XmlOptions setUnsynchronized(boolean b)
public boolean isUnsynchronized()
public XmlOptions setEntityResolver(EntityResolver resolver)
EntityResolvers are currently only used by compileXsd; they are not consulted by other functions, for example, parse. This will likely change in the future.
public EntityResolver getEntityResolver()
public XmlOptions setBaseURI(URI baseURI)
baseURI
- the URI to be considered as "base"XmlBeans.compileXsd(org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.SchemaTypeLoader, org.apache.xmlbeans.XmlOptions)
public URI getBaseURI()
public XmlOptions setSchemaCodePrinter(SchemaCodePrinter printer)
public SchemaCodePrinter getSchemaCodePrinter()
public XmlOptions setCopyUseNewSynchronizationDomain(boolean useNewSyncDomain)
useNewSyncDomain
- A flag representing the usage of new domainXmlObject.copy()
public boolean isCopyUseNewSynchronizationDomain()
public XmlOptions setUseSameLocale(Object localeOrXmlTokenSource)
public Object getUseSameLocale()
public XmlOptions setLoadEntityBytesLimit(int entityBytesLimit)
entityBytesLimit
- the maximum number of bytes allowed when an Entity is expanded during parsingpublic Integer getLoadEntityBytesLimit()
public XmlOptions setEntityExpansionLimit(int entityExpansionLimit)
entityExpansionLimit
- the maximum number of entity expansions allowed during parsingpublic int getEntityExpansionLimit()
public XmlOptions setLoadDTDGrammar(boolean loadDTDGrammar)
loadDTDGrammar
- true
, if DTD grammar is loaded during parsingpublic boolean isLoadDTDGrammar()
public XmlOptions setLoadExternalDTD(boolean loadExternalDTD)
loadExternalDTD
- true
, if external DTDs are loaded during parsingpublic boolean isLoadExternalDTD()
public XmlOptions setSaveOptimizeForSpeed(boolean saveOptimizeForSpeed)
public boolean isSaveOptimizeForSpeed()
public XmlOptions setSaaj(Saaj saaj)
public Saaj getSaaj()
public XmlOptions setLoadUseLocaleCharUtil(boolean useCharUtil)
public boolean isLoadUseLocaleCharUtil()
public XmlOptions setXPathUseSaxon()
public XmlOptions setXPathUseSaxon(boolean xpathUseSaxon)
public boolean isXPathUseSaxon()
public XmlOptions setXPathUseXmlBeans()
public XmlOptions setXPathUseXmlBeans(boolean xpathUseXmlBeans)
public boolean isXPathUseXmlBeans()
public XmlOptions setAttributeValidationCompatMode(boolean attributeValidationCompatMode)
public boolean isAttributeValidationCompatMode()
public static XmlOptions maskNull(XmlOptions o)
public boolean hasOption(XmlOptions.XmlOptionsKeys option)
public Object get(XmlOptions.XmlOptionsKeys option)
public void remove(XmlOptions.XmlOptionsKeys option)