You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by le...@locus.apache.org on 2000/05/09 01:08:41 UTC
cvs commit: xml-xerces/java/src/org/xml/sax/helpers AttributeListImpl.java AttributesImpl.java DefaultHandler.java LocatorImpl.java NamespaceSupport.java ParserAdapter.java ParserFactory.java XMLFilterImpl.java XMLReaderAdapter.java XMLReaderFactory.java
lehors 00/05/08 16:08:41
Modified: java/src/org/xml/sax AttributeList.java Attributes.java
ContentHandler.java DTDHandler.java
DocumentHandler.java EntityResolver.java
ErrorHandler.java HandlerBase.java InputSource.java
Locator.java Parser.java SAXException.java
SAXNotRecognizedException.java
SAXNotSupportedException.java
SAXParseException.java XMLFilter.java
XMLReader.java
java/src/org/xml/sax/helpers AttributeListImpl.java
AttributesImpl.java DefaultHandler.java
LocatorImpl.java NamespaceSupport.java
ParserAdapter.java ParserFactory.java
XMLFilterImpl.java XMLReaderAdapter.java
XMLReaderFactory.java
Log:
updated to SAX2
Revision Changes Path
1.4 +2 -2 xml-xerces/java/src/org/xml/sax/AttributeList.java
Index: AttributeList.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/AttributeList.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AttributeList.java 2000/03/06 21:06:33 1.3
+++ AttributeList.java 2000/05/08 23:08:31 1.4
@@ -1,6 +1,6 @@
// SAX Attribute List Interface.
// No warranty; no copyright -- use this as you will.
-// $Id: AttributeList.java,v 1.2 2000/01/21 14:44:51 david Exp $
+// $Id: AttributeList.java,v 1.4 2000/05/05 17:44:56 david Exp $
package org.xml.sax;
@@ -63,7 +63,7 @@
* @since SAX 1.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.DocumentHandler#startElement startElement
* @see org.xml.sax.helpers.AttributeListImpl AttributeListImpl
*/
1.3 +75 -29 xml-xerces/java/src/org/xml/sax/Attributes.java
Index: Attributes.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/Attributes.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Attributes.java 2000/03/06 21:06:33 1.2
+++ Attributes.java 2000/05/08 23:08:31 1.3
@@ -2,7 +2,7 @@
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the public domain.
-// $Id: Attributes.java,v 1.3 2000/02/25 12:06:05 david Exp $
+// $Id: Attributes.java,v 1.5 2000/05/05 17:45:09 david Exp $
package org.xml.sax;
@@ -22,30 +22,34 @@
* <ol>
* <li>by attribute index;</li>
* <li>by Namespace-qualified name; or</li>
- * <li>by raw XML 1.0 name.</li>
+ * <li>by qualified (prefixed) name.</li>
* </ol>
*
* <p>The list will not contain attributes that were declared
* #IMPLIED but not specified in the start tag. It will also not
* contain attributes used as Namespace declarations (xmlns*) unless
- * the http://xml.org/sax/features/namespace-prefixes feature is set to
- * true (it is false by default).</p>
+ * the <code>http://xml.org/sax/features/namespace-prefixes</code>
+ * feature is set to <var>true</var> (it is <var>false</var> by
+ * default).</p>
+ *
+ * <p>If the namespace-prefixes feature (see above) is <var>false</var>,
+ * access by qualified name may not be available; if the
+ * <code>http://xml.org/sax/features/namespaces</code>
+ * feature is <var>false</var>, access by Namespace-qualified names
+ * may not be available.</p>
+ *
+ * <p>This interface replaces the now-deprecated SAX1 {@link
+ * org.xml.sax.AttributeList AttributeList} interface, which does not
+ * contain Namespace support. In addition to Namespace support, it
+ * adds the <var>getIndex</var> methods (below).</p>
*
- * <p>If the namespace-prefixes feature is false, access by raw XML 1.0
- * may not be available; if the http://xml.org/sax/features/namespaces
- * feature is false, access by Namespace-qualified names may not
- * be available.</p>
- *
- * <p>This interface replaces the now-deprecated SAX1 AttributeList
- * interface, which does not contain Namespace support. In addition
- * to Namespace support, it adds the getIndex methods.</p>
+ * <p>The order of attributes in the list is unspecified, and will
+ * vary from implementation to implementation.</p>
*
- * <p>The order of attributes in the list is random.</p>
- *
* @since SAX 2.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.helpers.AttributeListImpl
*/
public interface Attributes
@@ -60,7 +64,15 @@
/**
* Return the number of attributes in the list.
*
+ * <p>Once you know the number of attributes, you can iterate
+ * through the list.</p>
+ *
* @return The number of attributes in the list.
+ * @see #getURI(int)
+ * @see #getLocalName(int)
+ * @see #getQName(int)
+ * @see #getType(int)
+ * @see #getValue(int)
*/
public abstract int getLength ();
@@ -72,6 +84,7 @@
* @return The Namespace URI, or the empty string if none
* is available, or null if the index is out of
* range.
+ * @see #getLength
*/
public abstract String getURI (int index);
@@ -83,27 +96,42 @@
* @return The local name, or the empty string if Namespace
* processing is not being performed, or null
* if the index is out of range.
+ * @see #getLength
*/
public abstract String getLocalName (int index);
/**
- * Look up an attribute's raw XML 1.0 name by index.
+ * Look up an attribute's XML 1.0 qualified name by index.
*
* @param index The attribute index (zero-based).
- * @return The raw XML 1.0 name, or the empty string
+ * @return The XML 1.0 qualified name, or the empty string
* if none is available, or null if the index
* is out of range.
+ * @see #getLength
*/
- public abstract String getRawName (int index);
+ public abstract String getQName (int index);
/**
* Look up an attribute's type by index.
*
+ * <p>The attribute type is one of the strings "CDATA", "ID",
+ * "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",
+ * or "NOTATION" (always in upper case).</p>
+ *
+ * <p>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 Recommentation
+ * (clause 3.3.3, "Attribute-Value Normalization").</p>
+ *
+ * <p>For an enumerated attribute that is not a notation, the
+ * parser will report the type as "NMTOKEN".</p>
+ *
* @param index The attribute index (zero-based).
* @return The attribute's type as a string, or null if the
* index is out of range.
+ * @see #getLength
*/
public abstract String getType (int index);
@@ -111,9 +139,15 @@
/**
* Look up an attribute's value by index.
*
+ * <p>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.</p>
+ *
* @param index The attribute index (zero-based).
* @return The attribute's value as a string, or null if the
* index is out of range.
+ * @see #getLength
*/
public abstract String getValue (int index);
@@ -137,18 +171,21 @@
/**
- * Look up the index of an attribute by raw XML 1.0 name.
+ * Look up the index of an attribute by XML 1.0 qualified name.
*
- * @param rawName The raw (prefixed) name.
+ * @param qName The qualified (prefixed) name.
* @return The index of the attribute, or -1 if it does not
* appear in the list.
*/
- public int getIndex (String rawName);
+ public int getIndex (String qName);
/**
* Look up an attribute's type by Namespace name.
*
+ * <p>See {@link #getType(int) getType(int)} for a description
+ * of the possible types.</p>
+ *
* @param uri The Namespace URI, or the empty String if the
* name has no Namespace URI.
* @param localName The local name of the attribute.
@@ -160,19 +197,25 @@
/**
- * Look up an attribute's type by raw XML 1.0 name.
+ * Look up an attribute's type by XML 1.0 qualified name.
+ *
+ * <p>See {@link #getType(int) getType(int)} for a description
+ * of the possible types.</p>
*
- * @param rawName The raw XML 1.0 name.
+ * @param qName The XML 1.0 qualified name.
* @return The attribute type as a string, or null if the
- * attribute is not in the list or if raw names
+ * attribute is not in the list or if qualified names
* are not available.
*/
- public abstract String getType (String rawName);
+ public abstract String getType (String qName);
/**
* Look up an attribute's value by Namespace name.
*
+ * <p>See {@link #getValue(int) getValue(int)} for a description
+ * of the possible values.</p>
+ *
* @param uri The Namespace URI, or the empty String if the
* name has no Namespace URI.
* @param localName The local name of the attribute.
@@ -183,14 +226,17 @@
/**
- * Look up an attribute's value by raw XML 1.0 name.
+ * Look up an attribute's value by XML 1.0 qualified name.
+ *
+ * <p>See {@link #getValue(int) getValue(int)} for a description
+ * of the possible values.</p>
*
- * @param rawName The raw XML 1.0 name.
+ * @param qName The XML 1.0 qualified name.
* @return The attribute value as a string, or null if the
- * attribute is not in the list or if raw names
+ * attribute is not in the list or if qualified names
* are not available.
*/
- public abstract String getValue (String rawName);
+ public abstract String getValue (String qName);
}
1.3 +78 -49 xml-xerces/java/src/org/xml/sax/ContentHandler.java
Index: ContentHandler.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/ContentHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ContentHandler.java 2000/03/06 21:06:33 1.2
+++ ContentHandler.java 2000/05/08 23:08:31 1.3
@@ -2,7 +2,7 @@
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the public domain.
-// $Id: ContentHandler.java,v 1.3 2000/02/25 14:55:41 david Exp $
+// $Id: ContentHandler.java,v 1.5 2000/05/05 17:45:39 david Exp $
package org.xml.sax;
@@ -18,9 +18,10 @@
* <p>This is the main interface that most SAX applications
* implement: if the application needs to be informed of basic parsing
* events, it implements this interface and registers an instance with
- * the SAX parser using the setDocumentHandler method. The parser
- * uses the instance to report basic document-related events like
- * the start and end of elements and character data.</p>
+ * the SAX parser using the {@link org.xml.sax.XMLReader#setContentHandler
+ * setContentHandler} method. The parser uses the instance to report
+ * basic document-related events like the start and end of elements
+ * and character data.</p>
*
* <p>The order of events in this interface is very important, and
* mirrors the order of information in the document itself. For
@@ -28,15 +29,28 @@
* instructions, and/or subelements) will appear, in order, between
* the startElement event and the corresponding endElement event.</p>
*
- * <p>This interface is based on the now-deprecated SAX 1.0
+ * <p>This interface is similar to the now-deprecated SAX 1.0
* DocumentHandler interface, but it adds support for Namespaces
- * and for reporting skipped entitys (in non-validating XML
+ * and for reporting skipped entities (in non-validating XML
* processors).</p>
*
+ * <p>Implementors should note that there is also a Java class
+ * {@link java.net.ContentHandler ContentHandler} in the java.net
+ * package; that means that it's probably a bad idea to do</p>
+ *
+ * <blockquote>
+ * import java.net.*;
+ * import org.xml.sax.*;
+ * </blockquote>
+ *
+ * <p>In fact, "import ...*" is usually a sign of sloppy programming
+ * anyway, so the user should consider this a feature rather than a
+ * bug.</p>
+ *
* @since SAX 2.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.XMLReader
* @see org.xml.sax.DTDHandler
* @see org.xml.sax.ErrorHandler
@@ -50,7 +64,7 @@
* <p>SAX parsers are strongly encouraged (though not absolutely
* required) to supply a locator: if it does so, it must supply
* the locator to the application by invoking this method before
- * invoking any of the other methods in the DocumentHandler
+ * invoking any of the other methods in the ContentHandler
* interface.</p>
*
* <p>The locator allows the application to determine the end
@@ -76,11 +90,13 @@
* Receive notification of the beginning of a document.
*
* <p>The SAX parser will invoke this method only once, before any
- * other methods in this interface or in DTDHandler (except for
- * setDocumentLocator).</p>
+ * other methods in this interface or in {@link org.xml.sax.DTDHandler
+ * DTDHandler} (except for {@link #setDocumentLocator
+ * setDocumentLocator}).</p>
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
+ * @see #endDocument
*/
public void startDocument ()
throws SAXException;
@@ -97,18 +113,20 @@
*
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
+ * @see #startDocument
*/
public void endDocument()
throws SAXException;
+
/**
* Begin the scope of a prefix-URI Namespace mapping.
*
* <p>The information from this event is not necessary for
* normal Namespace processing: the SAX XML reader will
* automatically replace prefixes for element and attribute
- * names when the http://xml.org/sax/features/namespaces
- * feature is true (the default).</p>
+ * names when the <code>http://xml.org/sax/features/namespaces</code>
+ * feature is <var>true</var> (the default).</p>
*
* <p>There are cases, however, when applications need to
* use prefixes in character data or in attribute values,
@@ -120,9 +138,14 @@
* <p>Note that start/endPrefixMapping events are not
* guaranteed to be properly nested relative to each-other:
* all startPrefixMapping events will occur before the
- * corresponding startElement event, and all endPrefixMapping
- * events will occur after the corresponding endElement event,
- * but their order is not guaranteed.</p>
+ * corresponding {@link #startElement startElement} event,
+ * and all {@link #endPrefixMapping endPrefixMapping}
+ * events will occur after the corresponding {@link #endElement
+ * endElement} event, but their order is not otherwise
+ * guaranteed.</p>
+ *
+ * <p>There should never be start/endPrefixMapping events for the
+ * "xml" prefix, since it is predeclared and immutable.</p>
*
* @param prefix The Namespace prefix being declared.
* @param uri The Namespace URI the prefix is mapped to.
@@ -138,9 +161,10 @@
/**
* End the scope of a prefix-URI mapping.
*
- * <p>See startPrefixMapping for details. This event will
- * always occur after the corresponding endElement event,
- * but the order of endPrefixMapping events is not otherwise
+ * <p>See {@link #startPrefixMapping startPrefixMapping} for
+ * details. This event will always occur after the corresponding
+ * {@link #endElement endElement} event, but the order of
+ * {@link #endPrefixMapping endPrefixMapping} events is not otherwise
* guaranteed.</p>
*
* @param prefix The prefix that was being mapping.
@@ -158,9 +182,9 @@
*
* <p>The Parser will invoke this method at the beginning of every
* element in the XML document; there will be a corresponding
- * endElement() event for every startElement() event (even when
- * the element is empty). All of the element's content will be
- * reported, in order, before the corresponding endElement()
+ * {@link #endElement endElement} event for every startElement event
+ * (even when the element is empty). All of the element's content will be
+ * reported, in order, before the corresponding endElement
* event.</p>
*
* <p>This event allows up to three name components for each
@@ -169,22 +193,22 @@
* <ol>
* <li>the Namespace URI;</li>
* <li>the local name; and</li>
- * <li>the raw XML 1.0 name.</li>
+ * <li>the qualified (prefixed) name.</li>
* </ol>
*
* <p>Any or all of these may be provided, depending on the
- * values of the http://xml.org/sax/features/namespaces
- * and the http://xml.org/sax/features/namespace-prefixes
+ * values of the <var>http://xml.org/sax/features/namespaces</var>
+ * and the <var>http://xml.org/sax/features/namespace-prefixes</var>
* properties:</p>
*
* <ul>
* <li>the Namespace URI and local name are required when
- * the namespaces property is true (the default), and are
- * optional when the namespaces property is false (if one is
+ * the namespaces property is <var>true</var> (the default), and are
+ * optional when the namespaces property is <var>false</var> (if one is
* specified, both must be);</li>
- * <li>the raw name is required when the namespace-prefixes property
- * is true, and is optional when the namespace-prefixes property
- * is false (the default).</li>
+ * <li>the qualified name is required when the namespace-prefixes property
+ * is <var>true</var>, and is optional when the namespace-prefixes property
+ * is <var>false</var> (the default).</li>
* </ul>
*
* <p>Note that the attribute list provided will contain only
@@ -192,9 +216,9 @@
* #IMPLIED attributes will be omitted. The attribute list
* will contain attributes used for Namespace declarations
* (xmlns* attributes) only if the
- * http://xml.org/sax/features/namespace-prefixes property is true
- * (it is false by default, and support for a true value is
- * optional).</p>
+ * <code>http://xml.org/sax/features/namespace-prefixes</code>
+ * property is true (it is false by default, and support for a
+ * true value is optional).</p>
*
* @param uri The Namespace URI, or the empty string if the
* element has no Namespace URI or if Namespace
@@ -202,8 +226,8 @@
* @param localName The local name (without prefix), or the
* empty string if Namespace processing is not being
* performed.
- * @param rawName The raw XML 1.0 name (with prefix), or the
- * empty string if raw names are not available.
+ * @param qName The qualified name (with prefix), or the
+ * empty string if qualified names are not available.
* @param atts The attributes attached to the element. If
* there are no attributes, it shall be an empty
* Attributes object.
@@ -213,7 +237,7 @@
* @see org.xml.sax.Attributes
*/
public void startElement (String namespaceURI, String localName,
- String rawName, Attributes atts)
+ String qName, Attributes atts)
throws SAXException;
@@ -222,8 +246,8 @@
*
* <p>The SAX parser will invoke this method at the end of every
* element in the XML document; there will be a corresponding
- * startElement() event for every endElement() event (even when the
- * element is empty).</p>
+ * {@link #startElement startElement} event for every endElement
+ * event (even when the element is empty).</p>
*
* <p>For information on the names, see startElement.</p>
*
@@ -233,13 +257,13 @@
* @param localName The local name (without prefix), or the
* empty string if Namespace processing is not being
* performed.
- * @param rawName The raw XML 1.0 name (with prefix), or the
- * empty string if raw names are not available.
+ * @param qName The qualified XML 1.0 name (with prefix), or the
+ * empty string if qualified names are not available.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
public void endElement (String namespaceURI, String localName,
- String rawName)
+ String qName)
throws SAXException;
@@ -256,9 +280,10 @@
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
- * <p>Note that some parsers will report whitespace using the
- * ignorableWhitespace() method rather than this one (validating
- * parsers <em>must</em> do so).</p>
+ * <p>Note that some parsers will report whitespace in element
+ * content using the {@link #ignorableWhitespace ignorableWhitespace}
+ * method rather than this one (validating parsers <em>must</em>
+ * do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
@@ -276,7 +301,7 @@
* Receive notification of ignorable whitespace in element content.
*
* <p>Validating Parsers must use this method to report each chunk
- * of ignorable whitespace (see the W3C XML 1.0 recommendation,
+ * of whitespace in element content (see the W3C XML 1.0 recommendation,
* section 2.10): non-validating parsers may also use this method
* if they are capable of parsing and using content models.</p>
*
@@ -307,13 +332,14 @@
* instruction found: note that processing instructions may occur
* before or after the main document element.</p>
*
- * <p>A SAX parser should never report an XML declaration (XML 1.0,
+ * <p>A SAX parser must never report an XML declaration (XML 1.0,
* section 2.8) or a text declaration (XML 1.0, section 4.3.1)
* using this method.</p>
*
* @param target The processing instruction target.
* @param data The processing instruction data, or null if
- * none was supplied.
+ * none was supplied. The data does not include any
+ * whitespace separating it from the target.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
@@ -329,12 +355,15 @@
* have not seen the declarations (because, for example, the
* entity was declared in an external DTD subset). All processors
* may skip external entities, depending on the values of the
- * http://xml.org/sax/features/external-general-entities and the
- * http://xml.org/sax/features/external-parameter-entities
+ * <code>http://xml.org/sax/features/external-general-entities</code>
+ * and the
+ * <code>http://xml.org/sax/features/external-parameter-entities</code>
* properties.</p>
*
* @param name The name of the skipped entity. If it is a
- * parameter entity, the name will begin with '%'.
+ * parameter entity, the name will begin with '%', and if
+ * it is the external DTD subset, it will be the string
+ * "[dtd]".
* @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception.
*/
1.4 +16 -12 xml-xerces/java/src/org/xml/sax/DTDHandler.java
Index: DTDHandler.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/DTDHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DTDHandler.java 2000/03/06 21:06:33 1.3
+++ DTDHandler.java 2000/05/08 23:08:31 1.4
@@ -1,6 +1,6 @@
// SAX DTD handler.
// No warranty; no copyright -- use this as you will.
-// $Id: DTDHandler.java,v 1.2 2000/01/21 15:19:32 david Exp $
+// $Id: DTDHandler.java,v 1.4 2000/05/05 17:46:02 david Exp $
package org.xml.sax;
@@ -19,6 +19,10 @@
* instance to report notation and unparsed entity declarations to
* the application.</p>
*
+ * <p>Note that this interface includes only those DTD events that
+ * the XML recommendation <em>requires</em> processors to report:
+ * notation and unparsed entity declarations.</p>
+ *
* <p>The SAX parser may report these events in any order, regardless
* of the order in which the notations and unparsed entities were
* declared; however, all DTD events must be reported after the
@@ -32,13 +36,10 @@
* obtained through this interface to find the entity and/or
* notation corresponding with the attribute value.</p>
*
- * <p>The HandlerBase class provides a default implementation
- * of this interface, which simply ignores the events.</p>
- *
* @since SAX 1.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.Parser#setDTDHandler
* @see org.xml.sax.HandlerBase
*/
@@ -51,10 +52,14 @@
* <p>It is up to the application to record the notation for later
* reference, if necessary.</p>
*
- * <p>If a system identifier is present, and it is a URL, the SAX
+ * <p>At least one of publicId and systemId must be non-null.
+ * If a system identifier is present, and it is a URL, the SAX
* parser must resolve it fully before passing it to the
- * application.</p>
+ * application through this event.</p>
*
+ * <p>There is no guarantee that the notation declaration will be
+ * reported before any unparsed entities that use it.</p>
+ *
* @param name The notation name.
* @param publicId The notation's public identifier, or null if
* none was given.
@@ -75,9 +80,9 @@
* Receive notification of an unparsed entity declaration event.
*
* <p>Note that the notation name corresponds to a notation
- * reported by the notationDecl() event. It is up to the
- * application to record the entity for later reference, if
- * necessary.</p>
+ * reported by the {@link #notationDecl notationDecl} event.
+ * It is up to the application to record the entity for later
+ * reference, if necessary.</p>
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before passing it to the application.</p>
@@ -87,8 +92,7 @@
* @param name The unparsed entity's name.
* @param publicId The entity's public identifier, or null if none
* was given.
- * @param systemId The entity's system identifier (it must always
- * have one).
+ * @param systemId The entity's system identifier.
* @param notation name The name of the associated notation.
* @see #notationDecl
* @see org.xml.sax.AttributeList
1.4 +2 -2 xml-xerces/java/src/org/xml/sax/DocumentHandler.java
Index: DocumentHandler.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/DocumentHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DocumentHandler.java 2000/03/06 21:06:33 1.3
+++ DocumentHandler.java 2000/05/08 23:08:31 1.4
@@ -1,6 +1,6 @@
// SAX document handler.
// No warranty; no copyright -- use this as you will.
-// $Id: DocumentHandler.java,v 1.2 2000/01/21 15:21:16 david Exp $
+// $Id: DocumentHandler.java,v 1.4 2000/05/05 17:46:11 david Exp $
package org.xml.sax;
@@ -37,7 +37,7 @@
* @since SAX 1.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.Parser#setDocumentHandler
* @see org.xml.sax.Locator
* @see org.xml.sax.HandlerBase
1.4 +6 -10 xml-xerces/java/src/org/xml/sax/EntityResolver.java
Index: EntityResolver.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/EntityResolver.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- EntityResolver.java 2000/03/06 21:06:33 1.3
+++ EntityResolver.java 2000/05/08 23:08:31 1.4
@@ -1,6 +1,6 @@
// SAX entity resolver.
// No warranty; no copyright -- use this as you will.
-// $Id: EntityResolver.java,v 1.2 2000/01/21 15:22:04 david Exp $
+// $Id: EntityResolver.java,v 1.4 2000/05/05 17:46:19 david Exp $
package org.xml.sax;
@@ -17,10 +17,11 @@
*
* <p>If a SAX application needs to implement customized handling
* for external entities, it must implement this interface and
- * register an instance with the SAX parser using the parser's
- * setEntityResolver method.</p>
+ * register an instance with the SAX driver using the
+ * {@link org.xml.sax.XMLReader#setEntityResolver setEntityResolver}
+ * method.</p>
*
- * <p>The parser will then allow the application to intercept any
+ * <p>The XML reader will then allow the application to intercept any
* external entities (including the external DTD subset and external
* parameter entities, if any) before including them.</p>
*
@@ -56,17 +57,12 @@
* identifiers to local URIs or to look up replacements in a catalog
* (possibly by using the public identifier).</p>
*
- * <p>The HandlerBase class implements the default behaviour for
- * this interface, which is simply always to return null (to request
- * that the parser use the default system identifier).</p>
- *
* @since SAX 1.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.Parser#setEntityResolver
* @see org.xml.sax.InputSource
- * @see org.xml.sax.HandlerBase
*/
public interface EntityResolver {
1.4 +20 -16 xml-xerces/java/src/org/xml/sax/ErrorHandler.java
Index: ErrorHandler.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/ErrorHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ErrorHandler.java 2000/03/06 21:06:33 1.3
+++ ErrorHandler.java 2000/05/08 23:08:32 1.4
@@ -1,6 +1,6 @@
// SAX error handler.
// No warranty; no copyright -- use this as you will.
-// $Id: ErrorHandler.java,v 1.2 2000/01/21 15:22:22 david Exp $
+// $Id: ErrorHandler.java,v 1.4 2000/05/05 17:46:27 david Exp $
package org.xml.sax;
@@ -15,31 +15,29 @@
*
* <p>If a SAX application needs to implement customized error
* handling, it must implement this interface and then register an
- * instance with the SAX parser using the parser's setErrorHandler
+ * instance with the XML reader using the
+ * {@link org.xml.sax.XMLReader#setErrorHandler setErrorHandler}
* method. The parser will then report all errors and warnings
* through this interface.</p>
*
- * <p> The parser shall use this interface instead of throwing an
- * exception: it is up to the application whether to throw an
- * exception for different types of errors and warnings. Note,
- * however, that there is no requirement that the parser continue to
- * provide useful information after a call to fatalError (in other
- * words, a SAX driver class could catch an exception and report a
- * fatalError).</p>
+ * <p><strong>WARNING:</strong> If an application does <em>not</em>
+ * register an ErrorHandler, XML parsing errors will go unreported
+ * and bizarre behaviour may result.</p>
*
- * <p>The HandlerBase class provides a default implementation of this
- * interface, ignoring warnings and recoverable errors and throwing a
- * SAXParseException for fatal errors. An application may extend
- * that class rather than implementing the complete interface
- * itself.</p>
+ * <p>For XML processing errors, a SAX driver must use this interface
+ * instead of throwing an exception: it is up to the application
+ * to decide whether to throw an exception for different types of
+ * errors and warnings. Note, however, that there is no requirement that
+ * the parser continue to provide useful information after a call to
+ * {@link #fatalError fatalError} (in other words, a SAX driver class
+ * could catch an exception and report a fatalError).</p>
*
* @since SAX 1.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.Parser#setErrorHandler
* @see org.xml.sax.SAXParseException
- * @see org.xml.sax.HandlerBase
*/
public interface ErrorHandler {
@@ -55,6 +53,9 @@
* after invoking this method: it should still be possible for the
* application to process the document through to the end.</p>
*
+ * <p>Filters may use this method to report other, non-XML warnings
+ * as well.</p>
+ *
* @param exception The warning information encapsulated in a
* SAX parse exception.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
@@ -80,6 +81,9 @@
* application cannot do so, then the parser should report a fatal
* error even if the XML 1.0 recommendation does not require it to
* do so.</p>
+ *
+ * <p>Filters may use this method to report other, non-XML errors
+ * as well.</p>
*
* @param exception The error information encapsulated in a
* SAX parse exception.
1.4 +6 -5 xml-xerces/java/src/org/xml/sax/HandlerBase.java
Index: HandlerBase.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/HandlerBase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HandlerBase.java 2000/03/06 21:06:33 1.3
+++ HandlerBase.java 2000/05/08 23:08:32 1.4
@@ -1,6 +1,6 @@
// SAX default handler base class.
// No warranty; no copyright -- use this as you will.
-// $Id: HandlerBase.java,v 1.3 2000/01/26 13:24:19 david Exp $
+// $Id: HandlerBase.java,v 1.5 2000/05/05 17:46:37 david Exp $
package org.xml.sax;
@@ -15,7 +15,9 @@
* <p>This class implements the default behaviour for four SAX1
* interfaces: EntityResolver, DTDHandler, DocumentHandler,
* and ErrorHandler. It is now obsolete, but is included in SAX2 to
- * support legacy SAX1 applications.</p>
+ * support legacy SAX1 applications. SAX2 applications should use
+ * the {@link org.xml.sax.helpers.DefaultHandler DefaultHandler}
+ * class instead.</p>
*
* <p>Application writers can extend this class when they need to
* implement only part of an interface; parser writers can
@@ -32,15 +34,14 @@
* @since SAX 1.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.EntityResolver
* @see org.xml.sax.DTDHandler
* @see org.xml.sax.DocumentHandler
* @see org.xml.sax.ErrorHandler
*/
public class HandlerBase
- implements EntityResolver, DTDHandler,
- DocumentHandler, ErrorHandler
+ implements EntityResolver, DTDHandler, DocumentHandler, ErrorHandler
{
1.4 +4 -2 xml-xerces/java/src/org/xml/sax/InputSource.java
Index: InputSource.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/InputSource.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- InputSource.java 2000/03/06 21:06:34 1.3
+++ InputSource.java 2000/05/08 23:08:32 1.4
@@ -1,6 +1,6 @@
// SAX input source.
// No warranty; no copyright -- use this as you will.
-// $Id: InputSource.java,v 1.3 2000/01/21 15:42:24 david Exp $
+// $Id: InputSource.java,v 1.5 2000/05/05 17:46:48 david Exp $
package org.xml.sax;
@@ -40,7 +40,7 @@
* @since SAX 1.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.Parser#parse
* @see org.xml.sax.EntityResolver#resolveEntity
* @see java.io.InputStream
@@ -317,3 +317,5 @@
private Reader characterStream;
}
+
+// end of InputSource.java
1.4 +53 -16 xml-xerces/java/src/org/xml/sax/Locator.java
Index: Locator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/Locator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Locator.java 2000/03/06 21:06:34 1.3
+++ Locator.java 2000/05/08 23:08:32 1.4
@@ -1,6 +1,6 @@
// SAX locator interface for document events.
// No warranty; no copyright -- use this as you will.
-// $Id: Locator.java,v 1.2 2000/01/21 15:42:50 david Exp $
+// $Id: Locator.java,v 1.4 2000/05/05 17:46:57 david Exp $
package org.xml.sax;
@@ -15,35 +15,41 @@
*
* <p>If a SAX parser provides location information to the SAX
* application, it does so by implementing this interface and then
- * passing an instance to the application using the document
- * handler's setDocumentLocator method. The application can use the
- * object to obtain the location of any other document handler event
+ * passing an instance to the application using the content
+ * handler's {@link org.xml.sax.ContentHandler#setDocumentLocator
+ * setDocumentLocator} method. The application can use the
+ * object to obtain the location of any other content handler event
* in the XML source document.</p>
*
* <p>Note that the results returned by the object will be valid only
- * during the scope of each document handler method: the application
+ * during the scope of each content handler method: the application
* will receive unpredictable results if it attempts to use the
* locator at any other time.</p>
*
* <p>SAX parsers are not required to supply a locator, but they are
- * very strong encouraged to do so. If the parser supplies a
+ * very strongly encouraged to do so. If the parser supplies a
* locator, it must do so before reporting any other document events.
* If no locator has been set by the time the application receives
- * the startDocument event, the application should assume that a
- * locator is not available.</p>
+ * the {@link org.xml.sax.ContentHandler#startDocument startDocument}
+ * event, the application should assume that a locator is not
+ * available.</p>
*
* @since SAX 1.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
- * @see org.xml.sax.DocumentHandler#setDocumentLocator
+ * @version 2.0
+ * @see org.xml.sax.ContentHandler#setDocumentLocator
*/
public interface Locator {
/**
* Return the public identifier for the current document event.
- * <p>This will be the public identifier
+ *
+ * <p>The return value is the public identifier of the document
+ * entity or of the external parsed entity in which the markup
+ * triggering the event appears.</p>
+ *
* @return A string containing the public identifier, or
* null if none is available.
* @see #getSystemId
@@ -54,6 +60,10 @@
/**
* Return the system identifier for the current document event.
*
+ * <p>The return value is the system identifier of the document
+ * entity or of the external parsed entity in which the markup
+ * triggering the event appears.</p>
+ *
* <p>If the system identifier is a URL, the parser must resolve it
* fully before passing it to the application.</p>
*
@@ -66,8 +76,20 @@
/**
* Return the line number where the current document event ends.
- * Note that this is the line position of the first character
- * after the text associated with the document event.
+ *
+ * <p><strong>Warning:</strong> The return value from the method
+ * is intended only as an approximation for the sake of error
+ * reporting; it is not intended to provide sufficient information
+ * to edit the character content of the original XML document.</p>
+ *
+ * <p>The return value is an approximation of the line number
+ * in the document entity or external parsed entity where the
+ * markup triggering the event appears.</p>
+ *
+ * <p>If possible, the SAX driver should provide the line position
+ * of the first character after the text associated with the document
+ * event. The first line in the document is line 1.</p>
+ *
* @return The line number, or -1 if none is available.
* @see #getColumnNumber
*/
@@ -76,9 +98,24 @@
/**
* Return the column number where the current document event ends.
- * Note that this is the column number of the first
- * character after the text associated with the document
- * event. The first column in a line is position 1.
+ *
+ * <p><strong>Warning:</strong> The return value from the method
+ * is intended only as an approximation for the sake of error
+ * reporting; it is not intended to provide sufficient information
+ * to edit the character content of the original XML document.</p>
+ *
+ * <p>The return value is an approximation of the column number
+ * in the document entity or external parsed entity where the
+ * markup triggering the event appears.</p>
+ *
+ * <p>If possible, the SAX driver should provide the line position
+ * of the first character after the text associated with the document
+ * event.</p>
+ *
+ * <p>If possible, the SAX driver should provide the line position
+ * of the first character after the text associated with the document
+ * event. The first column in each line is column 1.</p>
+ *
* @return The column number, or -1 if none is available.
* @see #getLineNumber
*/
1.4 +2 -2 xml-xerces/java/src/org/xml/sax/Parser.java
Index: Parser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/Parser.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Parser.java 2000/03/06 21:06:34 1.3
+++ Parser.java 2000/05/08 23:08:32 1.4
@@ -1,6 +1,6 @@
// SAX parser interface.
// No warranty; no copyright -- use this as you will.
-// $Id: Parser.java,v 1.3 2000/01/22 16:21:00 david Exp $
+// $Id: Parser.java,v 1.5 2000/05/05 17:47:07 david Exp $
package org.xml.sax;
@@ -39,7 +39,7 @@
* @since SAX 1.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.EntityResolver
* @see org.xml.sax.DTDHandler
* @see org.xml.sax.DocumentHandler
1.4 +4 -4 xml-xerces/java/src/org/xml/sax/SAXException.java
Index: SAXException.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/SAXException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SAXException.java 2000/03/06 21:06:34 1.3
+++ SAXException.java 2000/05/08 23:08:32 1.4
@@ -1,6 +1,6 @@
// SAX exception class.
// No warranty; no copyright -- use this as you will.
-// $Id: SAXException.java,v 1.2 2000/01/22 16:25:56 david Exp $
+// $Id: SAXException.java,v 1.4 2000/05/05 17:47:20 david Exp $
package org.xml.sax;
@@ -24,12 +24,12 @@
*
* <p>If the parser or application needs to include information about a
* specific location in an XML document, it should use the
- * SAXParseException subclass.</p>
+ * {@link org.xml.sax.SAXParseException SAXParseException} subclass.</p>
*
* @since SAX 1.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.SAXParseException
*/
public class SAXException extends Exception {
@@ -83,7 +83,7 @@
/**
* Return a detail message for this exception.
*
- * <p>If there is a embedded exception, and if the SAXException
+ * <p>If there is an embedded exception, and if the SAXException
* has no detail message of its own, this method will return
* the detail message from the embedded exception.</p>
*
1.4 +4 -2 xml-xerces/java/src/org/xml/sax/SAXNotRecognizedException.java
Index: SAXNotRecognizedException.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/SAXNotRecognizedException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SAXNotRecognizedException.java 2000/03/06 21:06:34 1.3
+++ SAXNotRecognizedException.java 2000/05/08 23:08:33 1.4
@@ -2,7 +2,7 @@
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the Public Domain.
-// $Id: SAXNotRecognizedException.java,v 1.2 2000/01/22 16:26:51 david Exp $
+// $Id: SAXNotRecognizedException.java,v 1.4 2000/05/05 17:47:28 david Exp $
package org.xml.sax;
@@ -23,11 +23,12 @@
* @since SAX 2.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.SAXNotSupportedException
*/
public class SAXNotRecognizedException extends SAXException
{
+
/**
* Construct a new exception with the given message.
*
@@ -37,6 +38,7 @@
{
super(message);
}
+
}
// end of SAXNotRecognizedException.java
1.4 +3 -3 xml-xerces/java/src/org/xml/sax/SAXNotSupportedException.java
Index: SAXNotSupportedException.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/SAXNotSupportedException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SAXNotSupportedException.java 2000/03/06 21:06:34 1.3
+++ SAXNotSupportedException.java 2000/05/08 23:08:33 1.4
@@ -2,7 +2,7 @@
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the Public Domain.
-// $Id: SAXNotSupportedException.java,v 1.3 2000/01/22 16:27:04 david Exp $
+// $Id: SAXNotSupportedException.java,v 1.5 2000/05/05 17:47:39 david Exp $
package org.xml.sax;
@@ -18,12 +18,12 @@
* <p>An XMLReader will throw this exception when it recognizes a
* feature or property identifier, but cannot perform the requested
* operation (setting a state or value). Other SAX2 applications and
- * extentions may use this class for similar purposes.</p>
+ * extensions may use this class for similar purposes.</p>
*
* @since SAX 2.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.SAXNotRecognizedException
*/
public class SAXNotSupportedException extends SAXException
1.4 +53 -29 xml-xerces/java/src/org/xml/sax/SAXParseException.java
Index: SAXParseException.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/SAXParseException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SAXParseException.java 2000/03/06 21:06:34 1.3
+++ SAXParseException.java 2000/05/08 23:08:33 1.4
@@ -1,6 +1,6 @@
// SAX exception class.
// No warranty; no copyright -- use this as you will.
-// $Id: SAXParseException.java,v 1.2 2000/01/22 16:29:41 david Exp $
+// $Id: SAXParseException.java,v 1.4 2000/05/05 17:48:16 david Exp $
package org.xml.sax;
@@ -15,17 +15,18 @@
* <p>This exception will include information for locating the error
* in the original XML document. Note that although the application
* will receive a SAXParseException as the argument to the handlers
- * in the ErrorHandler interface, the application is not actually
- * required to throw the exception; instead, it can simply read the
- * information in it and take a different action.</p>
+ * in the {@link org.xml.sax.ErrorHandler ErrorHandler} interface,
+ * the application is not actually required to throw the exception;
+ * instead, it can simply read the information in it and take a
+ * different action.</p>
*
- * <p>Since this exception is a subclass of SAXException, it
- * inherits the ability to wrap another exception.</p>
+ * <p>Since this exception is a subclass of {@link org.xml.sax.SAXException
+ * SAXException}, it inherits the ability to wrap another exception.</p>
*
* @since SAX 1.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.SAXException
* @see org.xml.sax.Locator
* @see org.xml.sax.ErrorHandler
@@ -36,25 +37,29 @@
//////////////////////////////////////////////////////////////////////
// Constructors.
//////////////////////////////////////////////////////////////////////
-
+
+
/**
* Create a new SAXParseException from a message and a Locator.
*
* <p>This constructor is especially useful when an application is
- * creating its own exception from within a DocumentHandler
- * callback.</p>
+ * creating its own exception from within a {@link org.xml.sax.ContentHandler
+ * ContentHandler} callback.</p>
*
* @param message The error or warning message.
- * @param locator The locator object for the error or warning.
+ * @param locator The locator object for the error or warning (may be
+ * null).
* @see org.xml.sax.Locator
* @see org.xml.sax.Parser#setLocale
*/
public SAXParseException (String message, Locator locator) {
super(message);
- this.publicId = locator.getPublicId();
- this.systemId = locator.getSystemId();
- this.lineNumber = locator.getLineNumber();
- this.columnNumber = locator.getColumnNumber();
+ if (locator != null) {
+ init(locator.getPublicId(), locator.getSystemId(),
+ locator.getLineNumber(), locator.getColumnNumber());
+ } else {
+ init(null, null, -1, -1);
+ }
}
@@ -62,24 +67,27 @@
* Wrap an existing exception in a SAXParseException.
*
* <p>This constructor is especially useful when an application is
- * creating its own exception from within a DocumentHandler
- * callback, and needs to wrap an existing exception that is not a
- * subclass of SAXException.</p>
+ * creating its own exception from within a {@link org.xml.sax.ContentHandler
+ * ContentHandler} callback, and needs to wrap an existing exception that is not a
+ * subclass of {@link org.xml.sax.SAXException SAXException}.</p>
*
* @param message The error or warning message, or null to
* use the message from the embedded exception.
- * @param locator The locator object for the error or warning.
- * @param e Any exception
+ * @param locator The locator object for the error or warning (may be
+ * null).
+ * @param e Any exception.
* @see org.xml.sax.Locator
* @see org.xml.sax.Parser#setLocale
*/
public SAXParseException (String message, Locator locator,
Exception e) {
super(message, e);
- this.publicId = locator.getPublicId();
- this.systemId = locator.getSystemId();
- this.lineNumber = locator.getLineNumber();
- this.columnNumber = locator.getColumnNumber();
+ if (locator != null) {
+ init(locator.getPublicId(), locator.getSystemId(),
+ locator.getLineNumber(), locator.getColumnNumber());
+ } else {
+ init(null, null, -1, -1);
+ }
}
@@ -106,10 +114,7 @@
int lineNumber, int columnNumber)
{
super(message);
- this.publicId = publicId;
- this.systemId = systemId;
- this.lineNumber = lineNumber;
- this.columnNumber = columnNumber;
+ init(publicId, systemId, lineNumber, columnNumber);
}
@@ -118,7 +123,7 @@
*
* <p>This constructor is most useful for parser writers who
* need to wrap an exception that is not a subclass of
- * SAXException.</p>
+ * {@link org.xml.sax.SAXException SAXException}.</p>
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before creating the exception.</p>
@@ -140,6 +145,23 @@
int lineNumber, int columnNumber, Exception e)
{
super(message, e);
+ init(publicId, systemId, lineNumber, columnNumber);
+ }
+
+
+ /**
+ * Internal initialization method.
+ *
+ * @param publicId The public identifier of the entity which generated the exception,
+ * or null.
+ * @param systemId The system identifier of the entity which generated the exception,
+ * or null.
+ * @param lineNumber The line number of the error, or -1.
+ * @param columnNumber The column number of the error, or -1.
+ */
+ private void init (String publicId, String systemId,
+ int lineNumber, int columnNumber)
+ {
this.publicId = publicId;
this.systemId = systemId;
this.lineNumber = lineNumber;
@@ -238,3 +260,5 @@
private int columnNumber;
}
+
+// end of SAXParseException.java
1.3 +6 -3 xml-xerces/java/src/org/xml/sax/XMLFilter.java
Index: XMLFilter.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/XMLFilter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XMLFilter.java 2000/03/06 21:06:34 1.2
+++ XMLFilter.java 2000/05/08 23:08:33 1.3
@@ -2,7 +2,7 @@
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the Public Domain.
-// $Id: XMLFilter.java,v 1.2 2000/01/22 16:27:36 david Exp $
+// $Id: XMLFilter.java,v 1.4 2000/05/05 17:48:25 david Exp $
package org.xml.sax;
@@ -22,12 +22,15 @@
* events as they pass on to the final application.</p>
*
* <p>The XMLFilterImpl helper class provides a convenient base
- * for creating SAX2 filters.</p>
+ * for creating SAX2 filters, by passing on all {@link org.xml.sax.EntityResolver
+ * EntityResolver}, {@link org.xml.sax.DTDHandler DTDHandler},
+ * {@link org.xml.sax.ContentHandler ContentHandler} and {@link org.xml.sax.ErrorHandler
+ * ErrorHandler} events automatically.</p>
*
* @since SAX 2.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.helpers.XMLFilterImpl
*/
public interface XMLFilter extends XMLReader
1.3 +45 -26 xml-xerces/java/src/org/xml/sax/XMLReader.java
Index: XMLReader.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/XMLReader.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XMLReader.java 2000/03/06 21:06:34 1.2
+++ XMLReader.java 2000/05/08 23:08:34 1.3
@@ -2,7 +2,7 @@
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the Public Domain.
-// $Id: XMLReader.java,v 1.3 2000/02/25 14:57:01 david Exp $
+// $Id: XMLReader.java,v 1.6 2000/05/05 17:48:56 david Exp $
package org.xml.sax;
@@ -17,19 +17,26 @@
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* </blockquote>
*
- * <p>This is a common interface that can be shared by many
- * XML parsers. This interface allows an application to set and
+ * <p><strong>Note:</strong> despite its name, this interface does
+ * <em>not</em> extend the standard Java {@link java.io.Reader Reader}
+ * interface, because reading XML is a fundamentally different activity
+ * than reading character data.</p>
+ *
+ * <p>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.</p>
*
- * <p>This interface replaces the (now deprecated) SAX 1.0 Parser
- * interface; it currently extends Parser to aid in the transition
- * to SAX2, but it will likely not do so in any future versions
- * of SAX.</p>
+ * <p>All SAX interfaces are assumed to be synchronous: the
+ * {@link #parse 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.</p>
*
- * <p>The Reader interface contains two important enhancements over
- * the old Parser interface:</p>
+ * <p>This interface replaces the (now deprecated) SAX 1.0 {@link
+ * org.xml.sax.Parser Parser} interface. The XMLReader interface
+ * contains two important enhancements over the old Parser
+ * interface:</p>
*
* <ol>
* <li>it adds a standard way to query and set features and
@@ -44,9 +51,10 @@
* @since SAX 2.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
+ * @see org.xml.sax.XMLFilter
* @see org.xml.sax.helpers.ParserAdapter
- * @see org.xml.sax.helpers.XMLReaderAdapter
+ * @see org.xml.sax.helpers.XMLReaderAdapter
*/
public interface XMLReader
{
@@ -65,7 +73,7 @@
* to be unable 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
- * validating, for example.</p>
+ * performing validation or expanding external entities.</p>
*
* <p>All XMLReaders are required to recognize the
* http://xml.org/sax/features/namespaces and the
@@ -100,14 +108,17 @@
* }
* </pre>
*
- * @param name The feature name, which is a fully-qualified
- * URI.
+ * <p>Implementors are free (and encouraged) to invent their own features,
+ * using names built on their own URIs.</p>
+ *
+ * @param name The feature name, which is a fully-qualified URI.
* @return The current state of the feature (true or false).
* @exception org.xml.sax.SAXNotRecognizedException When the
* XMLReader does not recognize the feature name.
* @exception org.xml.sax.SAXNotSupportedException When the
* XMLReader recognizes the feature name but
* cannot determine its value at this time.
+ * @see #setFeature
*/
public boolean getFeature (String name)
throws SAXNotRecognizedException, SAXNotSupportedException;
@@ -119,8 +130,8 @@
* <p>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
+ * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser Parser},
+ * which has no way of affecting whether the underlying parser is
* validating, for example.</p>
*
* <p>All XMLReaders are required to support setting
@@ -131,14 +142,14 @@
* in specific contexts, such as before, during, or after
* a parse.</p>
*
- * @param name The feature name, which is a fully-qualified
- * URI.
+ * @param name The feature name, which is a fully-qualified URI.
* @param state The requested state of the feature (true or false).
* @exception org.xml.sax.SAXNotRecognizedException When the
* XMLReader does not recognize the feature name.
* @exception org.xml.sax.SAXNotSupportedException When the
* XMLReader recognizes the feature name but
* cannot set the requested value.
+ * @see #getFeature
*/
public void setFeature (String name, boolean value)
throws SAXNotRecognizedException, SAXNotSupportedException;
@@ -150,23 +161,27 @@
* <p>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.</p>
+ * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser
+ * Parser}.</p>
*
* <p>XMLReaders are not required to recognize any specific
- * property names, though a core set is provided with
+ * property names, though an initial core set is documented for
* SAX2.</p>
*
* <p>Some property values may be available only in specific
* contexts, such as before, during, or after a parse.</p>
*
- * @param name The property name, which is a fully-qualified
- * URI.
+ * <p>Implementors are free (and encouraged) to invent their own properties,
+ * using names built on their own URIs.</p>
+ *
+ * @param name The property name, which is a fully-qualified URI.
* @return The current value of the property.
* @exception org.xml.sax.SAXNotRecognizedException When the
* XMLReader does not recognize the property name.
* @exception org.xml.sax.SAXNotSupportedException When the
* XMLReader recognizes the property name but
* cannot determine its value at this time.
+ * @see #setProperty
*/
public Object getProperty (String name)
throws SAXNotRecognizedException, SAXNotSupportedException;
@@ -178,7 +193,8 @@
* <p>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.</p>
+ * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser
+ * Parser}.</p>
*
* <p>XMLReaders are not required to recognize setting
* any specific property names, though a core set is provided with
@@ -191,8 +207,7 @@
* <p>This method is also the standard mechanism for setting
* extended handlers.</p>
*
- * @param name The property name, which is a fully-qualified
- * URI.
+ * @param name The property name, which is a fully-qualified URI.
* @param state The requested value for the property.
* @exception org.xml.sax.SAXNotRecognizedException When the
* XMLReader does not recognize the property name.
@@ -218,7 +233,7 @@
*
* <p>Applications may register a new or different resolver in the
* middle of a parse, and the SAX parser must begin using the new
- * handler immediately.</p>
+ * resolver immediately.</p>
*
* @param resolver The entity resolver.
* @exception java.lang.NullPointerException If the resolver
@@ -347,6 +362,10 @@
* <p>During the parse, the XMLReader will provide information
* about the XML document through the registered event
* handlers.</p>
+ *
+ * <p>This method is synchronous: it will not return until parsing
+ * has ended. If a client application wants to terminate
+ * parsing early, it should throw an exception.</p>
*
* @param source The input source for the top-level of the
* XML document.
1.4 +14 -9 xml-xerces/java/src/org/xml/sax/helpers/AttributeListImpl.java
Index: AttributeListImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/helpers/AttributeListImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AttributeListImpl.java 2000/03/06 21:06:37 1.3
+++ AttributeListImpl.java 2000/05/08 23:08:38 1.4
@@ -1,6 +1,6 @@
// SAX default implementation for AttributeList.
// No warranty; no copyright -- use this as you will.
-// $Id: AttributeListImpl.java,v 1.2 2000/01/21 15:12:33 david Exp $
+// $Id: AttributeListImpl.java,v 1.4 2000/05/05 17:49:14 david Exp $
package org.xml.sax.helpers;
@@ -10,19 +10,24 @@
/**
- * Convenience implementation for AttributeList.
+ * Default implementation for AttributeList.
*
* <blockquote>
* <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* </blockquote>
*
+ * <p>AttributeList implements the deprecated SAX1 {@link
+ * org.xml.sax.AttributeList AttributeList} interface, and has been
+ * replaced by the new SAX2 {@link org.xml.sax.helpers.AttributesImpl
+ * AttributesImpl} interface.</p>
+ *
* <p>This class provides a convenience implementation of the SAX
- * AttributeList class. This implementation is useful both
- * for SAX parser writers, who can use it to provide attributes
- * to the application, and for SAX application writers, who can
- * use it to create a persistent copy of an element's attribute
- * specifications:</p>
+ * {@link org.xml.sax.AttributeList AttributeList} interface. This
+ * implementation is useful both for SAX parser writers, who can use
+ * it to provide attributes to the application, and for SAX application
+ * writers, who can use it to create a persistent copy of an element's
+ * attribute specifications:</p>
*
* <pre>
* private AttributeList myatts;
@@ -52,9 +57,9 @@
* @since SAX 1.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.AttributeList
- * @see org.xml.sax.DocumentHandler#startElement
+ * @see org.xml.sax.DocumentHandler#startElement
*/
public class AttributeListImpl implements AttributeList
{
1.3 +84 -60 xml-xerces/java/src/org/xml/sax/helpers/AttributesImpl.java
Index: AttributesImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/helpers/AttributesImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AttributesImpl.java 2000/03/06 21:06:37 1.2
+++ AttributesImpl.java 2000/05/08 23:08:38 1.3
@@ -2,7 +2,7 @@
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the public domain.
-// $Id: AttributesImpl.java,v 1.2 2000/01/21 15:13:40 david Exp $
+// $Id: AttributesImpl.java,v 1.4 2000/05/05 17:49:22 david Exp $
package org.xml.sax.helpers;
@@ -19,28 +19,29 @@
* </blockquote>
*
* <p>This class provides a default implementation of the SAX2
- * Attributes interface, with the addition of manipulators
- * so that the list can be modified or reused.</p>
+ * {@link org.xml.sax.Attributes Attributes} interface, with the
+ * addition of manipulators so that the list can be modified or
+ * reused.</p>
*
* <p>There are two typical uses of this class:</p>
*
* <ol>
* <li>to take a persistent snapshot of an Attributes object
- * in a ContentHandler.startElement event; or</li>
- * <li>to construct or modify an Attributes object in a SAX2
- * XMLReader or filter.</li>
+ * in a {@link org.xml.sax.ContentHandler#startElement startElement} event; or</li>
+ * <li>to construct or modify an Attributes object in a SAX2 driver or filter.</li>
* </ol>
*
- * <p>This class replaces the now-deprecated SAX1 AttributeListImpl
+ * <p>This class replaces the now-deprecated SAX1 {@link
+ * org.xml.sax.helpers.AttributeListImpl AttributeListImpl}
* class; in addition to supporting the updated Attributes
- * interface rather than the deprecated AttributeList interface,
- * it also includes a much more efficient implementation using
- * arrays rather than Vector.</p>
+ * interface rather than the deprecated {@link org.xml.sax.AttributeList
+ * AttributeList} interface, it also includes a much more efficient
+ * implementation using a single array rather than a set of Vectors.</p>
*
* @since SAX 2.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
*/
public class AttributesImpl implements Attributes
{
@@ -64,22 +65,14 @@
/**
* Copy an existing Attributes object.
*
- * <p>This constructor is especially useful inside a start
- * element event.</p>
+ * <p>This constructor is especially useful inside a
+ * {@link org.xml.sax.ContentHandler#startElement startElement} event.</p>
*
* @param atts The existing Attributes object.
*/
public AttributesImpl (Attributes atts)
{
- length = atts.getLength();
- data = new String[length*5];
- for (int i = 0; i < length; i++) {
- data[i*5] = atts.getURI(i);
- data[i*5+1] = atts.getLocalName(i);
- data[i*5+2] = atts.getRawName(i);
- data[i*5+3] = atts.getType(i);
- data[i*5+4] = atts.getValue(i);
- }
+ setAttributes(atts);
}
@@ -105,8 +98,8 @@
* Return an attribute's Namespace URI.
*
* @param index The attribute's index (zero-based).
- * @return The Namespace URI or the empty string if none is
- * available.
+ * @return The Namespace URI, the empty string if none is
+ * available, or null if the index is out of range.
* @see org.xml.sax.Attributes#getURI
*/
public String getURI (int index)
@@ -123,8 +116,8 @@
* Return an attribute's local name.
*
* @param index The attribute's index (zero-based).
- * @return The attribute's local name or the empty string if
- * none is available.
+ * @return The attribute's local name, the empty string if
+ * none is available, or null if the index if out of range.
* @see org.xml.sax.Attributes#getLocalName
*/
public String getLocalName (int index)
@@ -138,14 +131,14 @@
/**
- * Return an attribute's raw XML 1.0 name.
+ * Return an attribute's qualified (prefixed) name.
*
* @param index The attribute's index (zero-based).
- * @return The attribute's raw name or the empty string if
- * none is available.
- * @see org.xml.sax.Attributes#getRawName
+ * @return The attribute's qualified name, the empty string if
+ * none is available, or null if the index is out of bounds.
+ * @see org.xml.sax.Attributes#getQName
*/
- public String getRawName (int index)
+ public String getQName (int index)
{
if (index >= 0 && index < length) {
return data[index*5+2];
@@ -159,7 +152,8 @@
* Return an attribute's type by index.
*
* @param index The attribute's index (zero-based).
- * @return The attribute's type.
+ * @return The attribute's type, "CDATA" if the type is unknown, or null
+ * if the index is out of bounds.
* @see org.xml.sax.Attributes#getType(int)
*/
public String getType (int index)
@@ -176,7 +170,7 @@
* Return an attribute's value by index.
*
* @param index The attribute's index (zero-based).
- * @return The attribute's value.
+ * @return The attribute's value or null if the index is out of bounds.
* @see org.xml.sax.Attributes#getValue(int)
*/
public String getValue (int index)
@@ -192,6 +186,10 @@
/**
* Look up an attribute's index by Namespace name.
*
+ * <p>In many cases, it will be more efficient to look up the name once and
+ * use the index query methods rather than using the name query methods
+ * repeatedly.</p>
+ *
* @param uri The attribute's Namespace URI, or the empty
* string if none is available.
* @param localName The attribute's local name.
@@ -211,17 +209,17 @@
/**
- * Look up an attribute's index by raw XML 1.0 name.
+ * Look up an attribute's index by qualified (prefixed) name.
*
- * @param rawName The raw XML 1.0 (prefixed) name.
+ * @param qName The qualified name.
* @return The attribute's index, or -1 if none matches.
* @see org.xml.sax.Attributes#getIndex(java.lang.String)
*/
- public int getIndex (String rawName)
+ public int getIndex (String qName)
{
int max = length * 5;
for (int i = 0; i < max; i += 5) {
- if (data[i+2].equals(rawName)) {
+ if (data[i+2].equals(qName)) {
return i / 5;
}
}
@@ -252,18 +250,18 @@
/**
- * Look up an attribute's type by raw XML 1.0 name.
+ * Look up an attribute's type by qualified (prefixed) name.
*
- * @param rawName The raw XML 1.0 name.
+ * @param qName The qualified name.
* @return The attribute's type, or null if there is no
* matching attribute.
* @see org.xml.sax.Attributes#getType(java.lang.String)
*/
- public String getType (String rawName)
+ public String getType (String qName)
{
int max = length * 5;
for (int i = 0; i < max; i += 5) {
- if (data[i+2].equals(rawName)) {
+ if (data[i+2].equals(qName)) {
return data[i+3];
}
}
@@ -294,18 +292,18 @@
/**
- * Look up an attribute's value by raw XML 1.0 name.
+ * Look up an attribute's value by qualified (prefixed) name.
*
- * @param rawName The raw XML 1.0 name.
+ * @param qName The qualified name.
* @return The attribute's value, or null if there is no
* matching attribute.
* @see org.xml.sax.Attributes#getValue(java.lang.String)
*/
- public String getValue (String rawName)
+ public String getValue (String qName)
{
int max = length * 5;
for (int i = 0; i < max; i += 5) {
- if (data[i+2].equals(rawName)) {
+ if (data[i+2].equals(qName)) {
return data[i+4];
}
}
@@ -333,6 +331,29 @@
/**
+ * Copy an entire Attributes object.
+ *
+ * <p>It may be more efficient to reuse an existing object
+ * rather than constantly allocating new ones.</p>
+ *
+ * @param atts The attributes to copy.
+ */
+ public void setAttributes (Attributes atts)
+ {
+ clear();
+ length = atts.getLength();
+ data = new String[length*5];
+ for (int i = 0; i < length; i++) {
+ data[i*5] = atts.getURI(i);
+ data[i*5+1] = atts.getLocalName(i);
+ data[i*5+2] = atts.getQName(i);
+ data[i*5+3] = atts.getType(i);
+ data[i*5+4] = atts.getValue(i);
+ }
+ }
+
+
+ /**
* Add an attribute to the end of the list.
*
* <p>For the sake of speed, this method does no checking
@@ -344,18 +365,18 @@
* being performed.
* @param localName The local name, or the empty string if
* Namespace processing is not being performed.
- * @param rawName The raw XML 1.0 name, or the empty string
- * if raw names are not available.
+ * @param qName The qualified (prefixed) name, or the empty string
+ * if qualified names are not available.
* @param type The attribute type as a string.
* @param value The attribute value.
*/
- public void addAttribute (String uri, String localName, String rawName,
+ public void addAttribute (String uri, String localName, String qName,
String type, String value)
{
ensureCapacity(length+1);
data[length*5] = uri;
data[length*5+1] = localName;
- data[length*5+2] = rawName;
+ data[length*5+2] = qName;
data[length*5+3] = type;
data[length*5+4] = value;
length++;
@@ -375,8 +396,8 @@
* being performed.
* @param localName The local name, or the empty string if
* Namespace processing is not being performed.
- * @param rawName The raw XML 1.0 name, or the empty string
- * if raw names are not available.
+ * @param qName The qualified name, or the empty string
+ * if qualified names are not available.
* @param type The attribute type as a string.
* @param value The attribute value.
* @exception java.lang.ArrayIndexOutOfBoundsException When the
@@ -384,12 +405,12 @@
* in the list.
*/
public void setAttribute (int index, String uri, String localName,
- String rawName, String type, String value)
+ String qName, String type, String value)
{
if (index >= 0 && index < length) {
data[index*5] = uri;
data[index*5+1] = localName;
- data[index*5+2] = rawName;
+ data[index*5+2] = qName;
data[index*5+3] = type;
data[index*5+4] = value;
} else {
@@ -409,8 +430,11 @@
public void removeAttribute (int index)
{
if (index >= 0 && index < length) {
- System.arraycopy(data, (index+1)*5, data, index*5,
- (length-index)*5);
+ data[index] = null;
+ if (index < length - 1) {
+ System.arraycopy(data, (index+1)*5, data, index*5,
+ (length-index)*5);
+ }
length--;
} else {
badIndex(index);
@@ -459,19 +483,19 @@
/**
- * Set the raw XML 1.0 name of a specific attribute.
+ * Set the qualified name of a specific attribute.
*
* @param index The index of the attribute (zero-based).
- * @param rawName The attribute's raw name, or the empty
+ * @param qName The attribute's qualified name, or the empty
* string for none.
* @exception java.lang.ArrayIndexOutOfBoundsException When the
* supplied index does not point to an attribute
* in the list.
*/
- public void setRawName (int index, String rawName)
+ public void setQName (int index, String qName)
{
if (index >= 0 && index < length) {
- data[index*5+2] = rawName;
+ data[index*5+2] = qName;
} else {
badIndex(index);
}
@@ -559,7 +583,7 @@
throws ArrayIndexOutOfBoundsException
{
String msg =
- "Attempt to reference attribute at illegal index: " + index;
+ "Attempt to modify attribute at illegal index: " + index;
throw new ArrayIndexOutOfBoundsException(msg);
}
1.3 +14 -10 xml-xerces/java/src/org/xml/sax/helpers/DefaultHandler.java
Index: DefaultHandler.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/helpers/DefaultHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultHandler.java 2000/03/06 21:06:37 1.2
+++ DefaultHandler.java 2000/05/08 23:08:38 1.3
@@ -2,7 +2,7 @@
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the public domain.
-// $Id: DefaultHandler.java,v 1.1 2000/01/26 13:24:26 david Exp $
+// $Id: DefaultHandler.java,v 1.3 2000/05/05 17:49:33 david Exp $
package org.xml.sax.helpers;
@@ -47,7 +47,7 @@
* @since SAX 2.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.EntityResolver
* @see org.xml.sax.DTDHandler
* @see org.xml.sax.ContentHandler
@@ -105,9 +105,12 @@
* @param publicId The notation public identifier, or null if not
* available.
* @param systemId The notation system identifier.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
* @see org.xml.sax.DTDHandler#notationDecl
*/
public void notationDecl (String name, String publicId, String systemId)
+ throws SAXException
{
// no op
}
@@ -125,10 +128,13 @@
* available.
* @param systemId The entity system identifier.
* @param notationName The name of the associated notation.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
* @see org.xml.sax.DTDHandler#unparsedEntityDecl
*/
public void unparsedEntityDecl (String name, String publicId,
String systemId, String notationName)
+ throws SAXException
{
// no op
}
@@ -180,7 +186,7 @@
* Receive notification of the end of the document.
*
* <p>By default, do nothing. Application writers may override this
- * method in a subclass to take specific actions at the beginning
+ * method in a subclass to take specific actions at the end
* of a document (such as finalising a tree or closing an output
* file).</p>
*
@@ -200,8 +206,7 @@
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the start of
- * each element (such as allocating a new tree node or writing
- * output to a file).</p>
+ * each Namespace prefix scope (such as storing the prefix mapping).</p>
*
* @param prefix The Namespace prefix being declared.
* @param uri The Namespace URI mapped to the prefix.
@@ -220,9 +225,8 @@
* Receive notification of the end of a Namespace mapping.
*
* <p>By default, do nothing. Application writers may override this
- * method in a subclass to take specific actions at the start of
- * each element (such as allocating a new tree node or writing
- * output to a file).</p>
+ * method in a subclass to take specific actions at the end of
+ * each prefix mapping.</p>
*
* @param prefix The Namespace prefix being declared.
* @exception org.xml.sax.SAXException Any SAX exception, possibly
@@ -251,7 +255,7 @@
* @see org.xml.sax.ContentHandler#startElement
*/
public void startElement (String uri, String localName,
- String rawName, Attributes attributes)
+ String qName, Attributes attributes)
throws SAXException
{
// no op
@@ -272,7 +276,7 @@
* wrapping another exception.
* @see org.xml.sax.ContentHandler#endElement
*/
- public void endElement (String uri, String localName, String rawName)
+ public void endElement (String uri, String localName, String qName)
throws SAXException
{
// no op
1.4 +2 -2 xml-xerces/java/src/org/xml/sax/helpers/LocatorImpl.java
Index: LocatorImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/helpers/LocatorImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LocatorImpl.java 2000/03/06 21:06:37 1.3
+++ LocatorImpl.java 2000/05/08 23:08:38 1.4
@@ -1,6 +1,6 @@
// SAX default implementation for Locator.
// No warranty; no copyright -- use this as you will.
-// $Id: LocatorImpl.java,v 1.2 2000/01/21 15:45:08 david Exp $
+// $Id: LocatorImpl.java,v 1.4 2000/05/05 17:49:44 david Exp $
package org.xml.sax.helpers;
@@ -44,7 +44,7 @@
* @since SAX 1.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.Locator Locator
*/
public class LocatorImpl implements Locator
1.4 +156 -24 xml-xerces/java/src/org/xml/sax/helpers/NamespaceSupport.java
Index: NamespaceSupport.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/helpers/NamespaceSupport.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NamespaceSupport.java 2000/03/06 21:06:37 1.3
+++ NamespaceSupport.java 2000/05/08 23:08:39 1.4
@@ -2,7 +2,7 @@
// Written by David Megginson, sax@megginson.com
// This class is in the Public Domain. NO WARRANTY!
-// $Id: NamespaceSupport.java,v 1.4 2000/02/25 14:56:13 david Exp $
+// $Id: NamespaceSupport.java,v 1.8 2000/05/05 17:49:53 david Exp $
package org.xml.sax.helpers;
@@ -22,8 +22,9 @@
*
* <p>This class encapsulates the logic of Namespace processing:
* it tracks the declarations currently in force for each context
- * and automatically processing raw XML 1.0 names into their
- * Namespace parts.</p>
+ * and automatically processes qualified XML 1.0 names into their
+ * Namespace parts; it can also be used in reverse for generating
+ * XML 1.0 from Namespaces.</p>
*
* <p>Namespace support objects are reusable, but the reset method
* must be invoked between each session.</p>
@@ -59,7 +60,7 @@
* @since SAX 2.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
*/
public class NamespaceSupport
{
@@ -166,7 +167,7 @@
* Revert to the previous Namespace context.
*
* <p>Normally, you should pop the context at the end of each
- * element. After popping the context, all Namespace prefix
+ * XML element. After popping the context, all Namespace prefix
* mappings that were previously in force are restored.</p>
*
* <p>You must not attempt to declare additional Namespace
@@ -181,7 +182,6 @@
if (contextPos < 0) {
throw new EmptyStackException();
}
-// XXX if current can be optimized out, unoptimize it here
currentContext = contexts[contextPos];
}
@@ -205,11 +205,20 @@
* <p>Note that you must <em>not</em> declare a prefix after
* you've pushed and popped another Namespace.</p>
*
+ * <p>Note that there is an asymmetry in this library: while {@link
+ * #getPrefix getPrefix} will not return the default "" prefix,
+ * even if you have declared one; to check for a default prefix,
+ * you have to look it up explicitly using {@link #getURI getURI}.
+ * This asymmetry exists to make it easier to look up prefixes
+ * for attribute names, where the default prefix is not allowed.</p>
+ *
* @param prefix The prefix to declare, or null for the empty
* string.
* @param uri The Namespace URI to associate with the prefix.
* @return true if the prefix was legal, false otherwise
* @see #processName
+ * @see #getURI
+ * @see #getPrefix
*/
public boolean declarePrefix (String prefix, String uri)
{
@@ -249,7 +258,7 @@
* default Namespace (if any), while an unprefixed element name
* will not.</p>
*
- * @param rawName The raw XML 1.0 name to be processed.
+ * @param qName The raw XML 1.0 name to be processed.
* @param parts An array supplied by the caller, capable of
* holding at least three members.
* @param isAttribute A flag indicating whether this is an
@@ -260,10 +269,10 @@
* is an undeclared prefix.
* @see #declarePrefix
* @see java.lang.String#intern */
- public String [] processName (String rawName, String parts[],
+ public String [] processName (String qName, String parts[],
boolean isAttribute)
{
- String myParts[] = currentContext.processName(rawName, isAttribute);
+ String myParts[] = currentContext.processName(qName, isAttribute);
if (myParts == null) {
return null;
} else {
@@ -284,6 +293,7 @@
* @param prefix The prefix to look up.
* @return The associated Namespace URI, or null if the prefix
* is undeclared in this context.
+ * @see #getPrefix
* @see #getPrefixes
*/
public String getURI (String prefix)
@@ -295,8 +305,13 @@
/**
* Return an enumeration of all prefixes currently declared.
*
+ * <p><strong>Note:</strong> if there is a default prefix, it will not be
+ * returned in this enumeration; check for the default prefix
+ * using the {@link #getURI getURI} with an argument of "".</p>
+ *
* @return An enumeration of all prefixes declared in the
- * current context.
+ * current context except for the empty (default)
+ * prefix.
* @see #getDeclaredPrefixes
* @see #getURI
*/
@@ -307,8 +322,74 @@
/**
+ * Return one of the prefixes mapped to a Namespace URI.
+ *
+ * <p>If more than one prefix is currently mapped to the same
+ * URI, this method will make an arbitrary selection; if you
+ * want all of the prefixes, use the {@link #getPrefixes}
+ * method instead.</p>
+ *
+ * <p><strong>Note:</strong> this will never return the empty (default) prefix;
+ * to check for a default prefix, use the {@link #getURI getURI}
+ * method with an argument of "".</p>
+ *
+ * @param uri The Namespace URI.
+ * @param isAttribute true if this prefix is for an attribute
+ * (and the default Namespace is not allowed).
+ * @return One of the prefixes currently mapped to the URI supplied,
+ * or null if none is mapped or if the URI is assigned to
+ * the default Namespace.
+ * @see #getPrefixes(java.lang.String)
+ * @see #getURI
+ */
+ public String getPrefix (String uri)
+ {
+ return currentContext.getPrefix(uri);
+ }
+
+
+ /**
+ * Return an enumeration of all prefixes currently declared for a URI.
+ *
+ * <p>This method returns prefixes mapped to a specific Namespace
+ * URI. The xml: prefix will be included. If you want only one
+ * prefix that's mapped to the Namespace URI, and you don't care
+ * which one you get, use the {@link #getPrefix getPrefix}
+ * method instead.</p>
+ *
+ * <p><strong>Note:</strong> the empty (default) prefix is <em>never</em> included
+ * in this enumeration; to check for the presence of a default
+ * Namespace, use the {@link #getURI getURI} method with an
+ * argument of "".</p>
+ *
+ * @param uri The Namespace URI.
+ * @return An enumeration of all prefixes declared in the
+ * current context.
+ * @see #getPrefix
+ * @see #getDeclaredPrefixes
+ * @see #getURI
+ */
+ public Enumeration getPrefixes (String uri)
+ {
+ Vector prefixes = new Vector();
+ Enumeration allPrefixes = getPrefixes();
+ while (allPrefixes.hasMoreElements()) {
+ String prefix = (String)allPrefixes.nextElement();
+ if (uri.equals(getURI(prefix))) {
+ prefixes.addElement(prefix);
+ }
+ }
+ return prefixes.elements();
+ }
+
+
+ /**
* Return an enumeration of all prefixes declared in this context.
*
+ * <p>The empty (default) prefix will be included in this
+ * enumeration; note that this behaviour differs from that of
+ * {@link #getPrefix} and {@link #getPrefixes}.</p>
+ *
* @return An enumeration of all prefixes declared in this
* context.
* @see #getPrefixes
@@ -337,6 +418,10 @@
/**
* Internal class for a single Namespace context.
+ *
+ * <p>This module caches and reuses Namespace contexts, so the number allocated
+ * will be equal to the element depth of the document, not to the total
+ * number of elements (i.e. 5-10 rather than tens of thousands).</p>
*/
final class Context {
@@ -359,6 +444,7 @@
this.parent = parent;
declarations = null;
prefixTable = parent.prefixTable;
+ uriTable = parent.uriTable;
elementNameTable = parent.elementNameTable;
attributeNameTable = parent.attributeNameTable;
defaultNS = parent.defaultNS;
@@ -385,10 +471,16 @@
prefix = prefix.intern();
uri = uri.intern();
- if (prefix.equals("")) {
- defaultNS = uri;
+ if ("".equals(prefix)) {
+ if ("".equals(uri)) {
+ defaultNS = null;
+ } else {
+ defaultNS = uri;
+ }
+ } else {
+ prefixTable.put(prefix, uri);
+ uriTable.put(uri, prefix); // may wipe out another prefix
}
- prefixTable.put(prefix, uri);
declarations.addElement(prefix);
}
@@ -396,7 +488,7 @@
/**
* Process a raw XML 1.0 name in this context.
*
- * @param rawName The raw XML 1.0 name.
+ * @param qName The raw XML 1.0 name.
* @param isAttribute true if this is an attribute name.
* @return An array of three strings containing the
* URI part (or empty string), the local part,
@@ -404,7 +496,7 @@
* if there is an undeclared prefix.
* @see org.xml.sax.helpers.NamespaceSupport#processName
*/
- String [] processName (String rawName, boolean isAttribute)
+ String [] processName (String qName, boolean isAttribute)
{
String name[];
Hashtable table;
@@ -419,7 +511,7 @@
// Start by looking in the cache, and
// return immediately if the name
// is already known in this content
- name = (String[])table.get(rawName);
+ name = (String[])table.get(qName);
if (name != null) {
return name;
}
@@ -427,7 +519,7 @@
// We haven't seen this name in this
// context before.
name = new String[3];
- int index = rawName.indexOf(':');
+ int index = qName.indexOf(':');
// No prefix.
@@ -437,21 +529,26 @@
} else {
name[0] = defaultNS;
}
- name[1] = rawName.intern();
+ name[1] = qName.intern();
name[2] = name[1];
}
// Prefix
else {
- String prefix = rawName.substring(0, index);
- String local = rawName.substring(index+1);
- String uri = (String)prefixTable.get(prefix);
+ String prefix = qName.substring(0, index);
+ String local = qName.substring(index+1);
+ String uri;
+ if ("".equals(prefix)) {
+ uri = defaultNS;
+ } else {
+ uri = (String)prefixTable.get(prefix);
+ }
if (uri == null) {
return null;
}
name[0] = uri;
name[1] = local.intern();
- name[2] = rawName.intern();
+ name[2] = qName.intern();
}
// Save in the cache for future use.
@@ -471,12 +568,34 @@
*/
String getURI (String prefix)
{
- if (prefixTable == null) {
+ if ("".equals(prefix)) {
+ return defaultNS;
+ } else if (prefixTable == null) {
return null;
} else {
return (String)prefixTable.get(prefix);
}
}
+
+
+ /**
+ * Look up one of the prefixes associated with a URI in this context.
+ *
+ * <p>Since many prefixes may be mapped to the same URI,
+ * the return value may be unreliable.</p>
+ *
+ * @param uri The URI to look up.
+ * @return The associated prefix, or null if none is declared.
+ * @see org.xml.sax.helpers.NamespaceSupport#getPrefix
+ */
+ String getPrefix (String uri)
+ {
+ if (uriTable == null) {
+ return null;
+ } else {
+ return (String)uriTable.get(uri);
+ }
+ }
/**
@@ -498,12 +617,19 @@
/**
* Return an enumeration of all prefixes currently in force.
*
+ * <p>The default prefix, if in force, is <em>not</em>
+ * returned, and will have to be checked for separately.</p>
+ *
* @return An enumeration of prefixes (never empty).
* @see org.xml.sax.helpers.NamespaceSupport#getPrefixes
*/
Enumeration getPrefixes ()
{
- return prefixTable.keys();
+ if (prefixTable == null) {
+ return EMPTY_ENUMERATION;
+ } else {
+ return prefixTable.keys();
+ }
}
@@ -526,6 +652,11 @@
} else {
prefixTable = new Hashtable();
}
+ if (uriTable != null) {
+ uriTable = (Hashtable)uriTable.clone();
+ } else {
+ uriTable = new Hashtable();
+ }
elementNameTable = new Hashtable();
attributeNameTable = new Hashtable();
tablesDirty = true;
@@ -538,6 +669,7 @@
////////////////////////////////////////////////////////////////
Hashtable prefixTable;
+ Hashtable uriTable;
Hashtable elementNameTable;
Hashtable attributeNameTable;
String defaultNS = null;
1.3 +58 -68 xml-xerces/java/src/org/xml/sax/helpers/ParserAdapter.java
Index: ParserAdapter.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/helpers/ParserAdapter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ParserAdapter.java 2000/03/06 21:06:37 1.2
+++ ParserAdapter.java 2000/05/08 23:08:39 1.3
@@ -2,7 +2,7 @@
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the public domain.
-// $Id: ParserAdapter.java,v 1.4 2000/02/25 14:56:26 david Exp $
+// $Id: ParserAdapter.java,v 1.6 2000/05/05 17:50:04 david Exp $
package org.xml.sax.helpers;
@@ -36,10 +36,10 @@
* </blockquote>
*
* <p>This class wraps a SAX1 {@link org.xml.sax.Parser Parser}
- * and makes it act as a SAX2 {@link org.xml.sax.XMLReader XMLReader},
+ * and makes it act as a SAX2 {@link org.xml.sax.XMLReader XMLReader},
* with feature, property, and Namespace support. Note
- * that it is not possible to report skippedEntity events, since
- * SAX1 does not make that information available.</p>
+ * that it is not possible to report {@link org.xml.sax.ContentHandler#skippedEntity
+ * skippedEntity} events, since SAX1 does not make that information available.</p>
*
* <p>This adapter does not test for duplicate Namespace-qualified
* attribute names.</p>
@@ -47,7 +47,7 @@
* @since SAX 2.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.helpers.XMLReaderAdapter
* @see org.xml.sax.XMLReader
* @see org.xml.sax.Parser
@@ -403,17 +403,7 @@
public void parse (String systemId)
throws IOException, SAXException
{
- if (parsing) {
- throw new SAXException("Parser is already in use");
- }
- setupParser();
- parsing = true;
- try {
- parser.parse(systemId);
- } finally {
- parsing = false;
- }
- parsing = false;
+ parse(new InputSource(systemId));
}
@@ -503,18 +493,18 @@
*
* <p>If necessary, perform Namespace processing.</p>
*
- * @param rawName The raw XML 1.0 name.
- * @param rawAtts The raw XML 1.0 attribute list.
+ * @param qName The qualified (prefixed) name.
+ * @param qAtts The XML 1.0 attribute list (with qnames).
*/
- public void startElement (String rawName, AttributeList rawAtts)
+ public void startElement (String qName, AttributeList qAtts)
throws SAXException
{
// If we're not doing Namespace
// processing, dispatch this quickly.
if (!namespaces) {
if (contentHandler != null) {
- attAdapter.setAttributeList(rawAtts);
- contentHandler.startElement("", "", rawName.intern(),
+ attAdapter.setAttributeList(qAtts);
+ contentHandler.startElement("", "", qName.intern(),
attAdapter);
}
return;
@@ -530,20 +520,20 @@
// attributes into the SAX2 attribute
// list, noting any Namespace
// declarations.
- int length = rawAtts.getLength();
+ int length = qAtts.getLength();
for (int i = 0; i < length; i++) {
- String attRawName = rawAtts.getName(i);
- String type = rawAtts.getType(i);
- String value = rawAtts.getValue(i);
+ String attQName = qAtts.getName(i);
+ String type = qAtts.getType(i);
+ String value = qAtts.getValue(i);
// Found a declaration...
- if (attRawName.startsWith("xmlns")) {
+ if (attQName.startsWith("xmlns")) {
String prefix;
- int n = attRawName.indexOf(':');
+ int n = attQName.indexOf(':');
if (n == -1) {
prefix = "";
} else {
- prefix = attRawName.substring(n+1);
+ prefix = attQName.substring(n+1);
}
if (!nsSupport.declarePrefix(prefix, value)) {
reportError("Illegal Namespace prefix: " + prefix);
@@ -554,14 +544,14 @@
// We may still have to add this to
// the list.
if (prefixes) {
- atts.addAttribute("", "", attRawName.intern(),
+ atts.addAttribute("", "", attQName.intern(),
type, value);
}
seenDecl = true;
// This isn't a declaration.
} else {
- String attName[] = processName(attRawName, true);
+ String attName[] = processName(attQName, true);
atts.addAttribute(attName[0], attName[1], attName[2],
type, value);
}
@@ -575,9 +565,9 @@
if (seenDecl) {
length = atts.getLength();
for (int i = 0; i < length; i++) {
- String attRawName = atts.getRawName(i);
- if (!attRawName.startsWith("xmlns")) {
- String attName[] = processName(attRawName, true);
+ String attQName = atts.getQName(i);
+ if (!attQName.startsWith("xmlns")) {
+ String attName[] = processName(attQName, true);
atts.setURI(i, attName[0]);
atts.setLocalName(i, attName[1]);
}
@@ -586,7 +576,7 @@
// OK, finally report the event.
if (contentHandler != null) {
- String name[] = processName(rawName, false);
+ String name[] = processName(qName, false);
contentHandler.startElement(name[0], name[1], name[2], atts);
}
}
@@ -595,25 +585,25 @@
/**
* Adapt a SAX1 end element event.
*
- * @param rawName The raw XML 1.0 name.
+ * @param qName The qualified (prefixed) name.
* @exception org.xml.sax.SAXException The client may raise a
* processing exception.
* @see org.xml.sax.DocumentHandler#endElement
*/
- public void endElement (String rawName)
+ public void endElement (String qName)
throws SAXException
{
// If we're not doing Namespace
// processing, dispatch this quickly.
if (!namespaces) {
if (contentHandler != null) {
- contentHandler.endElement("", "", rawName.intern());
+ contentHandler.endElement("", "", qName.intern());
}
return;
}
// Split the name.
- String names[] = processName(rawName, false);
+ String names[] = processName(qName, false);
if (contentHandler != null) {
contentHandler.endElement(names[0], names[1], names[2]);
Enumeration prefixes = nsSupport.getDeclaredPrefixes();
@@ -710,27 +700,27 @@
/**
- * Process a raw XML 1.0 name.
+ * Process a qualified (prefixed) name.
*
- * <p>If the name has an undeclared prefix, use only the raw name
+ * <p>If the name has an undeclared prefix, use only the qname
* and make an ErrorHandler.error callback in case the app is
* interested.</p>
*
- * @param rawName The raw XML 1.0 name.
+ * @param qName The qualified (prefixed) name.
* @param isAttribute true if this is an attribute name.
* @return The name split into three parts.
* @exception org.xml.sax.SAXException The client may throw
* an exception if there is an error callback.
*/
- private String [] processName (String rawName, boolean isAttribute)
+ private String [] processName (String qName, boolean isAttribute)
throws SAXException
{
- String parts[] = nsSupport.processName(rawName, nameParts,
+ String parts[] = nsSupport.processName(qName, nameParts,
isAttribute);
if (parts == null) {
parts = new String[3];
- parts[2] = rawName.intern();
- reportError("Undeclared prefix: " + rawName);
+ parts[2] = qName.intern();
+ reportError("Undeclared prefix: " + qName);
}
return parts;
}
@@ -847,11 +837,11 @@
* <p>This method must be invoked before any of the others
* can be used.</p>
*
- * @param The raw SAX1 attribute list.
+ * @param The SAX1 attribute list (with qnames).
*/
- void setAttributeList (AttributeList rawAtts)
+ void setAttributeList (AttributeList qAtts)
{
- this.rawAtts = rawAtts;
+ this.qAtts = qAtts;
}
@@ -863,7 +853,7 @@
*/
public int getLength ()
{
- return rawAtts.getLength();
+ return qAtts.getLength();
}
@@ -894,14 +884,14 @@
/**
- * Return the raw XML 1.0 name of the specified attribute.
+ * Return the qualified (prefixed) name of the specified attribute.
*
* @param The attribute's index.
- * @return The attribute's raw XML 1.0 name, internalized.
+ * @return The attribute's qualified name, internalized.
*/
- public String getRawName (int i)
+ public String getQName (int i)
{
- return rawAtts.getName(i).intern();
+ return qAtts.getName(i).intern();
}
@@ -913,7 +903,7 @@
*/
public String getType (int i)
{
- return rawAtts.getType(i).intern();
+ return qAtts.getType(i).intern();
}
@@ -925,7 +915,7 @@
*/
public String getValue (int i)
{
- return rawAtts.getValue(i);
+ return qAtts.getValue(i);
}
@@ -944,17 +934,17 @@
/**
- * Look up an attribute index by raw XML 1.0 name.
+ * Look up an attribute index by qualified (prefixed) name.
*
- * @param rawName The raw XML 1.0 name.
+ * @param qName The qualified name.
* @return The attributes index, or -1 if none was found.
* @see org.xml.sax.Attributes#getIndex(java.lang.String)
*/
- public int getIndex (String rawName)
+ public int getIndex (String qName)
{
int max = atts.getLength();
for (int i = 0; i < max; i++) {
- if (rawAtts.getName(i).equals(rawName)) {
+ if (qAtts.getName(i).equals(qName)) {
return i;
}
}
@@ -976,14 +966,14 @@
/**
- * Look up the type of an attribute by raw XML 1.0 name.
+ * Look up the type of an attribute by qualified (prefixed) name.
*
- * @param rawName The raw XML 1.0 name.
+ * @param qName The qualified name.
* @return The attribute's type as an internalized string.
*/
- public String getType (String rawName)
+ public String getType (String qName)
{
- return rawAtts.getType(rawName).intern();
+ return qAtts.getType(qName).intern();
}
@@ -1001,17 +991,17 @@
/**
- * Look up the value of an attribute by raw XML 1.0 name.
+ * Look up the value of an attribute by qualified (prefixed) name.
*
- * @param rawName The raw XML 1.0 name.
+ * @param qName The qualified name.
* @return The attribute's value.
*/
- public String getValue (String rawName)
+ public String getValue (String qName)
{
- return rawAtts.getValue(rawName);
+ return qAtts.getValue(qName);
}
- private AttributeList rawAtts;
+ private AttributeList qAtts;
}
}
1.4 +32 -28 xml-xerces/java/src/org/xml/sax/helpers/ParserFactory.java
Index: ParserFactory.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/helpers/ParserFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ParserFactory.java 2000/03/06 21:06:37 1.3
+++ ParserFactory.java 2000/05/08 23:08:39 1.4
@@ -1,6 +1,6 @@
// SAX parser factory.
// No warranty; no copyright -- use this as you will.
-// $Id: ParserFactory.java,v 1.2 2000/01/22 16:24:18 david Exp $
+// $Id: ParserFactory.java,v 1.4 2000/05/05 17:50:13 david Exp $
package org.xml.sax.helpers;
@@ -21,7 +21,11 @@
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* </blockquote>
*
- * <p>This class is not part of the platform-independent definition
+ * <p><strong>Note:</strong> This class is designed to work with the now-deprecated
+ * SAX1 {@link org.xml.sax.Parser Parser} class. SAX2 applications should use
+ * {@link org.xml.sax.helpers.XMLReaderFactory XMLReaderFactory} instead.</p>
+ *
+ * <p>ParserFactory is not part of the platform-independent definition
* of SAX; it is an additional convenience class designed
* specifically for Java XML application writers. SAX applications
* can use the static methods in this class to allocate a SAX parser
@@ -30,7 +34,7 @@
* name.</p>
*
* <p>Note that the application still requires an XML parser that
- * implements SAX.</p>
+ * implements SAX1.</p>
*
* @deprecated This class works with the deprecated
* {@link org.xml.sax.Parser Parser}
@@ -38,7 +42,7 @@
* @since SAX 1.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.Parser
* @see java.lang.Class
*/
@@ -51,29 +55,29 @@
private ParserFactory ()
{
}
-
-
- /**
- * Create a new SAX parser using the `org.xml.sax.parser' system property.
- *
- * <p>The named class must exist and must implement the
- * org.xml.sax.Parser interface.</p>
- *
- * @exception java.lang.NullPointerException There is no value
- * for the `org.xml.sax.parser' system property.
- * @exception java.lang.ClassNotFoundException The SAX parser
- * class was not found (check your CLASSPATH).
- * @exception IllegalAccessException The SAX parser class was
- * found, but you do not have permission to load
- * it.
- * @exception InstantiationException The SAX parser class was
- * found but could not be instantiated.
- * @exception java.lang.ClassCastException The SAX parser class
- * was found and instantiated, but does not implement
- * org.xml.sax.Parser.
- * @see #makeParser(java.lang.String)
- * @see org.xml.sax.Parser
- */
+
+
+ /**
+ * Create a new SAX parser using the `org.xml.sax.parser' system property.
+ *
+ * <p>The named class must exist and must implement the
+ * {@link org.xml.sax.Parser Parser} interface.</p>
+ *
+ * @exception java.lang.NullPointerException There is no value
+ * for the `org.xml.sax.parser' system property.
+ * @exception java.lang.ClassNotFoundException The SAX parser
+ * class was not found (check your CLASSPATH).
+ * @exception IllegalAccessException The SAX parser class was
+ * found, but you do not have permission to load
+ * it.
+ * @exception InstantiationException The SAX parser class was
+ * found but could not be instantiated.
+ * @exception java.lang.ClassCastException The SAX parser class
+ * was found and instantiated, but does not implement
+ * org.xml.sax.Parser.
+ * @see #makeParser(java.lang.String)
+ * @see org.xml.sax.Parser
+ */
public static Parser makeParser ()
throws ClassNotFoundException,
IllegalAccessException,
@@ -94,7 +98,7 @@
* Create a new SAX parser object using the class name provided.
*
* <p>The named class must exist and must implement the
- * org.xml.sax.Parser interface.</p>
+ * {@link org.xml.sax.Parser Parser} interface.</p>
*
* @param className A string containing the name of the
* SAX parser class.
1.3 +16 -18 xml-xerces/java/src/org/xml/sax/helpers/XMLFilterImpl.java
Index: XMLFilterImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/helpers/XMLFilterImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XMLFilterImpl.java 2000/03/06 21:06:37 1.2
+++ XMLFilterImpl.java 2000/05/08 23:08:39 1.3
@@ -2,7 +2,7 @@
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the Public Domain.
-// $Id: XMLFilterImpl.java,v 1.2 2000/01/22 16:27:53 david Exp $
+// $Id: XMLFilterImpl.java,v 1.4 2000/05/05 17:50:37 david Exp $
package org.xml.sax.helpers;
@@ -31,8 +31,8 @@
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* </blockquote>
*
- * <p>This class is designed to sit between an XMLReader and
- * the client application's event handlers. By default, it
+ * <p>This class is designed to sit between an {@link org.xml.sax.XMLReader
+ * XMLReader} and the client application's event handlers. By default, it
* does nothing but pass requests up to the reader and events
* on to the handlers unmodified, but subclasses can override
* specific methods to modify the event stream or the configuration
@@ -41,7 +41,7 @@
* @since SAX 2.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.XMLFilter
* @see org.xml.sax.XMLReader
* @see org.xml.sax.EntityResolver
@@ -50,8 +50,7 @@
* @see org.xml.sax.ErrorHandler
*/
public class XMLFilterImpl
- implements XMLFilter, EntityResolver, DTDHandler,
- ContentHandler, ErrorHandler
+ implements XMLFilter, EntityResolver, DTDHandler, ContentHandler, ErrorHandler
{
@@ -98,9 +97,9 @@
/**
* Set the parent reader.
*
- * <p>This is the XMLReader from which this filter will obtain
- * its events and to which it will pass its configuration
- * requests. The parent may itself be another filter.</p>
+ * <p>This is the {@link org.xml.sax.XMLReader XMLReader} from which
+ * this filter will obtain its events and to which it will pass its
+ * configuration requests. The parent may itself be another filter.</p>
*
* <p>If there is no parent reader set, any attempt to parse
* or to set or get a feature or property will fail.</p>
@@ -121,7 +120,7 @@
/**
* Get the parent reader.
*
- * @return The parent reader, or null if none is set.
+ * @return The parent XML reader, or null if none is set.
* @see #setParent
*/
public XMLReader getParent ()
@@ -387,8 +386,7 @@
public void parse (String systemId)
throws SAXException, IOException
{
- setupParse();
- parent.parse(systemId);
+ parse(new InputSource(systemId));
}
@@ -562,19 +560,19 @@
*
* @param uri The element's Namespace URI, or the empty string.
* @param localName The element's local name, or the empty string.
- * @param rawName The element's raw XML 1.0 name, or the empty
+ * @param qName The element's qualified (prefixed) name, or the empty
* string.
* @param atts The element's attributes.
* @exception org.xml.sax.SAXException The client may throw
* an exception during processing.
* @see org.xml.sax.ContentHandler#startElement
*/
- public void startElement (String uri, String localName, String rawName,
+ public void startElement (String uri, String localName, String qName,
Attributes atts)
throws SAXException
{
if (contentHandler != null) {
- contentHandler.startElement(uri, localName, rawName, atts);
+ contentHandler.startElement(uri, localName, qName, atts);
}
}
@@ -584,17 +582,17 @@
*
* @param uri The element's Namespace URI, or the empty string.
* @param localName The element's local name, or the empty string.
- * @param rawName The element's raw XML 1.0 name, or the empty
+ * @param qName The element's qualified (prefixed) name, or the empty
* string.
* @exception org.xml.sax.SAXException The client may throw
* an exception during processing.
* @see org.xml.sax.ContentHandler#endElement
*/
- public void endElement (String uri, String localName, String rawName)
+ public void endElement (String uri, String localName, String qName)
throws SAXException
{
if (contentHandler != null) {
- contentHandler.endElement(uri, localName, rawName);
+ contentHandler.endElement(uri, localName, qName);
}
}
1.3 +34 -28 xml-xerces/java/src/org/xml/sax/helpers/XMLReaderAdapter.java
Index: XMLReaderAdapter.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/helpers/XMLReaderAdapter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XMLReaderAdapter.java 2000/03/06 21:06:38 1.2
+++ XMLReaderAdapter.java 2000/05/08 23:08:39 1.3
@@ -2,7 +2,7 @@
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the public domain.
-// $Id: XMLReaderAdapter.java,v 1.3 2000/02/25 14:57:16 david Exp $
+// $Id: XMLReaderAdapter.java,v 1.5 2000/05/05 17:50:46 david Exp $
package org.xml.sax.helpers;
@@ -33,17 +33,18 @@
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* </blockquote>
*
- * <p>This class wraps a SAX2 XMLReader and makes it act as a SAX1
- * Parser. The XMLReader must support a true value for the
+ * <p>This class wraps a SAX2 {@link org.xml.sax.XMLReader XMLReader}
+ * and makes it act as a SAX1 {@link org.xml.sax.Parser Parser}. The XMLReader
+ * must support a true value for the
* http://xml.org/sax/features/namespace-prefixes property or parsing will fail
- * with a SAXException; if the XMLReader supports a false value
- * for the http://xml.org/sax/features/namespaces property, that will
- * also be used to improve efficiency.</p>
+ * with a {@link org.xml.sax.SAXException SAXException}; if the XMLReader
+ * supports a false value for the http://xml.org/sax/features/namespaces
+ * property, that will also be used to improve efficiency.</p>
*
* @since SAX 2.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.Parser
* @see org.xml.sax.XMLReader
*/
@@ -89,13 +90,19 @@
}
+
+ /**
+ * Internal setup.
+ *
+ * @param xmlReader The embedded XMLReader.
+ */
private void setup (XMLReader xmlReader)
{
if (xmlReader == null) {
throw new NullPointerException("XMLReader must not be null");
}
this.xmlReader = xmlReader;
- rawAtts = new AttributesAdapter();
+ qAtts = new AttributesAdapter();
}
@@ -190,8 +197,7 @@
public void parse (String systemId)
throws IOException, SAXException
{
- setupXMLReader();
- xmlReader.parse(systemId);
+ parse(new InputSource(systemId));
}
@@ -229,7 +235,7 @@
xmlReader.setFeature("http://xml.org/sax/features/namespaces",
false);
} catch (SAXException e) {
- // NO OP
+ // NO OP: it's just extra information, and we can ignore it
}
xmlReader.setContentHandler(this);
}
@@ -309,18 +315,18 @@
*
* @param uri The Namespace URI.
* @param localName The Namespace local name.
- * @param rawName The raw XML 1.0 name.
+ * @param qName The qualified (prefixed) name.
* @param atts The SAX2 attributes.
* @exception org.xml.sax.SAXException The client may raise a
* processing exception.
* @see org.xml.sax.ContentHandler#endDocument
*/
public void startElement (String uri, String localName,
- String rawName, Attributes atts)
+ String qName, Attributes atts)
throws SAXException
{
- rawAtts.setAttributes(atts);
- documentHandler.startElement(rawName, rawAtts);
+ qAtts.setAttributes(atts);
+ documentHandler.startElement(qName, qAtts);
}
@@ -329,16 +335,16 @@
*
* @param uri The Namespace URI.
* @param localName The Namespace local name.
- * @param rawName The raw XML 1.0 name.
+ * @param qName The qualified (prefixed) name.
* @exception org.xml.sax.SAXException The client may raise a
* processing exception.
* @see org.xml.sax.ContentHandler#endElement
*/
public void endElement (String uri, String localName,
- String rawName)
+ String qName)
throws SAXException
{
- documentHandler.endElement(rawName);
+ documentHandler.endElement(qName);
}
@@ -411,7 +417,7 @@
XMLReader xmlReader;
DocumentHandler documentHandler;
- AttributesAdapter rawAtts;
+ AttributesAdapter qAtts;
@@ -454,14 +460,14 @@
/**
- * Return the raw name of an attribute by position.
+ * Return the qualified (prefixed) name of an attribute by position.
*
- * @return The raw name.
+ * @return The qualified name.
* @see org.xml.sax.AttributeList#getName
*/
public String getName (int i)
{
- return attributes.getRawName(i);
+ return attributes.getQName(i);
}
@@ -490,26 +496,26 @@
/**
- * Return the type of an attribute by raw name.
+ * Return the type of an attribute by qualified (prefixed) name.
*
* @return The type.
* @see org.xml.sax.AttributeList#getType(java.lang.String)
*/
- public String getType (String rawName)
+ public String getType (String qName)
{
- return attributes.getType(rawName);
+ return attributes.getType(qName);
}
/**
- * Return the value of an attribute by raw name.
+ * Return the value of an attribute by qualified (prefixed) name.
*
* @return The value.
* @see org.xml.sax.AttributeList#getValue(java.lang.String)
*/
- public String getValue (String rawName)
+ public String getValue (String qName)
{
- return attributes.getValue(rawName);
+ return attributes.getValue(qName);
}
private Attributes attributes;
1.2 +20 -6 xml-xerces/java/src/org/xml/sax/helpers/XMLReaderFactory.java
Index: XMLReaderFactory.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/xml/sax/helpers/XMLReaderFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XMLReaderFactory.java 2000/03/06 21:06:38 1.1
+++ XMLReaderFactory.java 2000/05/08 23:08:39 1.2
@@ -2,11 +2,12 @@
// Written by David Megginson, sax@megginson.com
// NO WARRANTY! This class is in the Public Domain.
-// $Id: XMLReaderFactory.java,v 1.1 2000/02/25 11:47:41 david Exp $
+// $Id: XMLReaderFactory.java,v 1.3 2000/05/05 17:50:53 david Exp $
package org.xml.sax.helpers;
-import org.xml.sax.SAXException;
+import org.xml.sax.Parser;
import org.xml.sax.XMLReader;
+import org.xml.sax.SAXException;
/**
@@ -34,16 +35,19 @@
* system properties are not accessible or where the application or
* applet is not permitted to load classes dynamically.</p>
*
+ * <p><strong>Note to implementors:</strong> SAX implementations in specialized
+ * environments may replace this class with a different one optimized for the
+ * environment, as long as its method signatures remain the same.</p>
+ *
* @since SAX 2.0
* @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
- * @version 2.0beta
+ * @version 2.0
* @see org.xml.sax.XMLReader
*/
final public class XMLReaderFactory
{
-
/**
* Private constructor.
*
@@ -76,8 +80,18 @@
{
String className = System.getProperty("org.xml.sax.driver");
if (className == null) {
- throw new
- SAXException("System property org.xml.sax.driver not specified");
+ Parser parser;
+ try {
+ parser = ParserFactory.makeParser();
+ } catch (Exception e) {
+ parser = null;
+ }
+ if (parser == null) {
+ throw new
+ SAXException("System property org.xml.sax.driver not specified");
+ } else {
+ return new ParserAdapter(parser);
+ }
} else {
return createXMLReader(className);
}
Re: cvs commit: xml-xerces/java/src/org/xml/sax/helpers AttributeListImpl.java AttributesImpl.java DefaultHandler.java LocatorImpl.java NamespaceSupport.java ParserAdapter.java ParserFactory.java XMLFilterImpl.java XMLReaderAdapter.java XMLReaderFactory.ja
Posted by Edwin Goei <Ed...@eng.sun.com>.
I just did an update and tried to rebuild, but the tree doesn't build
because of at least some SAX2 name changes. Is someone already working on a
fix for these?
-Edwin
To: <xm...@apache.org>
Sent: Monday, May 08, 2000 4:08 PM
Subject: cvs commit: xml-xerces/java/src/org/xml/sax/helpers
AttributeListImpl.java AttributesImpl.java DefaultHandler.java
LocatorImpl.java NamespaceSupport.java ParserAdapter.java ParserFactory.java
XMLFilterImpl.java XMLReaderAdapter.java XMLReaderFactory.java
> Log:
> updated to SAX2
> [...]