Package org.apache.xmlbeans
Class XmlObject.Factory
- java.lang.Object
-
- org.apache.xmlbeans.XmlObject.Factory
-
- Enclosing interface:
- XmlObject
public static final class XmlObject.Factory extends java.lang.Object
Static 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.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static org.w3c.dom.DOMImplementation
newDomImplementation()
Creates a new DOMImplementation objectstatic org.w3c.dom.DOMImplementation
newDomImplementation(XmlOptions options)
Creates a new DOMImplementation object, taking optionsstatic XmlObject
newInstance()
Creates a new, completely empty instance.static XmlObject
newInstance(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.static XMLInputStream
newValidatingXMLInputStream(XMLInputStream xis)
Deprecated.XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.static XMLInputStream
newValidatingXMLInputStream(XMLInputStream xis, XmlOptions options)
Deprecated.XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.static XmlObject
newValue(java.lang.Object obj)
Creates an immutableXmlObject
valuestatic XmlSaxHandler
newXmlSaxHandler()
Returns anXmlSaxHandler
that can load an XmlObject from SAX events.static XmlSaxHandler
newXmlSaxHandler(XmlOptions options)
Returns anXmlSaxHandler
that can load an XmlObject from SAX events.static XmlObject
parse(java.io.File file)
Parses the givenFile
as XML.static XmlObject
parse(java.io.File file, XmlOptions options)
Parses the givenFile
as XML.static XmlObject
parse(java.io.InputStream is)
Decodes and parses the givenInputStream
as XML.static XmlObject
parse(java.io.InputStream is, XmlOptions options)
Decodes and parses the givenInputStream
as XML.static XmlObject
parse(java.io.Reader r)
Parses the givenReader
as XML.static XmlObject
parse(java.io.Reader r, XmlOptions options)
Parses the givenReader
as XML.static XmlObject
parse(java.lang.String xmlAsString)
Parses the givenString
as XML.static XmlObject
parse(java.lang.String xmlAsString, XmlOptions options)
Parses the givenString
as XML.static XmlObject
parse(java.net.URL u)
Downloads the givenURL
as XML.static XmlObject
parse(java.net.URL u, XmlOptions options)
Downloads the givenURL
as XML.static XmlObject
parse(javax.xml.stream.XMLStreamReader xsr)
Decodes and parses the givenXMLStreamReader
as XML.static XmlObject
parse(javax.xml.stream.XMLStreamReader xsr, XmlOptions options)
Parses the givenXMLStreamReader
as XML.static XmlObject
parse(XMLInputStream xis)
Deprecated.XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.static XmlObject
parse(XMLInputStream xis, XmlOptions options)
Deprecated.XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.static XmlObject
parse(org.w3c.dom.Node node)
Converts the given DOMNode
into an XmlObject.static XmlObject
parse(org.w3c.dom.Node node, XmlOptions options)
Converts the given DOMNode
into an XmlObject.
-
-
-
Method Detail
-
newInstance
public static XmlObject newInstance()
Creates a new, completely empty instance.
-
newInstance
public static XmlObject newInstance(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.
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()
- Parameters:
options
- Options specifying root document type and/or value facet checking.- Returns:
- A new, empty instance of XmlObject.
-
-
newValue
public static XmlObject newValue(java.lang.Object obj)
Creates an immutableXmlObject
value
-
parse
public static XmlObject parse(java.lang.String xmlAsString) throws XmlException
Parses the givenString
as XML.- Throws:
XmlException
-
parse
public static XmlObject parse(java.lang.String xmlAsString, XmlOptions options) throws XmlException
Parses the givenString
as 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)
Additional namespace mappings to be added when parsing a document. XmlOptions.setLoadAdditionalNamespaces(java.util.Map)
To trim the underlying XML text buffer immediately after parsing a document, resulting in a smaller memory footprint. XmlOptions.setLoadTrimTextBuffer()
- Parameters:
xmlAsString
- The string to parse.options
- Options as specified.- Returns:
- A new instance containing the specified XML.
- Throws:
XmlException
-
parse
public static XmlObject parse(java.io.File file) throws XmlException, java.io.IOException
Parses the givenFile
as XML.- Throws:
XmlException
java.io.IOException
-
parse
public static XmlObject parse(java.io.File file, XmlOptions options) throws XmlException, java.io.IOException
Parses the givenFile
as XML.- Throws:
XmlException
java.io.IOException
-
parse
public static XmlObject parse(java.net.URL u) throws XmlException, java.io.IOException
Downloads the givenURL
as XML.- Throws:
XmlException
java.io.IOException
-
parse
public static XmlObject parse(java.net.URL u, XmlOptions options) throws XmlException, java.io.IOException
Downloads the givenURL
as XML.- Throws:
XmlException
java.io.IOException
-
parse
public static XmlObject parse(java.io.InputStream is) throws XmlException, java.io.IOException
Decodes and parses the givenInputStream
as XML.- Throws:
XmlException
java.io.IOException
-
parse
public static XmlObject parse(javax.xml.stream.XMLStreamReader xsr) throws XmlException
Decodes and parses the givenXMLStreamReader
as XML.- Throws:
XmlException
-
parse
public static XmlObject parse(java.io.InputStream is, XmlOptions options) throws XmlException, java.io.IOException
Decodes and parses the givenInputStream
as 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)
Set additional namespace mappings to be added when parsing a document. XmlOptions.setLoadAdditionalNamespaces(java.util.Map)
Trim the underlying XML text buffer immediately after parsing a document, resulting in a smaller memory footprint. XmlOptions.setLoadTrimTextBuffer()
- Throws:
XmlException
java.io.IOException
-
parse
public static XmlObject parse(javax.xml.stream.XMLStreamReader xsr, XmlOptions options) throws XmlException
Parses the givenXMLStreamReader
as XML.- Throws:
XmlException
-
parse
public static XmlObject parse(java.io.Reader r) throws XmlException, java.io.IOException
Parses the givenReader
as XML.- Throws:
XmlException
java.io.IOException
-
parse
public static XmlObject parse(java.io.Reader r, XmlOptions options) throws XmlException, java.io.IOException
Parses the givenReader
as XML.- Throws:
XmlException
java.io.IOException
-
parse
public static XmlObject parse(org.w3c.dom.Node node) throws XmlException
Converts the given DOMNode
into an XmlObject.- Throws:
XmlException
-
parse
public static XmlObject parse(org.w3c.dom.Node node, XmlOptions options) throws XmlException
Converts the given DOMNode
into an XmlObject.- Throws:
XmlException
-
parse
public static XmlObject parse(XMLInputStream xis) throws XmlException, XMLStreamException
Deprecated.XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.Loads the givenXMLInputStream
into an XmlObject.- Throws:
XmlException
XMLStreamException
-
parse
public static XmlObject parse(XMLInputStream xis, XmlOptions options) throws XmlException, XMLStreamException
Deprecated.XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.Loads the givenXMLInputStream
into an XmlObject.- Throws:
XmlException
XMLStreamException
-
newXmlSaxHandler
public static XmlSaxHandler newXmlSaxHandler()
Returns anXmlSaxHandler
that can load an XmlObject from SAX events.
-
newXmlSaxHandler
public static XmlSaxHandler newXmlSaxHandler(XmlOptions options)
Returns anXmlSaxHandler
that can load an XmlObject from SAX events.
-
newDomImplementation
public static org.w3c.dom.DOMImplementation newDomImplementation()
Creates a new DOMImplementation object
-
newDomImplementation
public static org.w3c.dom.DOMImplementation newDomImplementation(XmlOptions options)
Creates a new DOMImplementation object, taking options
-
newValidatingXMLInputStream
public static XMLInputStream newValidatingXMLInputStream(XMLInputStream xis) throws XmlException, XMLStreamException
Deprecated.XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.Returns a new validatingXMLInputStream
that throws exceptions when the input is not valid.- Throws:
XmlException
XMLStreamException
-
newValidatingXMLInputStream
public static XMLInputStream newValidatingXMLInputStream(XMLInputStream xis, XmlOptions options) throws XmlException, XMLStreamException
Deprecated.XMLInputStream was deprecated by XMLStreamReader from STaX - jsr173 API.Returns a new validatingXMLInputStream
that throws exceptions when the input is not valid, specifying options for the root element's document type and/or the collection object to use as an error listener while validating.Use the options parameter to specify the following:
- A collection instance that should be used as an error listener during
compilation, as described in
XmlOptions.setErrorListener(java.util.Collection)
. - The document type for the root element, as described in
XmlOptions.setDocumentType(SchemaType)
.
- Parameters:
xis
- The basis for the new XMLInputStream.options
- Options specifying root document type and/or an error listener.- Returns:
- A new validating XMLInputStream.
- Throws:
XmlException
XMLStreamException
- A collection instance that should be used as an error listener during
compilation, as described in
-