public class DocumentBuilderImpl extends DocumentBuilder
Constructor and Description |
---|
DocumentBuilderImpl() |
Modifier and Type | Method and Description |
---|---|
Configuration |
getConfiguration()
Get the Saxon Configuration to be used by the document builder.
|
DOMImplementation |
getDOMImplementation()
Obtain an instance of a
DOMImplementation object. |
ParseOptions |
getParseOptions()
Get the XML parsing options that have been set using setParseOptions and other setter methods
|
int |
getStripSpace()
Get the space-stripping action to be applied to the source document
|
boolean |
isNamespaceAware()
Indicates whether or not this document builder is configured to
understand namespaces.
|
boolean |
isValidating()
Indicates whether or not this document builder is configured to
validate XML documents against a DTD.
|
boolean |
isXIncludeAware()
Get the XInclude processing mode for this parser.
|
Document |
newDocument()
Create a new Document Node.
|
Document |
parse(File f)
Parse the content of the given file as an XML document
and return a new DOM
Document object. |
Document |
parse(InputSource in)
Deprecated.
since 9.3. The DOM created by this class is a DOM wrapper around
(typically) a Saxon Tiny Tree. There is little point in constructing such
an object. If the tree is primarily for use by Saxon XSLT and XQuery, it is
better to construct a Tiny Tree directly and omit the DOM wrapper; if it is
primarily for other DOM applications, it is better to construct a fully-
functional DOM using (for example) Apache Xerces.
|
void |
setConfiguration(Configuration config)
Set the Saxon Configuration to be used by the document builder.
|
void |
setEntityResolver(EntityResolver er)
Specify the
EntityResolver to be used to resolve
entities present in the XML document to be parsed. |
void |
setErrorHandler(ErrorHandler eh)
Specify the
ErrorHandler to be used by the parser. |
void |
setParseOptions(ParseOptions options)
Set the XML parsing options to be used
|
void |
setStripSpace(int stripAction)
Set the space-stripping action to be applied to the source document
|
void |
setValidating(boolean state)
Determine whether the document builder should perform DTD validation
|
void |
setXIncludeAware(boolean state)
Set state of XInclude processing.
|
public void setConfiguration(Configuration config)
parse(org.xml.sax.InputSource)
method,
and subsequent calls reuse the same Configuration.
As an alternative to calling this method, a Configuration can be supplied by calling
setAttribute(FeatureKeys.CONFIGURATION, config)
on the DocumentBuilderFactory
object, where config
can be obtained by calling
getAttribute(FeatureKeys.CONFIGURATION)
on the TransformerFactory
.
config
- the Saxon configurationpublic Configuration getConfiguration()
setConfiguration(net.sf.saxon.Configuration)
,
or the Configuration created automatically by Saxon on the first call to the
parse(org.xml.sax.InputSource)
method, or a newly constructed Configuration if no Configuration has been supplied and
the parse(org.xml.sax.InputSource)
method has not been called.public boolean isNamespaceAware()
isNamespaceAware
in class DocumentBuilder
public void setValidating(boolean state)
state
- set to true to request DTD validationpublic boolean isValidating()
isValidating
in class DocumentBuilder
public Document newDocument()
newDocument
in class DocumentBuilder
UnsupportedOperationException
- (always). The only way to build a document using this DocumentBuilder
implementation is by using the parse() method.public Document parse(InputSource in) throws SAXException
Document
object.
Note: for this document to be usable as part of a Saxon query or transformation,
the document should be built within the Configuration
in which that query
or transformation is running. This can be achieved using the non-JAXP
setConfiguration(net.sf.saxon.Configuration)
method.
parse
in class DocumentBuilder
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.SAXException
- If any parse errors occur.public Document parse(File f) throws SAXException, IOException
Document
object.
An IllegalArgumentException
is thrown if the
File
is null
null.
This implementation differs from the parent implementation by using a correct algorithm for filename-to-uri conversion.
parse
in class DocumentBuilder
f
- The file containing the XML to parse.IOException
- If any IO errors occur.SAXException
- If any parse errors occur.public void setEntityResolver(EntityResolver er)
EntityResolver
to be used to resolve
entities present in the XML document to be parsed.setEntityResolver
in class DocumentBuilder
er
- The EntityResolver
to be used to resolve entities
present in the XML document to be parsed.public void setErrorHandler(ErrorHandler eh)
ErrorHandler
to be used by the parser.setErrorHandler
in class DocumentBuilder
eh
- The ErrorHandler
to be used by the parser.public DOMImplementation getDOMImplementation()
DOMImplementation
object.getDOMImplementation
in class DocumentBuilder
DOMImplementation
.public void setXIncludeAware(boolean state)
Set state of XInclude processing.
If XInclude markup is found in the document instance, should it be processed as specified in XML Inclusions (XInclude) Version 1.0.
XInclude processing defaults to false
.
state
- Set XInclude processing to true
or
false
public boolean isXIncludeAware()
Get the XInclude processing mode for this parser.
isXIncludeAware
in class DocumentBuilder
DocumentBuilderFactory.isXIncludeAware()
when this parser was created from factory.UnsupportedOperationException
- For backward compatibility, when implementations for
earlier versions of JAXP is used, this exception will be
thrown.DocumentBuilderFactory.setXIncludeAware(boolean)
public void setStripSpace(int stripAction)
stripAction
- one of Whitespace.IGNORABLE
,
Whitespace.ALL
, or Whitespace.NONE
public int getStripSpace()
Whitespace.IGNORABLE
,
Whitespace.ALL
, or Whitespace.NONE
public void setParseOptions(ParseOptions options)
options
- the XML parsing options. Options set using this method will override any options previously set
using other methods; options subsequently set using other methods will modify the parseOptions
object supplied using this methodpublic ParseOptions getParseOptions()
Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.