|
|||||||||
| Home >> All >> gnu >> xml >> dom >> [ ls overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
gnu.xml.dom.ls
Class DomLSParser

java.lang.Objectgnu.xml.dom.ls.DomLSParser
- All Implemented Interfaces:
- org.w3c.dom.DOMConfiguration, org.w3c.dom.DOMStringList, org.xml.sax.ErrorHandler, org.w3c.dom.ls.LSParser
- public class DomLSParser
- extends java.lang.Object
- implements org.w3c.dom.ls.LSParser, org.w3c.dom.DOMConfiguration, org.w3c.dom.DOMStringList, org.xml.sax.ErrorHandler
- extends java.lang.Object
Parser implementation for GNU DOM.
| Field Summary | |
private boolean |
async
|
private boolean |
coalescing
|
private org.xml.sax.EntityResolver |
entityResolver
|
private org.xml.sax.ErrorHandler |
errorHandler
|
private SAXEventSink |
eventSink
|
private boolean |
expandEntityReferences
|
private javax.xml.parsers.SAXParserFactory |
factory
|
private org.w3c.dom.ls.LSParserFilter |
filter
|
private boolean |
ignoreComments
|
private boolean |
ignoreWhitespace
|
private boolean |
namespaceAware
|
private org.xml.sax.XMLReader |
reader
|
private java.lang.String |
schemaType
|
private static java.util.List |
SUPPORTED_PARAMETERS
|
private boolean |
validating
|
private boolean |
xIncludeAware
|
| Fields inherited from interface org.w3c.dom.ls.LSParser |
ACTION_APPEND_AS_CHILDREN, ACTION_INSERT_AFTER, ACTION_INSERT_BEFORE, ACTION_REPLACE, ACTION_REPLACE_CHILDREN |
| Constructor Summary | |
DomLSParser(short mode,
java.lang.String schemaType)
|
|
| Method Summary | |
void |
abort()
Abort the loading of the document that is currently being loaded by the LSParser. |
boolean |
canSetParameter(java.lang.String name,
java.lang.Object value)
Check if setting a parameter to a specific value is supported. |
boolean |
contains(java.lang.String str)
Test if a string is part of this DOMStringList. |
private org.w3c.dom.Document |
doParse(org.w3c.dom.ls.LSInput input)
|
void |
error(org.xml.sax.SAXParseException e)
Receive notification of a recoverable error. |
void |
fatalError(org.xml.sax.SAXParseException e)
Receive notification of a non-recoverable error. |
boolean |
getAsync()
true if the LSParser is asynchronous,
false if it is synchronous. |
boolean |
getBusy()
true if the LSParser is currently busy
loading a document, otherwise false. |
org.w3c.dom.DOMConfiguration |
getDomConfig()
The DOMConfiguration object used when parsing an input
source. |
org.w3c.dom.ls.LSParserFilter |
getFilter()
When a filter is provided, the implementation will call out to the filter as it is constructing the DOM tree structure. |
private org.xml.sax.InputSource |
getInputSource(org.w3c.dom.ls.LSInput input)
|
int |
getLength()
The number of DOMStrings in the list. |
java.lang.Object |
getParameter(java.lang.String name)
Return the value of a parameter if known. |
org.w3c.dom.DOMStringList |
getParameterNames()
The list of the parameters supported by this DOMConfiguration object and for which at least one value
can be set by the application. |
private org.xml.sax.XMLReader |
getXMLReader()
|
java.lang.String |
item(int i)
Returns the indexth item in the collection. |
org.w3c.dom.Document |
parse(org.w3c.dom.ls.LSInput input)
Parse an XML document from a resource identified by a LSInput. |
org.w3c.dom.Document |
parseURI(java.lang.String uri)
Parse an XML document from a location identified by a URI reference [IETF RFC 2396]. |
org.w3c.dom.Node |
parseWithContext(org.w3c.dom.ls.LSInput input,
org.w3c.dom.Node context,
short action)
Parse an XML fragment from a resource identified by a LSInput and insert the content into an existing document
at the position specified with the context and
action arguments. |
void |
setFilter(org.w3c.dom.ls.LSParserFilter filter)
When a filter is provided, the implementation will call out to the filter as it is constructing the DOM tree structure. |
void |
setParameter(java.lang.String name,
java.lang.Object value)
Set the value of a parameter. |
void |
warning(org.xml.sax.SAXParseException e)
Receive notification of a warning. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
SUPPORTED_PARAMETERS
private static final java.util.List SUPPORTED_PARAMETERS
filter
private org.w3c.dom.ls.LSParserFilter filter
async
private final boolean async
schemaType
private java.lang.String schemaType
eventSink
private SAXEventSink eventSink
factory
private javax.xml.parsers.SAXParserFactory factory
reader
private org.xml.sax.XMLReader reader
namespaceAware
private boolean namespaceAware
ignoreWhitespace
private boolean ignoreWhitespace
expandEntityReferences
private boolean expandEntityReferences
ignoreComments
private boolean ignoreComments
coalescing
private boolean coalescing
validating
private boolean validating
xIncludeAware
private boolean xIncludeAware
entityResolver
private org.xml.sax.EntityResolver entityResolver
errorHandler
private org.xml.sax.ErrorHandler errorHandler
| Constructor Detail |
DomLSParser
public DomLSParser(short mode,
java.lang.String schemaType)
throws org.w3c.dom.DOMException
| Method Detail |
getDomConfig
public org.w3c.dom.DOMConfiguration getDomConfig()
- Description copied from interface:
org.w3c.dom.ls.LSParser - The
DOMConfigurationobject used when parsing an input source. ThisDOMConfigurationis specific to the parse operation. No parameter values from thisDOMConfigurationobject are passed automatically to theDOMConfigurationobject on theDocumentthat is created, or used, by the parse operation. The DOM application is responsible for passing any needed parameter values from thisDOMConfigurationobject to theDOMConfigurationobject referenced by theDocumentobject.
In addition to the parameters recognized in on the DOMConfiguration interface defined in [DOM Level 3 Core] , theDOMConfigurationobjects forLSParseradd or modify the following parameters:-
"charset-overrides-xml-encoding" -
true- [optional] (default) If a higher level protocol such as HTTP [IETF RFC 2616] provides an
indication of the character encoding of the input stream being
processed, that will override any encoding specified in the XML
declaration or the Text declaration (see also section 4.3.3,
"Character Encoding in Entities", in [XML 1.0]).
Explicitly setting an encoding in the
LSInputoverrides any encoding from the protocol. false- [required] The parser ignores any character set encoding information from higher-level protocols.
"disallow-doctype"-
-
true - [optional] Throw a fatal "doctype-not-allowed" error if a doctype node is found while parsing the document. This is useful when dealing with things like SOAP envelopes where doctype nodes are not allowed.
false- [required] (default) Allow doctype nodes in the document.
-
-
"ignore-unknown-character-denormalizations" -
-
true - [required] (default) If, while verifying full normalization when [XML 1.1] is supported, a processor encounters characters for which it cannot determine the normalization properties, then the processor will ignore any possible denormalizations caused by these characters. This parameter is ignored for [XML 1.0].
-
false - [optional] Report an fatal "unknown-character-denormalization" error if a character is encountered for which the processor cannot determine the normalization properties.
-
"infoset"- See
the definition of
DOMConfigurationfor a description of this parameter. Unlike in [DOM Level 3 Core] , this parameter will default totrueforLSParser. "namespaces"-
true- [required] (default) Perform the namespace processing as defined in [XML Namespaces] and [XML Namespaces 1.1] .
false- [optional] Do not perform the namespace processing.
-
"resource-resolver" - [required] A reference to a
LSResourceResolverobject, or null. If the value of this parameter is not null when an external resource (such as an external XML entity or an XML schema location) is encountered, the implementation will request that theLSResourceResolverreferenced in this parameter resolves the resource. "supported-media-types-only"-
-
true - [optional] Check that the media type of the parsed resource is a supported media type. If an unsupported media type is encountered, a fatal error of type "unsupported-media-type" will be raised. The media types defined in [IETF RFC 3023] must always be accepted.
false- [required] (default) Accept any media type.
-
"validate"- See the definition of
DOMConfigurationfor a description of this parameter. Unlike in [DOM Level 3 Core] , the processing of the internal subset is always accomplished, even if this parameter is set tofalse. -
"validate-if-schema" - See the definition of
DOMConfigurationfor a description of this parameter. Unlike in [DOM Level 3 Core] , the processing of the internal subset is always accomplished, even if this parameter is set tofalse. -
"well-formed" - See the definition of
DOMConfigurationfor a description of this parameter. Unlike in [DOM Level 3 Core] , this parameter cannot be set tofalse.
- Specified by:
getDomConfigin interfaceorg.w3c.dom.ls.LSParser
-
getFilter
public org.w3c.dom.ls.LSParserFilter getFilter()
- Description copied from interface:
org.w3c.dom.ls.LSParser - When a filter is provided, the implementation will call out to the
filter as it is constructing the DOM tree structure. The filter can
choose to remove elements from the document being constructed, or to
terminate the parsing early.
The filter is invoked after the operations requested by theDOMConfigurationparameters have been applied. For example, if " validate" is set totrue, the validation is done before invoking the filter.- Specified by:
getFilterin interfaceorg.w3c.dom.ls.LSParser
setFilter
public void setFilter(org.w3c.dom.ls.LSParserFilter filter)
- Description copied from interface:
org.w3c.dom.ls.LSParser - When a filter is provided, the implementation will call out to the
filter as it is constructing the DOM tree structure. The filter can
choose to remove elements from the document being constructed, or to
terminate the parsing early.
The filter is invoked after the operations requested by theDOMConfigurationparameters have been applied. For example, if " validate" is set totrue, the validation is done before invoking the filter.- Specified by:
setFilterin interfaceorg.w3c.dom.ls.LSParser
getAsync
public boolean getAsync()
- Description copied from interface:
org.w3c.dom.ls.LSParser trueif theLSParseris asynchronous,falseif it is synchronous.- Specified by:
getAsyncin interfaceorg.w3c.dom.ls.LSParser
getBusy
public boolean getBusy()
- Description copied from interface:
org.w3c.dom.ls.LSParser trueif theLSParseris currently busy loading a document, otherwisefalse.- Specified by:
getBusyin interfaceorg.w3c.dom.ls.LSParser
parse
public org.w3c.dom.Document parse(org.w3c.dom.ls.LSInput input) throws org.w3c.dom.DOMException, org.w3c.dom.ls.LSException
- Description copied from interface:
org.w3c.dom.ls.LSParser - Parse an XML document from a resource identified by a
LSInput.- Specified by:
parsein interfaceorg.w3c.dom.ls.LSParser
parseURI
public org.w3c.dom.Document parseURI(java.lang.String uri) throws org.w3c.dom.DOMException, org.w3c.dom.ls.LSException
- Description copied from interface:
org.w3c.dom.ls.LSParser - Parse an XML document from a location identified by a URI reference [IETF RFC 2396]. If the URI
contains a fragment identifier (see section 4.1 in [IETF RFC 2396]), the
behavior is not defined by this specification, future versions of
this specification may define the behavior.
- Specified by:
parseURIin interfaceorg.w3c.dom.ls.LSParser
parseWithContext
public org.w3c.dom.Node parseWithContext(org.w3c.dom.ls.LSInput input, org.w3c.dom.Node context, short action) throws org.w3c.dom.DOMException, org.w3c.dom.ls.LSException
- Description copied from interface:
org.w3c.dom.ls.LSParser - Parse an XML fragment from a resource identified by a
LSInputand insert the content into an existing document at the position specified with thecontextandactionarguments. When parsing the input stream, the context node (or its parent, depending on where the result will be inserted) is used for resolving unbound namespace prefixes. The context node'sownerDocumentnode (or the node itself if the node of typeDOCUMENT_NODE) is used to resolve default attributes and entity references.
As the new data is inserted into the document, at least one mutation event is fired per new immediate child or sibling of the context node.
If the context node is aDocumentnode and the action isACTION_REPLACE_CHILDREN, then the document that is passed as the context node will be changed such that itsxmlEncoding,documentURI,xmlVersion,inputEncoding,xmlStandalone, and all other such attributes are set to what they would be set to if the input source was parsed usingLSParser.parse().
This method is always synchronous, even if theLSParseris asynchronous (LSParser.asyncistrue).
If an error occurs while parsing, the caller is notified through theErrorHandlerinstance associated with the " error-handler" parameter of theDOMConfiguration.
When callingparseWithContext, the values of the following configuration parameters will be ignored and their default values will always be used instead: " validate", " validate-if-schema", and " element-content-whitespace". Other parameters will be treated normally, and the parser is expected to call theLSParserFilterjust as if a whole document was parsed.- Specified by:
parseWithContextin interfaceorg.w3c.dom.ls.LSParser
abort
public void abort()
- Description copied from interface:
org.w3c.dom.ls.LSParser - Abort the loading of the document that is currently being loaded by
the
LSParser. If theLSParseris currently not busy, a call to this method does nothing.- Specified by:
abortin interfaceorg.w3c.dom.ls.LSParser
doParse
private org.w3c.dom.Document doParse(org.w3c.dom.ls.LSInput input) throws org.w3c.dom.DOMException, org.w3c.dom.ls.LSException
getXMLReader
private org.xml.sax.XMLReader getXMLReader() throws org.w3c.dom.ls.LSException
getInputSource
private org.xml.sax.InputSource getInputSource(org.w3c.dom.ls.LSInput input) throws org.w3c.dom.ls.LSException
setParameter
public void setParameter(java.lang.String name, java.lang.Object value) throws org.w3c.dom.DOMException
- Description copied from interface:
org.w3c.dom.DOMConfiguration - Set the value of a parameter.
- Specified by:
setParameterin interfaceorg.w3c.dom.DOMConfiguration
getParameter
public java.lang.Object getParameter(java.lang.String name) throws org.w3c.dom.DOMException
- Description copied from interface:
org.w3c.dom.DOMConfiguration - Return the value of a parameter if known.
- Specified by:
getParameterin interfaceorg.w3c.dom.DOMConfiguration
canSetParameter
public boolean canSetParameter(java.lang.String name, java.lang.Object value)
- Description copied from interface:
org.w3c.dom.DOMConfiguration - Check if setting a parameter to a specific value is supported.
- Specified by:
canSetParameterin interfaceorg.w3c.dom.DOMConfiguration
getParameterNames
public org.w3c.dom.DOMStringList getParameterNames()
- Description copied from interface:
org.w3c.dom.DOMConfiguration - The list of the parameters supported by this
DOMConfigurationobject and for which at least one value can be set by the application. Note that this list can also contain parameter names defined outside this specification.- Specified by:
getParameterNamesin interfaceorg.w3c.dom.DOMConfiguration
item
public java.lang.String item(int i)
- Description copied from interface:
org.w3c.dom.DOMStringList - Returns the
indexth item in the collection. Ifindexis greater than or equal to the number ofDOMStrings in the list, this returnsnull.- Specified by:
itemin interfaceorg.w3c.dom.DOMStringList
getLength
public int getLength()
- Description copied from interface:
org.w3c.dom.DOMStringList - The number of
DOMStrings in the list. The range of valid child node indices is 0 tolength-1inclusive.- Specified by:
getLengthin interfaceorg.w3c.dom.DOMStringList
contains
public boolean contains(java.lang.String str)
- Description copied from interface:
org.w3c.dom.DOMStringList - Test if a string is part of this
DOMStringList.- Specified by:
containsin interfaceorg.w3c.dom.DOMStringList
warning
public void warning(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ErrorHandler - Receive notification of a warning.
SAX parsers will use this method to report conditions that are not errors or fatal errors as defined by the XML recommendation. The default behaviour is to take no action.
The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end.
Filters may use this method to report other, non-XML warnings as well.
- Specified by:
warningin interfaceorg.xml.sax.ErrorHandler
error
public void error(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ErrorHandler - Receive notification of a recoverable error.
This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a validating parser would use this callback to report the violation of a validity constraint. The default behaviour is to take no action.
The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end. If the application cannot do so, then the parser should report a fatal error even if the XML recommendation does not require it to do so.
Filters may use this method to report other, non-XML errors as well.
- Specified by:
errorin interfaceorg.xml.sax.ErrorHandler
fatalError
public void fatalError(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException
- Description copied from interface:
org.xml.sax.ErrorHandler - Receive notification of a non-recoverable error.
There is an apparent contradiction between the documentation for this method and the documentation for ContentHandler.endDocument()>
ContentHandler.endDocument()55 . Until this ambiguity is resolved in a future major release, clients should make no assumptions about whether endDocument() will or will not be invoked when the parser has reported a fatalError() or thrown an exception.This corresponds to the definition of "fatal error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a parser would use this callback to report the violation of a well-formedness constraint.
The application must assume that the document is unusable after the parser has invoked this method, and should continue (if at all) only for the sake of collecting additional error messages: in fact, SAX parsers are free to stop reporting any other events once this method has been invoked.
- Specified by:
fatalErrorin interfaceorg.xml.sax.ErrorHandler
|
|||||||||
| Home >> All >> gnu >> xml >> dom >> [ ls overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
gnu.xml.dom.ls.DomLSParser