Object
Serializable
Used to supply options for loading, saving, and compiling, and validating.
There are two styles for using XmlOptions: multiline setup, and single-line use. Here are two examples. First, multiline style:
XmlOptions opts = new XmlOptions(); opts.setSavePrettyPrint(); opts.setSavePrettyPrintIndent(4); System.out.println(xobj.xmlText(opts));The alternative is single-line usage:
System.out.println(xobj.xmlText(
new XmlOptions().setSavePrettyPrint().setSavePrettyPrintIndent(4)));
Object
XmlOptions
Serializable
Field Summary |
Constructor Summary |
|
|
Method Summary |
public | |
public boolean | |
public static |
|
public void | |
public void | |
public void | |
public static |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
public |
|
Methods from class java.lang. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
Constructor Detail |
public XmlOptions()
public XmlOptions(XmlOptions other)
Method Detail |
publicUsed to get a generic optionObjectget(Objectoption)
public boolean hasOption(Object option)
Used to test a generic option
public staticIf passed null, returns an empty options object. Otherwise, returns its argument.XmlOptionsmaskNull(XmlOptionso)
public void put(Object option)
Used to set a generic option
public void put(Used to set a generic optionObjectoption,Objectvalue)
public void put(Object option,
int value)
Used to set a generic option
public staticUsed to test a generic option on an options object that may be nullObjectsafeGet(XmlOptionso,Objectoption)
publicWhen parsing or writing a document, this sets the character encoding to use.XmlOptionssetCharacterEncoding(Stringencoding)
Related Topics
XmlObject.Factory.parse(File, XmlOptions)
XmlTokenSource.save(File, XmlOptions)
public XmlOptions setCompileDownloadUrls()
If this option is set, then the schema compiler will try to download
schemas that appear in imports and includes from network based URLs.
Related Topics
XmlBeans.compileXsd(XmlObject[], SchemaTypeLoader, XmlOptions)
publicIf 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.XmlOptionssetCompileMdefNamespaces(SetmdefNamespaces)
Related Topics
XmlBeans.compileXsd(XmlObject[], SchemaTypeLoader, XmlOptions)
public XmlOptions setCompileNoPvrRule()
If this option is set, the particle valid (restriciton) rule is not
enforced when building a SchemaTypeSystem. See
Section 3.9.6 of the XML Schema specification
for information on the PVR rule.
Related Topics
XmlBeans.compileXsd(XmlObject[], SchemaTypeLoader, XmlOptions)
public XmlOptions setCompileNoUpaRule()
If this option is set, the unique particle attribution rule is not
enforced when building a SchemaTypeSystem. See
Appendix H of the XML Schema specification
for information on the UPA rule.
Related Topics
XmlBeans.compileXsd(XmlObject[], SchemaTypeLoader, XmlOptions)
public XmlOptions setCompileNoValidation()
If this option is set, validation is not done on the Schema XmlBeans
when building a SchemaTypeSystem
Related Topics
XmlBeans.compileXsd(XmlObject[], SchemaTypeLoader, XmlOptions)
publicThis option allows forXmlOptionssetCompileSubstituteNames(MapnameMap)
QName substitution during schema compilation.
QNames to substitute QNames. Related Topics
XmlBeans.compileXsd(XmlObject[], SchemaTypeLoader, XmlOptions)
publicThis 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.XmlOptionssetDocumentSourceName(StringdocumentSourceName)
Related Topics
XmlObject.Factory.parse(String, XmlOptions)
publicWhen 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'sXmlOptionssetDocumentType(SchemaTypetype)
QName.
Related Topics
XmlObject.Factory.parse(File, XmlOptions)
publicIf 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.XmlOptionssetEntityResolver(EntityResolverresolver)
Related Topics
XmlBeans.compileXsd(XmlObject[], SchemaTypeLoader, XmlOptions)
publicXmlOptionssetErrorListener(Collectionc)
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");
}
}
XmlError objects
via Collection.add(Object)
Related Topics
XmlError
XmlObject.Factory.parse(File, XmlOptions)
XmlObject.validate(XmlOptions)
XmlBeans.compileXsd(XmlObject[], SchemaTypeLoader, XmlOptions)
XmlOptions.setLoadLineNumbers()
publicSet additional namespace mappings to be added when parsing a document.XmlOptionssetLoadAdditionalNamespaces(Mapnses)
Related Topics
XmlObject.Factory.parse(File, XmlOptions)
public XmlOptions setLoadLineNumbers()
If this option is set, line number annotations are placed
in the store when parsing a document. This is particularly
useful when you want XmlError objects to contain
line numbers.
Related Topics
XmlObject.Factory.parse(File, XmlOptions)
XmlError
public XmlOptions setLoadMessageDigest()
If this option is set when loading from an InputStream or File, then
the loader will compute a 160-bit SHA-1 message digest of the XML
file while loading it and make it available via
XmlObject.documentProperties().getMessageDigest();
Related Topics
XmlObject.Factory.parse(File, XmlOptions)
publicIf this option is set, the document element is replaced with the given QName when parsing. If null is supplied, the document element is removed.XmlOptionssetLoadReplaceDocumentElement(QNamereplacement)
Related Topics
XmlObject.Factory.parse(File, XmlOptions)
public XmlOptions setLoadStripComments()
If this option is set, all comments are stripped when parsing
a document.
Related Topics
XmlObject.Factory.parse(File, XmlOptions)
public XmlOptions setLoadStripProcinsts()
If this option is set, all processing instructions
are stripped when parsing a document.
Related Topics
XmlObject.Factory.parse(File, XmlOptions)
public XmlOptions setLoadStripWhitespace()
If this option is set, all insignificant whitespace is stripped
when parsing a document. Can be used to save memory on large
documents when you know there is no mixed content.
Related Topics
XmlObject.Factory.parse(File, XmlOptions)
publicThis option sets a map of namespace uri substitutions that happen when parsing a document.XmlOptionssetLoadSubstituteNamespaces(MapsubstNamespaces)
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.
Related Topics
XmlObject.Factory.parse(File, XmlOptions)
public XmlOptions setLoadTrimTextBuffer()
If this option is set, the underlying xml text buffer is trimmed
immediately after parsing a document resulting in a smaller memory
footprint. Use this option if you are loading a large number
of unchanging documents that will stay in memory for some time.
Related Topics
XmlObject.Factory.parse(File, XmlOptions)
public XmlOptions setSaveAggresiveNamespaces()
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.
Related Topics
XmlTokenSource.save(File, XmlOptions)
XmlTokenSource.xmlText(XmlOptions)
publicThis option causes the saver to filter a Processing Instruction with the given targetXmlOptionssetSaveFilterProcinst(StringfilterProcinst)
Related Topics
XmlTokenSource.save(File, XmlOptions)
XmlTokenSource.xmlText(XmlOptions)
publicIf 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.XmlOptionssetSaveImplicitNamespaces(MapimplicitNamespaces)
Related Topics
XmlTokenSource.save(File, XmlOptions)
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setSaveInner()
This option controls whether saving begins on the element or its contents
Related Topics
XmlTokenSource.save(File, XmlOptions)
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setSaveNamespacesFirst()
This option will cause the saver to save namespace attributes first.
Related Topics
XmlTokenSource.save(File, XmlOptions)
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setSaveOuter()
This option controls whether saving begins on the element or its contents
Related Topics
XmlTokenSource.save(File, XmlOptions)
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setSavePrettyPrint()
This option will cause the saver to reformat white space for easier reading.
Related Topics
XmlTokenSource.save(File, XmlOptions)
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setSavePrettyPrintIndent(int indent)
When used with setSavePrettyPrint this sets the indent
amount to use.
Related Topics
XmlOptions.setSavePrettyPrint()
XmlTokenSource.save(File, XmlOptions)
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setSavePrettyPrintOffset(int offset)
When used with setSavePrettyPrint this sets the offset
amount to use.
Related Topics
XmlOptions.setSavePrettyPrint()
XmlTokenSource.save(File, XmlOptions)
XmlTokenSource.xmlText(XmlOptions)
publicA map of hints to pass to the saver for which prefixes to use for which namespace URI.XmlOptionssetSaveSuggestedPrefixes(MapsuggestedPrefixes)
Related Topics
XmlTokenSource.save(File, XmlOptions)
XmlTokenSource.xmlText(XmlOptions)
publicThis option causes the saver to wrap the current fragment in an element with the given name.XmlOptionssetSaveSyntheticDocumentElement(QNamename)
Related Topics
XmlTokenSource.save(File, XmlOptions)
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setSaveUseOpenFrag()
When saving a fragment, this option changes the qname of the synthesized
root element. Normally <xml-fragment> is used.
Related Topics
XmlTokenSource.save(File, XmlOptions)
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setUseDefaultNamespace()
If this option is set, the saver will try to use the default
namespace for the most commonly used URI. If it is not set
the saver will always created named prefixes.
Related Topics
XmlTokenSource.save(File, XmlOptions)
XmlTokenSource.xmlText(XmlOptions)
public XmlOptions setValidateOnSet()
If this option is set when an instance is created, then value
facets will be checked on each call to a setter or getter
method on instances of XmlObject within the instance document.
If the facets are not satisfied, then an unchecked exception is
thrown immediately. This option is useful for finding code that
is introducing invalid values in an XML document, but it
slows performance.
Related Topics
XmlObject.Factory.parse(File, XmlOptions)
publicSets the name of the variable that represents the current node in a query expression.XmlOptionssetXqueryCurrentNodeVar(StringvarName)
Related Topics
XmlObject.execQuery(String)
XmlCursor.execQuery(String)
publicMap 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.XmlOptionssetXqueryVariables(MapvarMap)
Strings to variable instances. Related Topics