public abstract class XMLParser
extends java.lang.Object
DOMParser
and SAXParser
classes. It contains methods to parse eXtensible Markup Language (XML) 1.0 documents according to the World Wide Web Consortium (W3C) recommendation. This class can not be instantiated (applications may use the DOM or SAX parser depending on their requirements).Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BASE_URL
Base URL used in parsing entities.
|
static int |
BASE_URL_ID |
static java.lang.String |
CONTENT_MODEL_DETERMINISTIC
Deprecated.
Replaced by XDK_FEATURE_CONTENT_MODEL_DETERMINISTIC.
|
static int |
DEFAULT_ENTITY_EXPANSION_DEPTH |
static int |
DEFAULT_ENTITY_EXPANSION_DEPTH_SECURE |
static java.lang.String |
DTD_OBJECT
DTD Object to be used for validation.
|
static int |
DTD_OBJECT_ID |
static java.lang.String |
ENTITY_EXPANSION_DEPTH
Define the depth of entity expansion allowed.
|
static int |
ENTITY_EXPANSION_DEPTH_ID |
static java.lang.String |
EXPAND_ENTITYREF
Expands entities when set to true, else report just the reference
|
static int |
EXPAND_ENTITYREF_ID |
static int |
IGNORE_DUPLICATE_ID |
static java.lang.String |
PARSER |
static java.lang.String |
PARSER_CDATA |
static java.lang.String |
PARSER_DTD |
static java.lang.String |
RESOLVE_ENTITY_DEFAULT
Resolve external entities when set to true, else raise error Can be override by entityResovler
|
static int |
RESOLVE_ENTITY_DEFAULT_ID |
static java.lang.String |
SCHEMA_LANGUAGE |
static int |
SCHEMA_LANGUAGE_ID |
static java.lang.String |
SCHEMA_OBJECT
Schema Object to be used for validation.
|
static int |
SCHEMA_OBJECT_ID |
static java.lang.String |
SCHEMA_SOURCE |
static int |
SCHEMA_SOURCE_ID |
static java.lang.String |
STANDALONE
Sets the standalone property of the input files.
|
static int |
STANDALONE_ID |
static java.lang.String |
USE_DTD_ONLY_FOR_VALIDATION
If true, DTD Object is used only for validation and is not added to the parser document (Boolean.TRUE or Boolean.FALSE) This property/attribute is only if setDoctype is called to use a fixed DTD.
|
static int |
USE_DTD_ONLY_FOR_VALIDATION_ID |
static java.lang.String |
XDK_ATTRIBUTE_ENTITY_EXPANSION_COUNT_LIMIT
Defines the limit on the number of entity expansions.
|
static int |
XDK_ATTRIBUTE_ENTITY_EXPANSION_COUNT_LIMIT_DEFAULT |
static int |
XDK_ATTRIBUTE_ENTITY_EXPANSION_COUNT_LIMIT_ID |
static int |
XDK_ATTRIBUTE_ENTITY_EXPANSION_COUNT_LIMIT_SECURE |
static java.lang.String |
XDK_FEATURE_ALLOW_ILLEGAL_UTF8_ENCODING
This property can be set to true in order to allow the parser to tolerate certain illegal UTF-8 encodings.
|
static int |
XDK_FEATURE_ALLOW_ILLEGAL_UTF8_ENCODING_ID |
static java.lang.String |
XDK_FEATURE_CONTENT_MODEL_DETERMINISTIC
Do not verify if the content model is deterministic if this property is set to false.
|
static int |
XDK_FEATURE_CONTENT_MODEL_DETERMINISTIC_ID |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getAttribute(java.lang.String name)
Allows the user to retrieve specific attributes on the underlying implementation.
|
java.net.URL |
getBaseURL()
Gets the base URL
|
EntityResolver |
getEntityResolver()
Return the current entity resolver.
|
ErrorHandler |
getErrorHandler()
Return the current error handler.
|
static java.lang.String |
getReleaseVersion()
Returns the release version of the Oracle XML Parser
|
boolean |
getValidationMode()
Returns the validation mode
|
int |
getValidationModeValue()
Returns the validation mode
|
java.lang.Object |
getXMLProperty(java.lang.String name)
Get a property.
|
boolean |
isXMLPropertyReadOnly(java.lang.String name)
Check is the property is read-only Returns true if the property is not supported
|
boolean |
isXMLPropertySupported(java.lang.String name)
Check is the property is supported
|
void |
parse(InputSource in)
Parses the XML from given input source
|
void |
parse(java.io.InputStream in)
Parses the XML from given input stream.
|
void |
parse(java.io.Reader r)
Parses the XML from given input stream.
|
void |
parse(java.lang.String in)
Parses the XML from the URL indicated
|
void |
parse(java.net.URL url)
Parses the XML document pointed to by the given URL and creates the corresponding XML document hierarchy.
|
void |
reset()
Resets the parser state
|
void |
setAttribute(int id, java.lang.Object value)
Allows the user to set specific attributes on the underlying implementation.
|
void |
setAttribute(java.lang.String name, java.lang.Object value)
Allows the user to set specific attributes on the underlying implementation.
|
void |
setBaseURL(java.net.URL url)
Set the base URL for loading external enitites and DTDs.
|
void |
setDoctype(DTD dtd)
Set the DTD
|
void |
setEntityResolver(EntityResolver resolver)
Allow an application to register an entity resolver.
|
void |
setErrorHandler(ErrorHandler handler)
Allow an application to register an error event handler.
|
void |
setLocale(java.util.Locale locale)
Applications can use this to set the locale for error reporting.
|
void |
setPreserveWhitespace(boolean flag)
Set the white space preserving mode
|
void |
setSchemaValidationMode(boolean flag)
Deprecated.
Replaced by setValidationMode(int).
|
java.lang.Object |
setSchemaValidatorProperty(java.lang.String name, java.lang.Object value)
Set an XML property to schema validator.
|
void |
setSecureProcessing()
This method provides aggregate configurations for secure parsing It can be used to replace equevalent calls of setAttribute() This make it easier to change the definition of secure processing and provide better performance when the setAttribute becomes too many entries.
|
void |
setValidationMode(boolean yes)
Deprecated.
Replaced by setValidationMode(int).
|
void |
setValidationMode(int valMode)
Set the validation mode This method sets the validation mode of the parser.
|
java.lang.Object |
setXMLProperty(java.lang.String name, java.lang.Object value)
Set a property.
|
void |
setXMLSchema(java.lang.Object schema)
Set an XMLSchema for validating the instance document
|
public static final java.lang.String PARSER
public static final java.lang.String DTD_OBJECT
public static final int DTD_OBJECT_ID
public static final java.lang.String SCHEMA_OBJECT
public static final int SCHEMA_OBJECT_ID
public static final java.lang.String PARSER_DTD
public static final java.lang.String PARSER_CDATA
public static final java.lang.String SCHEMA_SOURCE
public static final int SCHEMA_SOURCE_ID
public static final java.lang.String SCHEMA_LANGUAGE
public static final int SCHEMA_LANGUAGE_ID
public static final int IGNORE_DUPLICATE_ID
public static final java.lang.String BASE_URL
public static final int BASE_URL_ID
public static final java.lang.String USE_DTD_ONLY_FOR_VALIDATION
public static final int USE_DTD_ONLY_FOR_VALIDATION_ID
public static final java.lang.String STANDALONE
public static final int STANDALONE_ID
public static final java.lang.String EXPAND_ENTITYREF
public static final int EXPAND_ENTITYREF_ID
public static final java.lang.String RESOLVE_ENTITY_DEFAULT
public static final int RESOLVE_ENTITY_DEFAULT_ID
public static final java.lang.String ENTITY_EXPANSION_DEPTH
public static final int ENTITY_EXPANSION_DEPTH_ID
public static final java.lang.String XDK_FEATURE_CONTENT_MODEL_DETERMINISTIC
public static final int XDK_FEATURE_CONTENT_MODEL_DETERMINISTIC_ID
public static final java.lang.String XDK_FEATURE_ALLOW_ILLEGAL_UTF8_ENCODING
public static final int XDK_FEATURE_ALLOW_ILLEGAL_UTF8_ENCODING_ID
public static final java.lang.String CONTENT_MODEL_DETERMINISTIC
public static final java.lang.String XDK_ATTRIBUTE_ENTITY_EXPANSION_COUNT_LIMIT
public static final int XDK_ATTRIBUTE_ENTITY_EXPANSION_COUNT_LIMIT_ID
public static final int XDK_ATTRIBUTE_ENTITY_EXPANSION_COUNT_LIMIT_SECURE
public static final int XDK_ATTRIBUTE_ENTITY_EXPANSION_COUNT_LIMIT_DEFAULT
public static final int DEFAULT_ENTITY_EXPANSION_DEPTH_SECURE
public static final int DEFAULT_ENTITY_EXPANSION_DEPTH
public void reset()
public void parse(InputSource in) throws XMLParseException, SAXException, java.io.IOException
in
- the org.xml.sax.InputSouce
to parseXMLParseException
- if syntax or other error encountered.SAXException
- Any SAX exception, possibly wrapping another exception.java.io.IOException
- IO Error.public void parse(java.lang.String in) throws XMLParseException, SAXException, java.io.IOException
in
- the String
containing the URL to parse fromXMLParseException
- if syntax or other error encountered.SAXException
- Any SAX exception, possibly wrapping another exception.java.io.IOException
- IO Error.public final void parse(java.net.URL url) throws XMLParseException, SAXException, java.io.IOException
url
- the url points to the XML document to parse.XMLParseException
- if syntax or other error encountered.SAXException
- Any SAX exception, possibly wrapping another exception.java.io.IOException
- IO Error.public final void parse(java.io.InputStream in) throws XMLParseException, SAXException, java.io.IOException
in
- the InputStream
containing XML data to parse.XMLParseException
- if syntax or other error encountered.SAXException
- Any SAX exception, possibly wrapping another exception.java.io.IOException
- IO Error.setBaseURL(java.net.URL)
public final void parse(java.io.Reader r) throws XMLParseException, SAXException, java.io.IOException
r
- the Reader
containing XML data to parse.XMLParseException
- if syntax or other error encountered.SAXException
- Any SAX exception, possibly wrapping another exception.java.io.IOException
- IO Error.setBaseURL(java.net.URL)
public void setSecureProcessing()
public void setEntityResolver(EntityResolver resolver)
If the application does not register an entity resolver, the XMLReader will perform its own default resolution.
Applications may register a new or different resolver in the middle of a parse, and the SAX parser must begin using the new resolver immediately.
resolver
- The entity resolver.java.lang.NullPointerException
- If the resolver argument is null.getEntityResolver()
public EntityResolver getEntityResolver()
setEntityResolver(org.xml.sax.EntityResolver)
public void setErrorHandler(ErrorHandler handler)
If the application does not register an error handler, all error events reported by the SAX parser will be silently ignored; however, normal processing may not continue. It is highly recommended that all SAX applications implement an error handler to avoid unexpected bugs.
Applications may register a new or different handler in the middle of a parse, and the SAX parser must begin using the new handler immediately.
handler
- The error handler.java.lang.NullPointerException
- If the handler argument is null.getErrorHandler()
public ErrorHandler getErrorHandler()
setErrorHandler(org.xml.sax.ErrorHandler)
public void setLocale(java.util.Locale locale) throws SAXException
locale
- Locale
to setSAXException
- A SAXException
could be thrown.Parser.setLocale(java.util.Locale)
public void setDoctype(DTD dtd)
dtd
- DTD
to set and used while parsingpublic void setSchemaValidationMode(boolean flag)
flag
- determines whether the XML parser should invoke schema validatingpublic void setValidationMode(boolean yes)
yes
- determines whether the XML parser should be validatingpublic void setValidationMode(int valMode)
valMode
- determines the type of the validation mode which the parser is set topublic java.lang.Object setSchemaValidatorProperty(java.lang.String name, java.lang.Object value)
name
- - name of the propertyvalue
- - value of the propertypublic void setBaseURL(java.net.URL url)
url
- The base URLpublic java.net.URL getBaseURL()
public void setPreserveWhitespace(boolean flag)
flag
- preserving modepublic boolean getValidationMode()
true
if the XML parser is validating false
if notpublic int getValidationModeValue()
0
if the XML parser is NONVALIDATING 1
if the XML parser is PARTIAL_VALIDATION 2
if the XML parser is DTD_VALIDATION 3
if the XML parser is SCHEMA_VALIDATIONpublic static java.lang.String getReleaseVersion()
public void setXMLSchema(java.lang.Object schema)
schema
- The XMLSchema objectpublic void setAttribute(java.lang.String name, java.lang.Object value) throws java.lang.IllegalArgumentException
name
- The name of the attribute.value
- The value of the attribute.java.lang.IllegalArgumentException
- thrown if the underlying implementation doesn't recognize the attribute.public void setAttribute(int id, java.lang.Object value) throws java.lang.IllegalArgumentException
id
- The id of the attribute.value
- The value of the attribute.java.lang.IllegalArgumentException
- thrown if the underlying implementation doesn't recognize the attribute.public java.lang.Object getAttribute(java.lang.String name) throws java.lang.IllegalArgumentException
name
- The name of the attribute.java.lang.IllegalArgumentException
- thrown if the underlying implementation doesn't recognize the attribute.public java.lang.Object setXMLProperty(java.lang.String name, java.lang.Object value)
name
- - name of the propertyvalue
- - value of the propertypublic java.lang.Object getXMLProperty(java.lang.String name)
name
- - name of the propertypublic boolean isXMLPropertySupported(java.lang.String name)
name
- - name of the propertypublic boolean isXMLPropertyReadOnly(java.lang.String name)
name
- - name of the property