|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xmlbeans.XmlOptions
public class XmlOptions
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:
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 |
Field Summary | |
---|---|
static java.lang.String |
BASE_URI
|
static java.lang.String |
CHARACTER_ENCODING
|
static java.lang.String |
COMPILE_DOWNLOAD_URLS
|
static java.lang.String |
COMPILE_MDEF_NAMESPACES
|
static java.lang.String |
COMPILE_NO_ANNOTATIONS
|
static java.lang.String |
COMPILE_NO_PVR_RULE
|
static java.lang.String |
COMPILE_NO_UPA_RULE
|
static java.lang.String |
COMPILE_NO_VALIDATION
|
static java.lang.String |
COMPILE_SUBSTITUTE_NAMES
|
static java.lang.String |
COPY_USE_NEW_SYNC_DOMAIN
|
static int |
DEFAULT_ENTITY_EXPANSION_LIMIT
|
static java.lang.String |
DOCUMENT_SOURCE_NAME
|
static java.lang.String |
DOCUMENT_TYPE
|
static java.lang.String |
ENTITY_EXPANSION_LIMIT
|
static java.lang.String |
ENTITY_RESOLVER
|
static java.lang.String |
ERROR_LISTENER
|
static java.lang.String |
GENERATE_JAVA_14
|
static java.lang.String |
GENERATE_JAVA_15
|
static java.lang.String |
GENERATE_JAVA_VERSION
|
static java.lang.String |
LOAD_ADDITIONAL_NAMESPACES
|
static java.lang.String |
LOAD_DTD_GRAMMAR
|
static java.lang.String |
LOAD_ENTITY_BYTES_LIMIT
|
static java.lang.String |
LOAD_EXTERNAL_DTD
|
static java.lang.String |
LOAD_LINE_NUMBERS
|
static java.lang.String |
LOAD_LINE_NUMBERS_END_ELEMENT
|
static java.lang.String |
LOAD_MESSAGE_DIGEST
|
static java.lang.String |
LOAD_REPLACE_DOCUMENT_ELEMENT
|
static java.lang.String |
LOAD_SAVE_CDATA_BOOKMARKS
|
static java.lang.String |
LOAD_STRIP_COMMENTS
|
static java.lang.String |
LOAD_STRIP_PROCINSTS
|
static java.lang.String |
LOAD_STRIP_WHITESPACE
|
static java.lang.String |
LOAD_SUBSTITUTE_NAMESPACES
|
static java.lang.String |
LOAD_TRIM_TEXT_BUFFER
|
static java.lang.String |
LOAD_USE_DEFAULT_RESOLVER
|
static java.lang.String |
LOAD_USE_XMLREADER
|
static java.lang.String |
SAVE_AGGRESSIVE_NAMESPACES
|
static java.lang.String |
SAVE_CDATA_ENTITY_COUNT_THRESHOLD
|
static java.lang.String |
SAVE_CDATA_LENGTH_THRESHOLD
|
static java.lang.String |
SAVE_FILTER_PROCINST
|
static java.lang.String |
SAVE_IMPLICIT_NAMESPACES
|
static java.lang.String |
SAVE_INNER
|
static java.lang.String |
SAVE_NAMESPACES_FIRST
|
static java.lang.String |
SAVE_NO_XML_DECL
|
static java.lang.String |
SAVE_OPTIMIZE_FOR_SPEED
|
static java.lang.String |
SAVE_OUTER
|
static java.lang.String |
SAVE_PRETTY_PRINT
|
static java.lang.String |
SAVE_PRETTY_PRINT_INDENT
|
static java.lang.String |
SAVE_PRETTY_PRINT_OFFSET
|
static java.lang.String |
SAVE_SAX_NO_NSDECLS_IN_ATTRIBUTES
|
static java.lang.String |
SAVE_SUBSTITUTE_CHARACTERS
|
static java.lang.String |
SAVE_SUGGESTED_PREFIXES
|
static java.lang.String |
SAVE_SYNTHETIC_DOCUMENT_ELEMENT
|
static java.lang.String |
SAVE_USE_DEFAULT_NAMESPACE
|
static java.lang.String |
SAVE_USE_OPEN_FRAGMENT
|
static java.lang.String |
SCHEMA_CODE_PRINTER
|
static java.lang.String |
UNSYNCHRONIZED
|
static java.lang.String |
VALIDATE_ON_SET
|
static java.lang.String |
VALIDATE_STRICT
|
static java.lang.String |
VALIDATE_TEXT_ONLY
|
static java.lang.String |
VALIDATE_TREAT_LAX_AS_SKIP
|
static java.lang.String |
XQUERY_CURRENT_NODE_VAR
|
static java.lang.String |
XQUERY_VARIABLE_MAP
|
Constructor Summary | |
---|---|
XmlOptions()
Construct a new blank XmlOptions. |
|
XmlOptions(XmlOptions other)
Construct a new XmlOptions, copying the options. |
Method Summary | |
---|---|
java.lang.Object |
get(java.lang.Object option)
Used to get a generic option |
boolean |
hasOption(java.lang.Object option)
Used to test a generic option |
static boolean |
hasOption(XmlOptions options,
java.lang.Object option)
|
static XmlOptions |
maskNull(XmlOptions o)
If passed null, returns an empty options object. |
void |
put(java.lang.Object option)
Used to set a generic option |
void |
put(java.lang.Object option,
int value)
Used to set a generic option |
void |
put(java.lang.Object option,
java.lang.Object value)
Used to set a generic option |
void |
remove(java.lang.Object option)
|
static java.lang.Object |
safeGet(XmlOptions o,
java.lang.Object option)
Used to test a generic option on an options object that may be null |
XmlOptions |
setBaseURI(java.net.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(java.lang.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 |
setCompileMdefNamespaces(java.util.Set 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 |
setCompileNoPvrRule()
If this option is set, the particle valid (restriciton) rule is not enforced when building a SchemaTypeSystem . |
XmlOptions |
setCompileNoUpaRule()
If this option is set, the unique particle attribution rule is not enforced when building a SchemaTypeSystem . |
XmlOptions |
setCompileNoValidation()
If this option is set, validation is not done on the Schema XmlBeans when building a SchemaTypeSystem |
XmlOptions |
setCompileSubstituteNames(java.util.Map 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(java.lang.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(java.util.Collection c)
Sets a collection object for collecting XmlError objects
during parsing, validation, and compilation. |
XmlOptions |
setGenerateJavaVersion(java.lang.String source)
If this option is set, then the schema compiler will print java code that is compatible with the desired Java version. |
XmlOptions |
setLoadAdditionalNamespaces(java.util.Map 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(java.lang.String option)
If this option is set, line number annotations are placed in the store when parsing a document. |
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 |
setLoadReplaceDocumentElement(javax.xml.namespace.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 |
setLoadStripProcinsts()
If this option is set, all processing instructions are stripped when parsing a document. |
XmlOptions |
setLoadStripWhitespace()
If this option is set, all insignificant whitespace is stripped when parsing a document. |
XmlOptions |
setLoadSubstituteNamespaces(java.util.Map 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 |
setLoadUseDefaultResolver()
By default, XmlBeans does not resolve entities when parsing xml documents (unless an explicit entity resolver is specified). |
XmlOptions |
setLoadUseXMLReader(XMLReader xmlReader)
By default, XmlBeans creates a JAXP parser, other parsers can be used by providing an XMLReader. |
XmlOptions |
setSaveAggresiveNamespaces()
Deprecated. replaced by setSaveAggressiveNamespaces() |
XmlOptions |
setSaveAggressiveNamespaces()
Causes the saver to reduce the number of namespace prefix declarations. |
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(java.lang.String filterProcinst)
This option causes the saver to filter a Processing Instruction with the given target |
XmlOptions |
setSaveImplicitNamespaces(java.util.Map 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 |
setSaveNamespacesFirst()
This option will cause the saver to save namespace attributes first. |
XmlOptions |
setSaveNoXmlDecl()
This option controls whether saving saves out the XML declaration ( |
XmlOptions |
setSaveOuter()
This option controls whether saving begins on the element or its contents |
XmlOptions |
setSavePrettyPrint()
This option will cause the saver to reformat white space for easier reading. |
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 |
setSaveSubstituteCharacters(XmlOptionCharEscapeMap characterReplacementMap)
This option causes the saver to replace characters with other values in the output stream. |
XmlOptions |
setSaveSuggestedPrefixes(java.util.Map suggestedPrefixes)
A map of hints to pass to the saver for which prefixes to use for which namespace URI. |
XmlOptions |
setSaveSyntheticDocumentElement(javax.xml.namespace.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 |
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 |
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 |
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 |
setValidateStrict()
Performs additional validation checks that are disabled by default for better compatibility. |
XmlOptions |
setValidateTreatLaxAsSkip()
Instructs the validator to skip elements matching an |
XmlOptions |
setXqueryCurrentNodeVar(java.lang.String varName)
Sets the name of the variable that represents the current node in a query expression. |
XmlOptions |
setXqueryVariables(java.util.Map varMap)
Map the names and values of external variables in an xquery expression. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String GENERATE_JAVA_14
public static final java.lang.String GENERATE_JAVA_15
public static final java.lang.String SAVE_NAMESPACES_FIRST
public static final java.lang.String SAVE_SYNTHETIC_DOCUMENT_ELEMENT
public static final java.lang.String SAVE_PRETTY_PRINT
public static final java.lang.String SAVE_PRETTY_PRINT_INDENT
public static final java.lang.String SAVE_PRETTY_PRINT_OFFSET
public static final java.lang.String SAVE_AGGRESSIVE_NAMESPACES
public static final java.lang.String SAVE_USE_DEFAULT_NAMESPACE
public static final java.lang.String SAVE_IMPLICIT_NAMESPACES
public static final java.lang.String SAVE_SUGGESTED_PREFIXES
public static final java.lang.String SAVE_FILTER_PROCINST
public static final java.lang.String SAVE_USE_OPEN_FRAGMENT
public static final java.lang.String SAVE_OUTER
public static final java.lang.String SAVE_INNER
public static final java.lang.String SAVE_NO_XML_DECL
public static final java.lang.String SAVE_SUBSTITUTE_CHARACTERS
public static final java.lang.String SAVE_OPTIMIZE_FOR_SPEED
public static final java.lang.String SAVE_CDATA_LENGTH_THRESHOLD
public static final java.lang.String SAVE_CDATA_ENTITY_COUNT_THRESHOLD
public static final java.lang.String SAVE_SAX_NO_NSDECLS_IN_ATTRIBUTES
public static final java.lang.String LOAD_REPLACE_DOCUMENT_ELEMENT
public static final java.lang.String LOAD_STRIP_WHITESPACE
public static final java.lang.String LOAD_STRIP_COMMENTS
public static final java.lang.String LOAD_STRIP_PROCINSTS
public static final java.lang.String LOAD_LINE_NUMBERS
public static final java.lang.String LOAD_LINE_NUMBERS_END_ELEMENT
public static final java.lang.String LOAD_SAVE_CDATA_BOOKMARKS
public static final java.lang.String LOAD_SUBSTITUTE_NAMESPACES
public static final java.lang.String LOAD_TRIM_TEXT_BUFFER
public static final java.lang.String LOAD_ADDITIONAL_NAMESPACES
public static final java.lang.String LOAD_MESSAGE_DIGEST
public static final java.lang.String LOAD_USE_DEFAULT_RESOLVER
public static final java.lang.String LOAD_USE_XMLREADER
public static final java.lang.String XQUERY_CURRENT_NODE_VAR
public static final java.lang.String XQUERY_VARIABLE_MAP
public static final java.lang.String CHARACTER_ENCODING
public static final java.lang.String ERROR_LISTENER
public static final java.lang.String DOCUMENT_TYPE
public static final java.lang.String DOCUMENT_SOURCE_NAME
public static final java.lang.String COMPILE_SUBSTITUTE_NAMES
public static final java.lang.String COMPILE_NO_VALIDATION
public static final java.lang.String COMPILE_NO_UPA_RULE
public static final java.lang.String COMPILE_NO_PVR_RULE
public static final java.lang.String COMPILE_NO_ANNOTATIONS
public static final java.lang.String COMPILE_DOWNLOAD_URLS
public static final java.lang.String COMPILE_MDEF_NAMESPACES
public static final java.lang.String VALIDATE_ON_SET
public static final java.lang.String VALIDATE_TREAT_LAX_AS_SKIP
public static final java.lang.String VALIDATE_STRICT
public static final java.lang.String VALIDATE_TEXT_ONLY
public static final java.lang.String UNSYNCHRONIZED
public static final java.lang.String ENTITY_RESOLVER
public static final java.lang.String BASE_URI
public static final java.lang.String SCHEMA_CODE_PRINTER
public static final java.lang.String GENERATE_JAVA_VERSION
public static final java.lang.String COPY_USE_NEW_SYNC_DOMAIN
public static final java.lang.String LOAD_ENTITY_BYTES_LIMIT
public static final java.lang.String ENTITY_EXPANSION_LIMIT
public static final java.lang.String LOAD_DTD_GRAMMAR
public static final java.lang.String LOAD_EXTERNAL_DTD
public static final int DEFAULT_ENTITY_EXPANSION_LIMIT
Constructor Detail |
---|
public XmlOptions()
public XmlOptions(XmlOptions other)
Method Detail |
---|
public XmlOptions setSaveNamespacesFirst()
XmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setSavePrettyPrint()
XmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
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 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 XmlOptions setCharacterEncoding(java.lang.String encoding)
encoding
- the character encodingXmlObject.Factory.parse(java.io.File, XmlOptions)
,
XmlTokenSource.save(java.io.File, XmlOptions)
public XmlOptions setDocumentType(SchemaType type)
QName
.
type
- The root element's document type.XmlObject.Factory.parse(java.io.File, XmlOptions)
public XmlOptions setErrorListener(java.util.Collection 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 XmlOptions setSaveAggressiveNamespaces()
XmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setSaveAggresiveNamespaces()
setSaveAggressiveNamespaces()
public XmlOptions setSaveSyntheticDocumentElement(javax.xml.namespace.QName name)
name
- the name to use for the top level elementXmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setUseDefaultNamespace()
XmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setSaveImplicitNamespaces(java.util.Map 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(java.util.Map suggestedPrefixes)
suggestedPrefixes
- a map from URIs to prefixesXmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setSaveFilterProcinst(java.lang.String filterProcinst)
filterProcinst
- the name of a Processing Instruction to filter
on saveXmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
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 XmlOptions setSaveUseOpenFrag()
XmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setSaveOuter()
XmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setSaveInner()
XmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setSaveNoXmlDecl()
XmlTokenSource.save(java.io.File, XmlOptions)
,
XmlTokenSource.xmlText(XmlOptions)
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 XmlOptions setSaveCDataEntityCountThreshold(int cdataEntityCountThreshold)
setSaveCDataLengthThreshold(int)
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 XmlOptions setSaveSaxNoNSDeclsInAttributes()
public XmlOptions setLoadReplaceDocumentElement(javax.xml.namespace.QName replacement)
XmlObject.Factory.parse(java.io.File, XmlOptions)
public XmlOptions setLoadStripWhitespace()
XmlObject.Factory.parse(java.io.File, XmlOptions)
public XmlOptions setLoadStripComments()
XmlObject.Factory.parse(java.io.File, XmlOptions)
public XmlOptions setLoadStripProcinsts()
XmlObject.Factory.parse(java.io.File, XmlOptions)
public XmlOptions setLoadLineNumbers()
XmlError
objects to contain
line numbers.
setLoadLineNumbers(java.lang.String)
XmlObject.Factory.parse(java.io.File, XmlOptions)
,
XmlError
public XmlOptions setLoadLineNumbers(java.lang.String option)
XmlError
objects to contain
line numbers. Use the option to load line numbers at the end of an element.
XmlObject.Factory.parse(java.io.File, XmlOptions)
,
XmlError
public XmlOptions setLoadSubstituteNamespaces(java.util.Map 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()
XmlObject.Factory.parse(java.io.File, XmlOptions)
public XmlOptions setLoadAdditionalNamespaces(java.util.Map nses)
nses
- additional namespace mappingsXmlObject.Factory.parse(java.io.File, XmlOptions)
public XmlOptions setLoadMessageDigest()
XmlObject.Factory.parse(java.io.File, XmlOptions)
public XmlOptions setLoadUseDefaultResolver()
XmlObject.Factory.parse(java.io.File, XmlOptions)
public XmlOptions setLoadUseXMLReader(XMLReader xmlReader)
XmlObject.Factory.parse(java.io.File, XmlOptions)
public XmlOptions setXqueryCurrentNodeVar(java.lang.String varName)
varName
- The new variable name to use for the query.XmlObject.execQuery(java.lang.String)
,
XmlCursor.execQuery(java.lang.String)
public XmlOptions setXqueryVariables(java.util.Map varMap)
varMap
- a map from Strings to variable instances.XmlObject.execQuery(java.lang.String)
,
XmlCursor.execQuery(java.lang.String)
public XmlOptions setDocumentSourceName(java.lang.String documentSourceName)
XmlObject.Factory.parse(java.lang.String, XmlOptions)
public XmlOptions setCompileSubstituteNames(java.util.Map 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
XmlBeans.compileXsd(org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.SchemaTypeLoader, org.apache.xmlbeans.XmlOptions)
public XmlOptions setCompileNoUpaRule()
SchemaTypeSystem
. See
Appendix H of the XML Schema specification
for information on the UPA rule.
XmlBeans.compileXsd(org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.SchemaTypeLoader, org.apache.xmlbeans.XmlOptions)
public XmlOptions setCompileNoPvrRule()
SchemaTypeSystem
. See
Section 3.9.6 of the XML Schema specification
for information on the PVR rule.
XmlBeans.compileXsd(org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.SchemaTypeLoader, org.apache.xmlbeans.XmlOptions)
public XmlOptions setCompileNoAnnotations()
XmlBeans.compileXsd(org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.SchemaTypeLoader, org.apache.xmlbeans.XmlOptions)
public XmlOptions setCompileDownloadUrls()
XmlBeans.compileXsd(org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.SchemaTypeLoader, org.apache.xmlbeans.XmlOptions)
public XmlOptions setCompileMdefNamespaces(java.util.Set mdefNamespaces)
mdefNamespaces
- a set of namespace URIs as StringsXmlBeans.compileXsd(org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.SchemaTypeLoader, org.apache.xmlbeans.XmlOptions)
public XmlOptions setValidateOnSet()
XmlObject.Factory.parse(java.io.File, XmlOptions)
public XmlOptions setValidateTreatLaxAsSkip()
public XmlOptions setValidateStrict()
public XmlOptions setUnsynchronized()
public XmlOptions setEntityResolver(EntityResolver resolver)
XmlBeans.compileXsd(org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.SchemaTypeLoader, org.apache.xmlbeans.XmlOptions)
public XmlOptions setBaseURI(java.net.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 XmlOptions setSchemaCodePrinter(SchemaCodePrinter printer)
XmlBeans.compileXsd(org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.SchemaTypeLoader, org.apache.xmlbeans.XmlOptions)
public XmlOptions setGenerateJavaVersion(java.lang.String source)
source
- A Java version numberGENERATE_JAVA_14
,
GENERATE_JAVA_15
,
XmlBeans.compileXmlBeans(java.lang.String, org.apache.xmlbeans.SchemaTypeSystem, org.apache.xmlbeans.XmlObject[], org.apache.xmlbeans.BindingConfig, org.apache.xmlbeans.SchemaTypeLoader, org.apache.xmlbeans.Filer, org.apache.xmlbeans.XmlOptions)
public XmlOptions setCopyUseNewSynchronizationDomain(boolean useNewSyncDomain)
useNewSyncDomain
- A flag representing the usage of new domainXmlObject.copy()
public XmlOptions setLoadEntityBytesLimit(int entityBytesLimit)
entityBytesLimit
-
public XmlOptions setEntityExpansionLimit(int entityExpansionLimit)
entityExpansionLimit
-
public XmlOptions setLoadDTDGrammar(boolean loadDTDGrammar)
loadDTDGrammar
-
public XmlOptions setLoadExternalDTD(boolean loadExternalDTD)
loadExternalDTD
-
public static XmlOptions maskNull(XmlOptions o)
public void put(java.lang.Object option)
public void put(java.lang.Object option, java.lang.Object value)
public void put(java.lang.Object option, int value)
public boolean hasOption(java.lang.Object option)
public static boolean hasOption(XmlOptions options, java.lang.Object option)
public java.lang.Object get(java.lang.Object option)
public void remove(java.lang.Object option)
public static java.lang.Object safeGet(XmlOptions o, java.lang.Object option)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |