Package org.apache.xmlbeans.impl.schema
Class XmlObjectFactory<T>
java.lang.Object
org.apache.xmlbeans.impl.schema.ElementFactory<T>
org.apache.xmlbeans.impl.schema.AbstractDocumentFactory<T>
org.apache.xmlbeans.impl.schema.DocumentFactory<T>
org.apache.xmlbeans.impl.schema.XmlObjectFactory<T>
public class XmlObjectFactory<T> extends DocumentFactory<T>
Factory class for creating new instances. Note that if
a type can be inferred from the XML being loaded (for example,
by recognizing the document element QName), then the instance
returned by a factory will have the inferred type. Otherwise
the Factory will returned an untyped document.
-
Constructor Summary
Constructors Constructor Description XmlObjectFactory(String typeHandle)XmlObjectFactory(SchemaTypeSystem typeSystem, String typeHandle)This constructor is only used as a workaround for bootstrapping the XML schemas - don't use it! -
Method Summary
Modifier and Type Method Description DOMImplementationnewDomImplementation()Creates a new DOMImplementation objectDOMImplementationnewDomImplementation(XmlOptions options)Creates a new DOMImplementation object, taking optionsTnewInstance()Creates a new, completely empty instance.TnewInstance(XmlOptions options)Creates a new, completely empty instance, specifying options for the root element's document type and/or whether to validate value facets as they are set.TnewValue(Object obj)Creates an immutableXmlObjectvalueXmlSaxHandlernewXmlSaxHandler()Returns anXmlSaxHandlerthat can load an XmlObject from SAX events.XmlSaxHandlernewXmlSaxHandler(XmlOptions options)Returns anXmlSaxHandlerthat can load an XmlObject from SAX events.Tparse(File file)Parses the givenFileas XML.Tparse(File file, XmlOptions options)Parses the givenFileas XML.Tparse(InputStream is)Decodes and parses the givenInputStreamas XML.Tparse(InputStream is, XmlOptions options)Decodes and parses the givenInputStreamas XML.Tparse(Reader r)Parses the givenReaderas XML.Tparse(Reader r, XmlOptions options)Parses the givenReaderas XML.Tparse(String xmlAsString)Parses the givenStringas XML.Tparse(String xmlAsString, XmlOptions options)Parses the givenStringas XML.Tparse(URL u)Downloads the givenURLas XML.Tparse(URL u, XmlOptions options)Downloads the givenURLas XML.Tparse(XMLStreamReader xsr)Decodes and parses the givenXMLStreamReaderas XML.Tparse(XMLStreamReader xsr, XmlOptions options)Parses the givenXMLStreamReaderas XML.Tparse(Node node)Converts the given DOMNodeinto an XmlObject.Tparse(Node node, XmlOptions options)Converts the given DOMNodeinto an XmlObject.
-
Constructor Details
-
XmlObjectFactory
-
XmlObjectFactory
This constructor is only used as a workaround for bootstrapping the XML schemas - don't use it!
-
-
Method Details
-
newInstance
Creates a new, completely empty instance.- Overrides:
newInstancein classDocumentFactory<T>
-
newInstance
Creates a new, completely empty instance, specifying options for the root element's document type and/or whether to validate value facets as they are set.
Use the options parameter to specify the following:
To specify this Use this method The document type for the root element. XmlOptions.setDocumentType(org.apache.xmlbeans.SchemaType)Whether value facets should be checked as they are set. XmlOptions.setValidateOnSet()- Overrides:
newInstancein classDocumentFactory<T>- Parameters:
options- Options specifying root document type and/or value facet checking.- Returns:
- A new, empty instance of XmlObject.
-
-
newValue
Creates an immutableXmlObjectvalue -
parse
Parses the givenStringas XML.- Overrides:
parsein classAbstractDocumentFactory<T>- Parameters:
xmlAsString- the string value to parse- Throws:
XmlException
-
parse
Parses the givenStringas XML.Use the options parameter to specify the following:
To specify this Use this method The document type for the root element. XmlOptions.setDocumentType(org.apache.xmlbeans.SchemaType)To place line number annotations in the store when parsing a document. XmlOptions.setLoadLineNumbers()To replace the document element with the specified QName when parsing. XmlOptions.setLoadReplaceDocumentElement(javax.xml.namespace.QName)To strip all insignificant whitespace when parsing a document. XmlOptions.setLoadStripWhitespace()To strip all comments when parsing a document. XmlOptions.setLoadStripComments()To strip all processing instructions when parsing a document. XmlOptions.setLoadStripProcinsts()A map of namespace URI substitutions to use when parsing a document. XmlOptions.setLoadSubstituteNamespaces(java.util.Map<java.lang.String, java.lang.String>)Additional namespace mappings to be added when parsing a document. XmlOptions.setLoadAdditionalNamespaces(java.util.Map<java.lang.String, java.lang.String>)To trim the underlying XML text buffer immediately after parsing a document, resulting in a smaller memory footprint. XmlOptions.setLoadTrimTextBuffer()- Overrides:
parsein classAbstractDocumentFactory<T>- Parameters:
xmlAsString- The string to parse.options- Options as specified.- Returns:
- A new instance containing the specified XML.
- Throws:
XmlException
-
parse
Parses the givenFileas XML.- Overrides:
parsein classAbstractDocumentFactory<T>- Parameters:
file- the file from which to load an xml document- Throws:
XmlExceptionIOException
-
parse
Parses the givenFileas XML.- Overrides:
parsein classAbstractDocumentFactory<T>- Throws:
XmlExceptionIOException
-
parse
Downloads the givenURLas XML.- Overrides:
parsein classAbstractDocumentFactory<T>- Throws:
XmlExceptionIOException
-
parse
Downloads the givenURLas XML.- Overrides:
parsein classAbstractDocumentFactory<T>- Throws:
XmlExceptionIOException
-
parse
Decodes and parses the givenInputStreamas XML.- Overrides:
parsein classAbstractDocumentFactory<T>- Throws:
XmlExceptionIOException
-
parse
Decodes and parses the givenXMLStreamReaderas XML.- Overrides:
parsein classAbstractDocumentFactory<T>- Throws:
XmlException
-
parse
Decodes and parses the givenInputStreamas XML.Use the options parameter to specify the following:
To specify this Use this method The character encoding to use when parsing or writing a document. XmlOptions.setCharacterEncoding(java.lang.String)The document type for the root element. XmlOptions.setDocumentType(org.apache.xmlbeans.SchemaType)Place line number annotations in the store when parsing a document. XmlOptions.setLoadLineNumbers()Replace the document element with the specified QName when parsing. XmlOptions.setLoadReplaceDocumentElement(javax.xml.namespace.QName)Strip all insignificant whitespace when parsing a document. XmlOptions.setLoadStripWhitespace()Strip all comments when parsing a document. XmlOptions.setLoadStripComments()Strip all processing instructions when parsing a document. XmlOptions.setLoadStripProcinsts()Set a map of namespace URI substitutions to use when parsing a document. XmlOptions.setLoadSubstituteNamespaces(java.util.Map<java.lang.String, java.lang.String>)Set additional namespace mappings to be added when parsing a document. XmlOptions.setLoadAdditionalNamespaces(java.util.Map<java.lang.String, java.lang.String>)Trim the underlying XML text buffer immediately after parsing a document, resulting in a smaller memory footprint. XmlOptions.setLoadTrimTextBuffer()- Overrides:
parsein classAbstractDocumentFactory<T>- Throws:
XmlExceptionIOException
-
parse
Parses the givenXMLStreamReaderas XML.- Overrides:
parsein classAbstractDocumentFactory<T>- Throws:
XmlException
-
parse
Parses the givenReaderas XML.- Overrides:
parsein classAbstractDocumentFactory<T>- Throws:
XmlExceptionIOException
-
parse
Parses the givenReaderas XML.- Overrides:
parsein classAbstractDocumentFactory<T>- Throws:
XmlExceptionIOException
-
parse
Converts the given DOMNodeinto an XmlObject.- Overrides:
parsein classAbstractDocumentFactory<T>- Throws:
XmlException
-
parse
Converts the given DOMNodeinto an XmlObject.- Overrides:
parsein classAbstractDocumentFactory<T>- Throws:
XmlException
-
newXmlSaxHandler
Returns anXmlSaxHandlerthat can load an XmlObject from SAX events. -
newXmlSaxHandler
Returns anXmlSaxHandlerthat can load an XmlObject from SAX events. -
newDomImplementation
Creates a new DOMImplementation object -
newDomImplementation
Creates a new DOMImplementation object, taking options