Oracle9i XML API Reference - XDK and Oracle XML DB Release 2 (9.2) Part Number A96616-01 |
|
XML parsing facilitates the extension of existing applications to support XML by processing XML documents and providing access to the information contained in them through a variety of APIs. This chapter contains the following sections
This class implements the default behavior for the XMLDocumentHandler
interface. Application writers can extend this class when they need to implement only part of the interface.
public class DefaultXMLDocumentHandler implements
oracle.xml.parser.v2.XMLDocumentHandler
oracle.xml.parser.v2.DefaultXMLDocumentHandler
XMLDocumentHandler
Constructs a default document.
public DefaultXMLDocumentHandler();
Receive notification of a CDATA Section. The Parser will invoke this method once for each CDATA Section found. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void cDATASection( char[] ch, int start, int length);
Parameter | Description |
---|---|
ch |
The CDATA section characters. |
start |
The start position in the character array. |
length |
The number of characters to use from the character array. |
Receives notification of a comment. The Parser will invoke this method once for each comment found: note that comment may occur before or after the main document element. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void comment( String data);
Parameter | Description |
---|---|
data |
The comment data, or |
Receives notification of end of the DTD. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void endDoctype();
Receives notification of the end of an element. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception. The options are described in the following table.
End the scope of a prefix-URI mapping. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void endPrefixMapping( String prefix);
Returns the next pipe-line node handler node.
public XMLDocumentHandler
getHandler();
Sets the DTD so can subsequently receive notification of that DTD. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void setDoctype( DTD
dtd);
Parameter | Description |
---|---|
dtd |
The DTD. |
Receives notification of a XMLError handler. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void setError( XMLError
he);
Parameter | Description |
---|---|
err |
The XMLError object. |
Receive notification of a next pipe-line node handler. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void setHandler( XMLDocumentHandler
h);
Parameter | Description |
---|---|
h |
The XMLDocumentHandler node. |
Receive notification of a Text XML Declaration. The Parser will invoke this method once for each text XML Decl. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void setTextDecl( String version, String encoding);
Parameter | Description |
---|---|
version |
The version number. |
encoding |
The encoding name, or NULL if not specified. |
Receive notification of an XML Declaration. The Parser will invoke this method once for XML Decl. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void setXMLDecl( String version, String standalone, String encoding);
Parameter | Description |
---|---|
version |
The version number. |
standalone |
The Standalone value, or |
encoding |
The encoding name, or |
Receive notification of a XMLSchema object. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void setXMLSchema( Object s);
Parameter | Description |
---|---|
s |
The XMLSchema object. |
Receives notification of a skipped entity. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void skippedEntity( String name);
Parameter | Description |
---|---|
name |
The name of the skipped entity. If it is a parameter entity, the name will begin with '%', and if it is the external DTD subset, it will be the string "[dtd]". |
Receives notification of the beginning of an element. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception. The options are described in the following table.
Begin the scope of a prefix-URI Namespace mapping. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void startPrefixMapping( String prefix, String uri);
Parameter | Description |
---|---|
prefix |
The Namespace prefix being declared. |
uri |
The Namespace URI the prefix is mapped to. |
public class DocumentBuilder oracle.xml.parser.v2.DocumentBuilder
This class implements XMLDocumentHandler (deprecated) and ContentHandler to build a DOM Tree from SAX 2.0 events. XMLDocumentHandler events are supported for backward compatibility
Default constructor. Creates a document builder that can be used as XMLDocumentHandler.
public DocumentBuilder();
Reports an attribute type declaration. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void attributeDecl( String eName, String aName, String type, String valueDefault, String value);
Receives notification of CDATA Section data inside an element. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void cDATASection( char[] ch, int start, int length);
Parameter | Description |
---|---|
ch |
The CDATA characters. |
start |
The starting position in the array. |
length |
The number of characters to use from the array. |
Receive notification of character data inside an element. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void characters( char[] ch, int start, int length)
Parameter | Description |
---|---|
ch |
An array holding the character data. |
start |
The starting position in the array. |
length |
The number of characters to use from the array. |
Receives notification of a comment. Reports an XML comment anywhere in the document. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception. The options are described in the following table.
Syntax | Description |
---|---|
int length); |
Receives notification of a comment using the parameters of the comment character array. |
String data); |
Receives notification of a comment using the comment data. |
Report an element type declaration. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void elementDecl( String name, String model);
Parameter | Description |
---|---|
name |
The element type name. |
model |
The content model as a normalized string. |
Reports the end of a CDATA section. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void endCDATA();
Receives notification of end of the DTD. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void endDoctype();
Receives notification of the end of the document. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void endDocument();
Reports the end of DTD declarations. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void endDTD();
Receives notification of the end of an element. Throws
org.xml.sax.SAXException,
which could be any SAX exception, possibly
wrapping another exception. The options are described in the following table.
Reports the end of an entity. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void endEntity( String name);
Parameter | Description |
---|---|
name |
The name of the entity that is ending. |
Reports a parsed external entity declaration. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void externalEntityDecl( String name, String publicId, String systemId);
Returns the current XMLNode being build.
public XMLNode
getCurrentNode();
Returns the document being build.
public XMLDocument
getDocument();
Receives notification of ignorable whitespace in element content. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void ignorableWhitespace( char[] ch, int start, int length);
Parameter | Description |
---|---|
ch |
The whitespace characters. |
start |
The start position in the character array. |
length |
The number of characters to use from the character array. |
Report an internal entity declaration. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void internalEntityDecl( String name, String value);
Parameter | Description |
---|---|
name |
The name of the entity. If it is a parameter entity, the name will begin with '%'. |
value |
The replacement text of the entity. |
Receives notification of a processing instruction. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void processingInstruction( String target, String data);
Parameter | Description |
---|---|
target |
The processing instruction target. |
data |
The processing instruction data, or |
Sets a flag to retain CDATA sections
public void retainCDATASection( boolean flag);
Parameter | Description |
---|---|
flag |
Determines whether CDATA sections are retained; |
Sets a flag to turn on debug information in the document.
public void setDebugMode(b oolean flag);
Parameter | Description |
---|---|
flag |
Determines whether debug info is stored; |
Sets the DTD so can subsequently receive notification of that DTD. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void setDoctype( DTD
dtd);
Parameter | Description |
---|---|
did |
The DTD for the document. |
Sets the Locator so can subsequently receive notification for this Locator object for document events. By default, do nothing. Application writers may override this method in a subclass if they wish to store the locator for use with other document events.
public void setDocumentLocator( org.xml.sax.Locator locator);
Parameter | Description |
---|---|
locator |
A locator for all SAX document events. |
Sets a optional NodeFactory to be used for creating custom DOM trees.
public void setNodeFactory( NodeFactory
f);
Parameter | Description |
---|---|
f |
NodeFactory/ |
Receive notification of a Text XML Declaration. The Parser will invoke this method once for each text XML Decl. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void setTextDecl( String version, String encoding);
Parameter | Description |
---|---|
version |
The version number, or |
encoding |
The encoding name, or |
Receive notification of a XML Declaration. The Parser will invoke this method once for XML Decl. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void setXMLDecl( String version, String standalone, String encoding);
Parameter | Description |
---|---|
version |
The version number. |
standalone |
The standalone value, or |
encoding |
The encoding name, or |
Reports the start of a CDATA section. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void startCDATA();
Receive notification of the beginning of the document. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void startDocument();
Report the start of DTD declarations, if any. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void startDTD( String name, String publicId, String systemId);
Receives notification of the beginning of an element. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception. The options are described in the following table.
Reports the beginning of some internal and external XML entities. All start/endEntity events must be properly nested. Throws org.xml.sax.SAXException,
which could be any SAX exception, possibly wrapping another exception.
public void startEntity( String name);
Parameter | Description |
---|---|
name |
The name of the entity. If it is a parameter entity, the name will begin with '%', and if it is the external DTD subset, it will be "[dtd]". |
public class DOMParser oracle.xml.parser.v2.DOMParser
This class implements an eXtensible Markup Language (XML) 1.0 parser according to the World Wide Web Consortium (W3C) recommendation. to parse a XML document and build a DOM tree.
Creates a new parser object.
public DOMParser();
Returns specific attributes on the underlying implementation. Throws IllegalArgumentException
if the underlying implementation doesn't recognize the attribute.
public java.lang.Object getAttribute( String name);
Parameter | Description |
---|---|
name |
The name of the attribute. |
Returns the DTD.
public DTD
getDoctype();
Returns the document being parsed.
public XMLDocument
getDocument();
Parses the XML External DTD from given input stream. Throws the following exceptions:
XMLParseException
if syntax or other error encountered.SAXException
, which could be SAX exception, possibly wrapping another exception.IOException
in cases of I/O Error.The options are described in the following table.
Parameter | Description |
---|---|
in |
The input to parse. |
rootName |
The element to be used as root Element. |
r |
The reader containing XML data to parse. |
url |
The url which points to the XML document to parse. |
Resets the parser state.
public void reset();
Switches to determine whether to retain CDATA sections.
public void retainCDATASection( boolean flag);
Parameter | Description |
---|---|
flag |
TRUE - keep CDATASections (default) FALSE - convert CDATASection to Text nodes |
Sets specific attributes on the underlying implementation. Throws an IllegalArgumentException
if the underlying implementation doesn't recognize the attribute.
public void setAttribute( String name, Object value);
Parameter | Description |
---|---|
name |
The name of the attribute. |
value |
he value of the attribute. |
Sets a flag to turn on debug information in the document
public void setDebugMode( boolean flag);
Parameter | Description |
---|---|
flag |
Determines whether debug info is stored. |
Creates an output stream for the output of errors and warnings. If an output stream for errors is not specified, the parser will use the standard error output stream System.err
for outputting errors and warnings. Additionally, an exception is thrown if the encoding specified is unsupported. The options are described in the following table.
Parameter | Description |
---|---|
out |
Used for output of errors and warnings. |
enc |
The encoding to use. |
Set the node factory. Applications can extend the NodeFactory and register it through this method. The parser will then use the user supplied NodeFactory to create nodes of the DOM tree. Throws XMLParseException
if an invalid factory is set
public void setNodeFactory( NodeFactory
factory);
Parameter | Description |
---|---|
factory |
The NodeFactory to set. |
Switches to determine whether to print warnings.
public void showWarnings( boolean flag);
Parameter | Description |
---|---|
flag |
Determines whether warnings should be shown. |
This class specifies methods to create various nodes of the DOM tree built during parsing. Applications can override these methods to create their own custom classes to be added to the DOM tree while parsing. Applications have to register their own NodeFactory using the XMLParser's setNodeFactory() method. If a null pointer is returned by these methods, then the node will not be added to the DOM tree.
public class NodeFactory extends java.lang.Object implements java.io.Serializable java.lang.Object | +--oracle.xml.parser.v2.NodeFactory
java.io.Serializable
Class constructor.
public NodeFactory();
Creates and returns an attribute node. The options are described in the following table.
Creates and returns CDATA node with the specified text.
public XMLCDATA
createCDATASection( String text);
Parameter | Description |
---|---|
text |
The text associated with the node. |
Creates and returns a comment node with the specified text.
public XMLComment
createComment( String text);
Parameter | Description |
---|---|
text |
The text associated with the node. |
Creates and returns a document node. This method cannot return a null pointer.
public XMLDocument
createDocument();
Creates a document fragment node with the specified tag.
public XMLDocumentFragment
createDocumentFragment();
The created document fragment node.
Creates and returns an Element node with the specified tag.
public XMLElement
createElement( String tag);
Parameter | Description |
---|---|
tag |
The name of the element. |
Creates and returns an Element node with the specified local name, prefix, and namespaceURI.
public XMLElement
createElementNS( String localName,
String prefix,
String namespaceURI);
Parameters | Description |
---|---|
localName |
The name of the element. |
prefix |
The prefix of an element. |
namespaceURI |
The namespace of the element. |
Creates and returns an entity reference node with the specified tag.
public XMLEntityReference
createEntityReference( String tag);
Parameter | Description |
---|---|
tag |
The name of the node. |
Creates and returns a ProcessingInstruction node with the specified tag, and text.
public XMLPI
createProcessingInstruction( String tag,
String text);
Parameter | Description |
---|---|
tag |
The name of the node. |
text |
The text associated with the node. |
Creates and returns a text node with the specified text.
public XMLText
createTextNode( String text);
Parameter | Description |
---|---|
text |
The text associated with the node. |
The oraxml class provides a command-line interface to validate XML files
public class oraxml extends java.lang.Object java.lang.Object | +--oracle.xml.parser.v2.oraxml
public oraxml();
public static void main( String[] args);
This class implements the SAX AttributeList
interface and also provides Namespace support. Applications that require Namespace support can explicitly cast any attribute list returned by an Oracle parser class to SAXAttrList
and use the methods described here. It also implements Attributes (SAX 2.0) interface.
This interface allows access to a list of attributes in three different ways:
This interface replaces the now-deprecated SAX1 interface, which does not contain Namespace support. In addition to Namespace support, it adds the getIndex methods.
The order of attributes in the list is unspecified, and will vary from implementation to implementation.
public class SAXAttrList oracle.xml.parser.v2.SAXAttrList
Class constructor.
public SAXAttrList(int elems)
Adds an attribute to the parent element node. The options are described in the following table.
Returns the expanded name for an attribute in the list (by position).
public String getExpandedName( int i);
Parameter | Description |
---|---|
i |
The index of the attribute in the list. |
Returns the index of an attribute. Returns -1
if it does not appear in the list. The options are described in the following table.
Syntax | Description |
---|---|
String qName); |
Returns the index of an attribute by qualified name. |
String localName); |
Returns the index of an attribute by namespace URI and local name. |
Parameter | Description |
---|---|
qName |
The qualified (prefixed) name. |
uri |
The Namespace URI, or the empty string if the name has no Namespace URI. |
localName |
The attribute's local name. |
Returns the number of attributes in this list. The SAX parser may provide attributes in any arbitrary order, regardless of the order in which they were declared or specified. The number of attributes may be zero.
public int getLength();
Returns an attribute's local name by index, or the empty string if Namespace processing is not being performed, or NULL
if the index is out of range.
public String getLocalName( int index);
Parameter | Description |
---|---|
index |
The attribute index (zero-based). |
Returns the namespace prefix for an attribute in the list by position.
public String getPrefix( int index);
Parameter | Description |
---|---|
index |
The attribute index (zero-based). |
i
- The index of the attribute in the list.
Returns an attribute's XML 1.0 qualified name by index, or the empty string if none is available, or NULL
if the index is out of range.
public String getQName( int index);
Parameter | Description |
---|---|
index |
The attribute index (zero-based). |
Returns an attribute's type. The attribute type is one of the strings "CDATA
", "ID
", "IDREF
", "IDREFS
", "NMTOKEN
", "NMTOKENS
", "ENTITY
", "ENTITIES
", or "NOTATION"
(always in upper case). If the parser has not read a declaration for the attribute, or if the parser does not report attribute types, then it must return the value "CDATA
" as stated in the XML 1.0 Recommendation (clause 3.3.3, "Attribute-Value Normalization"). For an enumerated attribute that is not a notation, the parser will report the type as "NMTOKEN
". The options are described in the following table.
Returns an attribute's Namespace URI by index, or the empty string if none is available, or null if the index is out of range.
public String getURI( int index);
Parameter | Description |
---|---|
index |
The attribute index (zero-based). |
Returns the attribute's value as a string, or NULL
if the index is out of range. If the attribute value is a list of tokens (IDREFS
, ENTITIES
, or NMTOKENS
), the tokens will be concatenated into a single string with each token separated by a single space. The options are described in the following table.
Resets the SAXAttrList.
public void reset();
This class implements an eXtensible Markup Language (XML) 1.0 SAX parser according to the World Wide Web Consortium (W3C) recommendation. Applications can register a SAX handler to receive notification of various parser events.
XMLReader is the interface that an XML parser's SAX2 driver must implement. This interface allows an application to set and query features and properties in the parser, to register event handlers for document processing, and to initiate a document parse.
All SAX interfaces are assumed to be synchronous: the parse methods must not return until parsing is complete, and readers must wait for an event-handler callback to return before reporting the next event.
This interface replaces the (now deprecated) SAX 1.0 Parser interface. The XMLReader interface contains two important enhancements over the old Parser interface:
public class SAXParser oracle.xml.parser.v2.SAXParser
Creates a new parser object.
public SAXParser()
Returns the current content handler, or null if none has been registered.
public org.xml.sax.ContentHandler getContentHandler();
Returns the current DTD handler, or null if none has been registered.
public org.xml.sax.DTDHandler getDTDHandler();
Returns the current state of the feature (true or false). The feature name is any fully-qualified URI. It is possible for an XMLReader to recognize a feature name but not be able to return its value; this is especially true in the case of an adapter for a SAX1 Parser, which has no way of knowing whether the underlying parser is performing validation or expanding external entities. Some feature values may be available only in specific contexts, such as before, during, or after a parse. Throws the following exceptions:
org.xml.sax.SAXNotRecognizedException
if the XMLReader does not recognize the feature name.org.xml.sax.SAXNotSupportedException
if the XMLReader recognizes the feature name but cannot determine its value at this time.The feature http://www.xml.org/sax/features/validation due to its binary input value only controls DTD validation. The value true sets DTD validation to TRUE. This feature cannot be used to control XML Schema based validation.
Implementors are free (and encouraged) to invent their own features, using names built on their own URIs.
public boolean getFeature( String name);
Parameter | Description |
---|---|
name |
Feature name. |
Returns the value of a property. The property name is any fully-qualified URI. It is possible for an XMLReader to recognize a property name but to be unable to return its state; this is especially true in the case of an adapter for a SAX1 Parser
. XMLReaders are not required to recognize any specific property names, though an initial core set is documented for SAX2. Some property values may be available only in specific contexts, such as before, during, or after a parse. Implementors are free (and encouraged) to invent their own properties, using names built on their own URIs. Throws the following exceptions:
org.xml.sax.SAXNotRecognizedException
if the XMLReader does not recognize the feature name.org.xml.sax.SAXNotSupportedException
if the XMLReader recognizes the feature name but cannot determine its value at this time.public Object getProperty( String name);
Parameter | Description |
---|---|
name |
The property name, which is a fully-qualified URI |
Registers a content event handler. If the application does not register a content handler, all content events reported by the SAX parser will be silently ignored. 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. Throws java.lang.NullPointerException
if the handler argument is null.
public void setContentHandler( org.xml.sax.ContentHandler handler);
Parameter | Description |
---|---|
handler |
The content handler. |
Registers a DTD event handler. If the application does not register a DTD handler, all DTD events reported by the SAX parser will be silently ignored. 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. Throws java.lang.NullPointerException
if the handler argument is null.
public void setDTDHandler( org.xml.sax.DTDHandler handler);
Parameter | Description |
---|---|
handler |
The DTD handler. |
Set the state of a feature. The feature name is any fully-qualified URI. It is possible for an XMLReader to recognize a feature name but to be unable to set its value; this is especially true in the case of an adapter for a SAX1 Parser
, which has no way of affecting whether the underlying parser is validating, for example.
Some feature values may be immutable or mutable only in specific contexts, such as before, during, or after a parse. The feature "http:://www.xml.org/sax/features/validation" due to its binary input value only controls DTD validation. The value true sets DTD validation to TRUE. This feature cannot be used to control XML Schema based validation. Throws the following exceptions:
org.xml.sax.SAXNotRecognizedException
- When the XMLReader does not recognize the feature name.org.xml.sax.SAXNotSupportedException
- When the XMLReader recognizes the feature name but cannot set the requested value.public void setFeature( String name, boolean value);
Parameter | Description |
---|---|
name |
The feature name, which is a fully-qualified URI. |
state |
The requested state of the feature (true or false). |
Sets the value of a property. The property name is any fully-qualified URI. It is possible for an XMLReader to recognize a property name but to be unable to set its value; this is especially true in the case of an adapter for a SAX1 Parser
. XMLReaders are not required to recognize setting any specific property names, though a core set is provided with SAX2. Some property values may be immutable or mutable only in specific contexts, such as before, during, or after a parse. This method is also the standard mechanism for setting extended handlers. Throws the following exceptions:
org.xml.sax.SAXNotRecognizedException
if the XMLReader does not recognize the property name.org.xml.sax.SAXNotSupportedException
if the XMLReader recognizes the property name but cannot set the requested value.public void setProperty( String name, Object value);
Parameter | Description |
---|---|
name |
The property name, which is a fully-qualified URI. |
state |
The requested value for the property. |
Indicates that a parsing exception occurred while processing an XML document
public class XMLParseException oracle.xml.parser.v2.XMLParseException
Class constructor.
public XMLParseException( String mesg, String pubId, String sysId, int line, int col, int type);
Parameter | Description |
---|---|
mesg |
Message. |
pubId |
Public id. |
sysId |
System id. |
line |
Line. |
col |
Column. |
type |
Type. |
Returns the error message at specified index.
public String formatErrorMessage( int i);
Parameter | Description |
---|---|
i |
Index. |
Returns the column number of error at specified index.
public int getColumnNumber(int i);
Parameter | Description |
---|---|
i |
Index. |
Returns the exception (if exists) that occurred in error at specified index.
public java.lang.Exception getException(int i);
Parameter | Description |
---|---|
i |
Index. |
Returns the line number of error at specified index
public int getLineNumber(int i);
Parameter | Description |
---|---|
i |
Index. |
Returns the error message at specified index
public String getMessage(int i)
Parameter | Description |
---|---|
i |
Index. |
Returns the type of the error message at specified index.
public int getMessageType(int i)
Parameter | Description |
---|---|
i |
Index. |
Return the total number of errors/warnings found during parsing.
public int getNumMessages();
Returns the public ID of input when error at specified index occurred.
public String getPublicId(int i);
Parameter | Description |
---|---|
i |
Index |
Returns the system ID of input when error at specified index occurred.
public String getSystemId(int i);
Parameter | Description |
---|---|
i |
Index |
This class serves as a base class for the 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 cannot be instantiated (applications may use the DOM or SAX parser depending on their requirements).
public abstract class XMLParser oracle.xml.parser.v2.XMLParser
Retrieves values of specific attributes on the underlying implementation. Throws IllegalArgumentException
- thrown if the underlying implementation doesn't recognize the attribute.
public java.lang.Object getAttribute( String name);
Parameter | Description |
---|---|
value |
The value of the attribute. |
Returns the base URL.
public java.net.URL getBaseURL();
Returns the current entity resolver.
public org.xml.sax.EntityResolver getEntityResolver();
The current entity resolver, or null if none has been registered.
Returns the current error handler, or null if none has been registered.
public org.xml.sax.ErrorHandler getErrorHandler();
Returns the release version of the Oracle XML Parser.
public static String getReleaseVersion();
Returns the validation mode value:
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_VALIDATION
public int getValidationModeValue();
Returns value of a property. The property is returned if present and supported, else null is returned
public java.lang.Object getXMLProperty( String name);
Parameter | Description |
---|---|
name |
Name of the property. |
Returns TRUE
if a given property is read-only Returns true if the property is not supported
public boolean isXMLPropertyReadOnly( String name);
Parameter | Description |
---|---|
name |
Name of the property. |
Returns TRUE
if a given property is supported.
public boolean isXMLPropertySupported( String name)
Parameter | Description |
---|---|
name |
Name of the property. |
Parses the XML. Throws the following exceptions:
XMLParseException
if syntax or other error encountered.SAXException
, which could be any SAX exception, possibly wrapping another exception.IOException
in cases of I/O Error.The options are described in the following table.
Parameter | Description |
---|---|
in |
Source containing XML data to parse. |
url |
The ULR pointing to the XML document which will be parsed. |
Resets the parser state.
public void reset();
Sets specific attributes on the underlying implementation. Throws an IllegalArgumentException
if the underlying implementation doesn't recognize the attribute.
public void setAttribute( String name, Object value);
Parameter | Description |
---|---|
|
The name of the attribute. |
|
The value of the attribute. |
Sets the base URL for loading external entities and DTDs. This method should to be called if the parse() is used to parse the XML Document.
public void setBaseURL( java.net.URL url);
Parameter | Description |
---|---|
url |
The base URL. |
Sets the DTD.
public void setDoctype( DTD
dtd);
Parameter | Description |
---|---|
dtd |
The DTD to set and use while parsing. |
Registers an entity resolver. Throws a NullPointerException
if the resolver argument is null.
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.
public void setEntityResolver( org.xml.sax.EntityResolver resolver);
Parameter | Description |
---|---|
resolver |
The entity resolver. |
Registers an error event handler. Throws java.lang.NullPointerException
if the handler argument is null.
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.
public void setErrorHandler( org.xml.sax.ErrorHandler handler);
Parameter | Description |
---|---|
handler |
The error handler. |
handler
- The error handler.
Sets the locale for error reporting. Throws a SAXException
on error.
public void setLocale( java.util.Locale locale);
Parameter | Description |
---|---|
locale |
The locale to set. |
Sets the white space preserving mode.
public void setPreserveWhitespace( boolean flag);
Parameter | Description |
---|---|
flag |
The preserving mode. |
Sets the validation mode. This method sets the validation mode of the parser to one of the 4 types: NONVALIDATING
, PARTIAL_VALIDATION
, DTD_VALIDATION
and SCHEMA_VALIDATION
.
public void setValidationMode(int valMode)
Parameter | Description |
---|---|
valMode |
Determines the type of the validation mode to which the parser should be set. |
Sets and returns an XMLproperty. The value of the property set is returned if successfully set, a null is returned if the property is read-only and cannot be set or is not supported.
public java.lang.Object setXMLProperty( String name, Object value);
Parameter | Description |
---|---|
name |
Name of the property. |
value |
Value of the property. |
Sets an XMLSchema for validating the instance document.
public void setXMLSchema( java.lang.Object schema);
Parameter | Description |
---|---|
schema |
The XMLSchema object |
Basic interface for XMLToken. All XMLParser applications with Tokenizer feature must implement this interface. The interface has to be registered using XMLParser
method setTokenHandler()
.
If XMLtoken handler isn't null, then for each registered and found token the parser calls the XMLToken call-back method token()
. During tokenizing the parser doesn't validate the document and doesn't include/read internal/external entities. If XMLtoken handler == null then the parser parses as usual.
A request for XML token is registered (on/off) using XMLParser method setToken()
. The requests could be registered during the parsing (from inside the call-back method) as well.
The XML tokens are defined as public constants in XMLToken
interface. They correspond to the XML syntax variables from W3C XML Syntax Specification.
public interface XMLToken
Receives an XML token and it's corresponding value. This is an interface call-back method.
public void token( int token, String value);
Parameter | Description |
---|---|
token |
The XML token constant as specified in the interface. |
value |
The corresponding substring from the parsed text. |
This class implements an eXtensible Markup Language (XML) 1.0 parser according to the World Wide Web Consortium (W3C) recommendation.
public class XMLTokenizer oracle.xml.parser.v2.XMLTokenizer
Creates a new Tokenizer object. The options are described in the following table.
Syntax | Description |
---|---|
public XMLTokenizer(); |
Creates a new Tokenizer object. |
XMLToken handler); |
Creates a new Tokenizer object from a handler. |
Parameter | Description |
---|---|
handler |
The handler. |
Parses the document.
public void parseDocument();
Registers a new error event handler. This replaces any previous setting for error handling.
public void setErrorHandler(org.xml.sax.ErrorHandler handler)
Parameter | Description |
---|---|
handler |
The handler being registered. |
Registers a output stream for errors.
public void setErrorStream( java.io.OutputStream out);
Parameter | Description |
---|---|
out |
Error stream being registered. |
Registers a new token for XML tokenizer.
public void setToken( int token, boolean val);
Parameter | Description |
---|---|
token |
XMLToken being set. |
Registers a new XML tokenizer event handler.
public void setTokenHandler( XMLToken
handler);
Parameter | Description |
---|---|
handler |
XMLToken being registered. |
Tokenizes the XML. Throws the following exceptions:
XMLParseException
if syntax or other error encountered.SAXException
, which could be any SAX exception, possibly wrapping another exception.IOException
in cases of I/O Error.The options are described in the following table.
Parameter | Description |
---|---|
in |
The source for parsing. |
url |
The URL which points to the XML document to parse. |
The NSName interface is part of the orace.xml.util package; it provides Namespace support for Element and Attr names.
public interface oracle.xml.util.NSName
Returns the fully resolved name for this name.
public String getExpandedName();
Returns the local name for this name.
public String getLocalName();
Returns the resolved Namespace for this name.
public String getNamespace()
Returns the prefix for this name.
public String getPrefix();
Returns the qualified name.
public String getQualifiedName();
This class of the oracle.xml.util
package holds the error message and the line number where it occured.
public class XMLError oracle.xml.util.XMLError
Default constructor for XMLError.
public XMLError();
Adds a new error to the vector. The options are described in the following table.
Syntax | Description |
---|---|
String msg); |
Adds a new error to the vector, with a message. |
String[] params); |
Adds a new error to the vector, with an array of parameters. |
Parameter | Description |
---|---|
id |
Id of the error message. |
type |
Type of the error. |
MESG |
Error message (without parameters). |
params |
Parameter array. |
Adds a new error to the vector, with no parameters.
public void error3( int id, int type);
Parameter | Description |
---|---|
id |
Id of the error message. |
type |
Type of the error. |
Adds a new error to the vector, with 1 parameter.
public void error3( int id, int type, String p1);
Parameter | Description |
---|---|
id |
Id of the error message. |
type |
Type of the error. |
p1 |
Parameter 1. |
Adds a new error to the vector, with two parameters.
public void error3( int id, int type, String p1, String p2);
Parameter | Description |
---|---|
id |
Id of the error message. |
type |
Type of the error. |
p1 |
Parameter 1. |
p2 |
Parameter 2. |
Adds a new error to the vector, with 3 parameters.
public void error3( int id, int type, String p1, String p2, String p3)
Parameter | Description |
---|---|
id |
Id of the error message. |
type |
Type of the error. |
p1 |
Parameter 1. |
p2 |
Parameter 2. |
p3 |
Parameter 3. |
Flushes all the error to the output stream output stream defaults or to error handler.
public void flushErrorStream();
Formats an error message.
public String formatErrorMesg(int index);
Parameter | Description |
---|---|
i |
Index. |
Returns the column number of error at specified index.
public int getColumnNumber(int i);
Parameter | Description |
---|---|
i |
Index. |
Returns the exception (if exists) that occured in error at specified index.
public java.lang.Exception getException(int i);
Parameter | Description |
---|---|
i |
Index. |
Returns the first error.
public int getFirstError();
Returns the line number of error at specified index.
public int getLineNumber(int i);
Parameter | Description |
---|---|
i |
Index. |
Returns the registered locator
public org.xml.sax.Locator getLocator();
Returns an error message. The options are described in the following table.
Syntax | Description |
---|---|
int i); |
Returns the error message at specified index. |
String[] params); |
Returns error message with more than 5 parameters, packaged in an array. |
Parameter | Description |
---|---|
i |
Index. |
errId |
The error id. |
param |
An array of parameters. |
Returns error message with no parameters.
public String getMessage1( int errId);
Parameter | Description |
---|---|
errId |
The error id. |
Returns error message with 1 argument.
public String getMessage1( int errId, String a1);
Parameter | Description |
---|---|
errId |
The error id. |
a1 |
Parameter 1. |
Returns error message with 2 parameters
public String getMessage3( int errId, String a1, String a2);
Parameter | Description |
---|---|
errId |
The error id. |
a1 |
Parameter 1. |
a2 |
Parameter 2. |
Returns error message with 3 parameters.
public String getMessage3( int errId, String a1, String a2, String a3);
Parameter | Description |
---|---|
errId |
The error id. |
a1 |
Parameter 1. |
a2 |
Parameter 2. |
a3 |
Parameter 3. |
Returns error message with 4 parameters.
public String getMessage4( int errId, String a1, String a2, String a3, String a4);
Parameter | Description |
---|---|
errId |
The error id. |
a1 |
Parameter 1. |
a2 |
Parameter 2. |
a3 |
Parameter 3. |
a4 |
Parameter 4. |
Returns error message with 5 parameters.
public String getMessage5( int errId, String a1, String a2, String a3, String a4, String a5);
Parameter | Description |
---|---|
errId |
The error id. |
a1 |
Parameter 1. |
a2 |
Parameter 2. |
a3 |
Parameter 3. |
a4 |
Parameter 4. |
a5 |
Parameter 5. |
Returns the type of the error message type at specified index
public int getMessageType(int i);
Parameter | Description |
---|---|
i |
Index |
Returns the total number of errors/warnings found during parsing
public int getNumMessages()
Returns the public ID of input when error at specified index occured
public String getPublicId( int i);
Parameter | Description |
---|---|
i |
Index. |
Returns the system ID of input when error at specified index occured.
public String getSystemId(int i);
Parameter | Description |
---|---|
i |
Index. |
Flushes all the JAXP 1.1 errors to the ErrorListener. If no ErrorListener was set, defaults to System.err.
public void printErrorListener();
Resets the error class.
public void reset();
Sets an output stream for error reporting. The options are described in the following table.
Parameter | Description |
---|---|
out |
Output for errors/warnings. |
enc |
Encoding of the output stream. |
Registers an exception.
public void setException( java.lang.Exception exp);
Parameter | Description |
---|---|
exp |
Last exception which occured. |
Registers a locale for error reporting.
public void setLocale( java.util.Locale locale);
Parameter | Description |
---|---|
locale |
The locale for error reporting. |
Register a locator
public void setLocator( org.xml.sax.Locator locator);
Parameter | Description |
---|---|
locator |
Locator to get lin/col/sysid/pubid information. |
Turns reporting warning on/off.
public void showWarnings(boolean flag);
Parameter | Description |
---|---|
flag |
Controls reporting of warnings. |
The XML Exception class in package oracle.xml.util
indicates that a parsing exception occurred while processing an XML document.
public class XMLException extends java.lang.Exception java.lang.Object | +--java.lang.Throwable | +--java.lang.Exception | +--oracle.xml.util.XMLException
java.io.Serializable
Generates an XML Exception. The options are described in the following table.
Parameter | Description |
---|---|
mesg |
Message. |
pubId |
Public Id. |
sysId |
System Id. |
line |
Line. |
col |
Column. |
type |
Type. |
err |
Error. |
e |
Exception. |
firsterr |
First error. |
Returns the error message at specified index.
public String formatErrorMessage( int i);
Parameter | Description |
---|---|
i |
Index. |
Returns the column number of error at specified index.
public int getColumnNumber( int i);
Parameter | Description |
---|---|
i |
Index. |
Returns the exception (if exists) that occured in error at specified index
public java.lang.Exception getException( int i);
Parameter | Description |
---|---|
i |
Index |
Returns the line number of error at specified index
public int getLineNumber(int i);
Parameter | Description |
---|---|
i |
Index. |
Returns the error message at specified index
public String getMessage(int i).
Parameter | Description |
---|---|
i |
Index. |
Get the type of the error message at specified index
public int getMessageType(int i);
Parameter | Description |
---|---|
i |
Index. |
Returns the total number of errors/warnings found during parsing
public int getNumMessages();
Returns the public ID of input when error at specified index occured
public String getPublicId(int i);
Parameter | Description |
---|---|
i |
Index. |
Returns the system ID of input when error at specified index occured
public String getSystemId(int i);
Parameter | Description |
---|---|
i |
Index. |
Get XMLError object inside XMLException.
public XMLError
getXMLError();
Prints Throwable
and its backtrace. The options are described in the following table.
Parameter | Description |
---|---|
s |
Output for the stack trace. |
Sets the underlying exception, if it exists.
public void setException(java.lang.Exception ex);
Parameter | Description |
---|---|
ex |
The exception |
Returns any embedded exception.
public String toString();
|
Copyright © 2001, 2002 Oracle Corporation. All Rights Reserved. |
|