Package net.sf.saxon.dom
Class DocumentBuilderImpl
- java.lang.Object
-
- javax.xml.parsers.DocumentBuilder
-
- net.sf.saxon.dom.DocumentBuilderImpl
-
public class DocumentBuilderImpl extends javax.xml.parsers.DocumentBuilderThis class implements the JAXP DocumentBuilder interface, allowing a Saxon TinyTree to be constructed using standard JAXP parsing interfaces. Note that although the TinyTree implements the DOM interfaces, it is read-only, and all attempts to update it will throw an exception. No schema or DTD validation is carried out on the document.
-
-
Constructor Summary
Constructors Constructor Description DocumentBuilderImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigurationgetConfiguration()Get the Saxon Configuration to be used by the document builder.org.w3c.dom.DOMImplementationgetDOMImplementation()Obtain an instance of aDOMImplementationobject.booleanisNamespaceAware()Indicates whether or not this document builder is configured to understand namespaces.booleanisValidating()Indicates whether or not this document builder is configured to validate XML documents against a DTD.org.w3c.dom.DocumentnewDocument()Create a new Document Node.org.w3c.dom.Documentparse(org.xml.sax.InputSource in)Parse the content of the given input source as an XML document and return a new DOMDocumentobject.voidsetConfiguration(Configuration config)Set the Saxon Configuration to be used by the document builder.voidsetEntityResolver(org.xml.sax.EntityResolver er)Specify theEntityResolverto be used to resolve entities present in the XML document to be parsed.voidsetErrorHandler(org.xml.sax.ErrorHandler eh)Specify theErrorHandlerto be used by the parser.
-
-
-
Method Detail
-
setConfiguration
public void setConfiguration(Configuration config)
Set the Saxon Configuration to be used by the document builder. This non-JAXP method must be called if the resulting document is to be used within a Saxon query or transformation. If no Configuration is supplied, Saxon creates a Configuration on the first call to theparse(org.xml.sax.InputSource)method, and subsequent calls reuse the same Configuration.- Since:
- Saxon 8.8
-
getConfiguration
public Configuration getConfiguration()
Get the Saxon Configuration to be used by the document builder. This is a non-JAXP method.- Returns:
- the Configuration previously supplied to
setConfiguration(net.sf.saxon.Configuration), or the Configuration created automatically by Saxon on the first call to theparse(org.xml.sax.InputSource)method, or null if no Configuration has been supplied and theparse(org.xml.sax.InputSource)method has not been called. - Since:
- Saxon 8.8
-
isNamespaceAware
public boolean isNamespaceAware()
Indicates whether or not this document builder is configured to understand namespaces.- Specified by:
isNamespaceAwarein classjavax.xml.parsers.DocumentBuilder- Returns:
- true if this document builder is configured to understand namespaces. This implementation always returns true.
-
isValidating
public boolean isValidating()
Indicates whether or not this document builder is configured to validate XML documents against a DTD.- Specified by:
isValidatingin classjavax.xml.parsers.DocumentBuilder- Returns:
- true if this parser is configured to validate XML documents against a DTD; false otherwise. This implementation always returns false.
-
newDocument
public org.w3c.dom.Document newDocument()
Create a new Document Node.- Specified by:
newDocumentin classjavax.xml.parsers.DocumentBuilder- Returns:
- a new Document Node. The returned document will be of little use, because it is immutable. But it can be used in a DOMResult as the result of a transformation
-
parse
public org.w3c.dom.Document parse(org.xml.sax.InputSource in) throws org.xml.sax.SAXExceptionParse the content of the given input source as an XML document and return a new DOMDocumentobject.Note: for this document to be usable as part of a Saxon query or transformation, the document should be built within the
Configurationin which that query or transformation is running. This can be achieved using the non-JAXPsetConfiguration(net.sf.saxon.Configuration)method.- Specified by:
parsein classjavax.xml.parsers.DocumentBuilder- Parameters:
in- InputSource containing the content to be parsed. Note that if an EntityResolver or ErrorHandler has been supplied, then the XMLReader contained in this InputSource will be modified to register this EntityResolver or ErrorHandler, replacing any that was previously registered.- Returns:
- A new DOM Document object.
- Throws:
org.xml.sax.SAXException- If any parse errors occur.
-
setEntityResolver
public void setEntityResolver(org.xml.sax.EntityResolver er)
Specify theEntityResolverto be used to resolve entities present in the XML document to be parsed. Setting this tonullwill result in the underlying implementation using the EntityResolver registered with the XMLReader contained in the InputSource.- Specified by:
setEntityResolverin classjavax.xml.parsers.DocumentBuilder- Parameters:
er- TheEntityResolverto be used to resolve entities present in the XML document to be parsed.
-
setErrorHandler
public void setErrorHandler(org.xml.sax.ErrorHandler eh)
Specify theErrorHandlerto be used by the parser. Setting this tonullwill result in the underlying implementation using using the ErrorHandler registered with the XMLReader contained in the InputSource.- Specified by:
setErrorHandlerin classjavax.xml.parsers.DocumentBuilder- Parameters:
eh- TheErrorHandlerto be used by the parser.
-
getDOMImplementation
public org.w3c.dom.DOMImplementation getDOMImplementation()
Obtain an instance of aDOMImplementationobject.- Specified by:
getDOMImplementationin classjavax.xml.parsers.DocumentBuilder- Returns:
- A new instance of a
DOMImplementation.
-
-