Commit 7a163ec0 by Anthony Green Committed by Tom Tromey

Makefile.am (ordinary_java_source_files): Add org/xml/sax/helpers/NewInstance.java.

2002-12-19  Anthony Green  <green@redhat.com>

	* Makefile.am (ordinary_java_source_files): Add
	org/xml/sax/helpers/NewInstance.java.
	* Makefile.in: Rebuilt.
	* org/xml/sax/package.html, org/xml/sax/ext/package.html,
	org/xml/sax/helpers/package.html: New files.
	* org/xml/sax/*: Upgrade to SAX 2.0.1 release from
	http://www.saxproject.org.

From-SVN: r60350
parent 51d6eed4
2002-12-19 Anthony Green <green@redhat.com>
* Makefile.am (ordinary_java_source_files): Add
org/xml/sax/helpers/NewInstance.java.
* Makefile.in: Rebuilt.
* org/xml/sax/package.html, org/xml/sax/ext/package.html,
org/xml/sax/helpers/package.html: New files.
* org/xml/sax/*: Upgrade to SAX 2.0.1 release from
http://www.saxproject.org.
2002-12-19 Andrew Haley <aph@redhat.com> 2002-12-19 Andrew Haley <aph@redhat.com>
* java/util/natResourceBundle.cc: Include * java/util/natResourceBundle.cc: Include
......
...@@ -2252,6 +2252,7 @@ org/xml/sax/helpers/AttributesImpl.java \ ...@@ -2252,6 +2252,7 @@ org/xml/sax/helpers/AttributesImpl.java \
org/xml/sax/helpers/DefaultHandler.java \ org/xml/sax/helpers/DefaultHandler.java \
org/xml/sax/helpers/LocatorImpl.java \ org/xml/sax/helpers/LocatorImpl.java \
org/xml/sax/helpers/NamespaceSupport.java \ org/xml/sax/helpers/NamespaceSupport.java \
org/xml/sax/helpers/NewInstance.java \
org/xml/sax/helpers/ParserAdapter.java \ org/xml/sax/helpers/ParserAdapter.java \
org/xml/sax/helpers/ParserFactory.java \ org/xml/sax/helpers/ParserFactory.java \
org/xml/sax/helpers/XMLFilterImpl.java \ org/xml/sax/helpers/XMLFilterImpl.java \
......
...@@ -2002,6 +2002,7 @@ org/xml/sax/helpers/AttributesImpl.java \ ...@@ -2002,6 +2002,7 @@ org/xml/sax/helpers/AttributesImpl.java \
org/xml/sax/helpers/DefaultHandler.java \ org/xml/sax/helpers/DefaultHandler.java \
org/xml/sax/helpers/LocatorImpl.java \ org/xml/sax/helpers/LocatorImpl.java \
org/xml/sax/helpers/NamespaceSupport.java \ org/xml/sax/helpers/NamespaceSupport.java \
org/xml/sax/helpers/NewInstance.java \
org/xml/sax/helpers/ParserAdapter.java \ org/xml/sax/helpers/ParserAdapter.java \
org/xml/sax/helpers/ParserFactory.java \ org/xml/sax/helpers/ParserFactory.java \
org/xml/sax/helpers/XMLFilterImpl.java \ org/xml/sax/helpers/XMLFilterImpl.java \
...@@ -3701,6 +3702,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ ...@@ -3701,6 +3702,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/org/xml/sax/helpers/DefaultHandler.P \ .deps/org/xml/sax/helpers/DefaultHandler.P \
.deps/org/xml/sax/helpers/LocatorImpl.P \ .deps/org/xml/sax/helpers/LocatorImpl.P \
.deps/org/xml/sax/helpers/NamespaceSupport.P \ .deps/org/xml/sax/helpers/NamespaceSupport.P \
.deps/org/xml/sax/helpers/NewInstance.P \
.deps/org/xml/sax/helpers/ParserAdapter.P \ .deps/org/xml/sax/helpers/ParserAdapter.P \
.deps/org/xml/sax/helpers/ParserFactory.P \ .deps/org/xml/sax/helpers/ParserFactory.P \
.deps/org/xml/sax/helpers/XMLFilterImpl.P \ .deps/org/xml/sax/helpers/XMLFilterImpl.P \
......
// SAX Attribute List Interface. // SAX Attribute List Interface.
// http://www.saxproject.org
// No warranty; no copyright -- use this as you will. // No warranty; no copyright -- use this as you will.
// $Id: AttributeList.java,v 1.1 2000/10/02 02:43:16 sboag Exp $ // $Id: AttributeList.java,v 1.3.2.3 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax; package org.xml.sax;
...@@ -10,6 +11,8 @@ package org.xml.sax; ...@@ -10,6 +11,8 @@ package org.xml.sax;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>This is the original SAX1 interface for reporting an element's * <p>This is the original SAX1 interface for reporting an element's
...@@ -61,9 +64,8 @@ package org.xml.sax; ...@@ -61,9 +64,8 @@ package org.xml.sax;
* {@link org.xml.sax.Attributes Attributes} * {@link org.xml.sax.Attributes Attributes}
* interface, which includes Namespace support. * interface, which includes Namespace support.
* @since SAX 1.0 * @since SAX 1.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.DocumentHandler#startElement startElement * @see org.xml.sax.DocumentHandler#startElement startElement
* @see org.xml.sax.helpers.AttributeListImpl AttributeListImpl * @see org.xml.sax.helpers.AttributeListImpl AttributeListImpl
*/ */
......
// Attributes.java - attribute list with Namespace support // Attributes.java - attribute list with Namespace support
// Written by David Megginson, sax@megginson.com // http://www.saxproject.org
// Written by David Megginson
// NO WARRANTY! This class is in the public domain. // NO WARRANTY! This class is in the public domain.
// $Id: Attributes.java,v 1.1 2000/10/02 02:43:16 sboag Exp $ // $Id: Attributes.java,v 1.5.2.4 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax; package org.xml.sax;
...@@ -14,6 +15,8 @@ package org.xml.sax; ...@@ -14,6 +15,8 @@ package org.xml.sax;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>This interface allows access to a list of attributes in * <p>This interface allows access to a list of attributes in
...@@ -30,7 +33,13 @@ package org.xml.sax; ...@@ -30,7 +33,13 @@ package org.xml.sax;
* contain attributes used as Namespace declarations (xmlns*) unless * contain attributes used as Namespace declarations (xmlns*) unless
* the <code>http://xml.org/sax/features/namespace-prefixes</code> * the <code>http://xml.org/sax/features/namespace-prefixes</code>
* feature is set to <var>true</var> (it is <var>false</var> by * feature is set to <var>true</var> (it is <var>false</var> by
* default).</p> * default).
* Because SAX2 conforms to the "Namespaces in XML" specification,
* it does not give namespace declaration attributes a namespace URI.
* Some other W3C specifications are in conflict with that, expecting
* these declarations to be in a namespace.
* Handler code may need to resolve that conflict.
* </p>
* *
* <p>If the namespace-prefixes feature (see above) is <var>false</var>, * <p>If the namespace-prefixes feature (see above) is <var>false</var>,
* access by qualified name may not be available; if the * access by qualified name may not be available; if the
...@@ -47,10 +56,10 @@ package org.xml.sax; ...@@ -47,10 +56,10 @@ package org.xml.sax;
* vary from implementation to implementation.</p> * vary from implementation to implementation.</p>
* *
* @since SAX 2.0 * @since SAX 2.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0 * @see org.xml.sax.helpers.AttributesImpl
* @see org.xml.sax.helpers.AttributeListImpl * @see org.xml.sax.ext.DeclHandler#attributeDecl
*/ */
public interface Attributes public interface Attributes
{ {
...@@ -167,7 +176,7 @@ public interface Attributes ...@@ -167,7 +176,7 @@ public interface Attributes
* @return The index of the attribute, or -1 if it does not * @return The index of the attribute, or -1 if it does not
* appear in the list. * appear in the list.
*/ */
public int getIndex (String uri, String localPart); public int getIndex (String uri, String localName);
/** /**
......
// ContentHandler.java - handle main document content. // ContentHandler.java - handle main document content.
// Written by David Megginson, sax@megginson.com // http://www.saxproject.org
// Written by David Megginson
// NO WARRANTY! This class is in the public domain. // NO WARRANTY! This class is in the public domain.
// $Id: ContentHandler.java,v 1.1 2000/10/02 02:43:16 sboag Exp $ // $Id: ContentHandler.java,v 1.4.2.9 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax; package org.xml.sax;
...@@ -13,6 +14,8 @@ package org.xml.sax; ...@@ -13,6 +14,8 @@ package org.xml.sax;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>This is the main interface that most SAX applications * <p>This is the main interface that most SAX applications
...@@ -48,9 +51,8 @@ package org.xml.sax; ...@@ -48,9 +51,8 @@ package org.xml.sax;
* bug.</p> * bug.</p>
* *
* @since SAX 2.0 * @since SAX 2.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.XMLReader * @see org.xml.sax.XMLReader
* @see org.xml.sax.DTDHandler * @see org.xml.sax.DTDHandler
* @see org.xml.sax.ErrorHandler * @see org.xml.sax.ErrorHandler
...@@ -90,8 +92,7 @@ public interface ContentHandler ...@@ -90,8 +92,7 @@ public interface ContentHandler
* Receive notification of the beginning of a document. * Receive notification of the beginning of a document.
* *
* <p>The SAX parser will invoke this method only once, before any * <p>The SAX parser will invoke this method only once, before any
* other methods in this interface or in {@link org.xml.sax.DTDHandler * other event callbacks (except for {@link #setDocumentLocator
* DTDHandler} (except for {@link #setDocumentLocator
* setDocumentLocator}).</p> * setDocumentLocator}).</p>
* *
* @exception org.xml.sax.SAXException Any SAX exception, possibly * @exception org.xml.sax.SAXException Any SAX exception, possibly
...@@ -136,18 +137,21 @@ public interface ContentHandler ...@@ -136,18 +137,21 @@ public interface ContentHandler
* itself, if necessary.</p> * itself, if necessary.</p>
* *
* <p>Note that start/endPrefixMapping events are not * <p>Note that start/endPrefixMapping events are not
* guaranteed to be properly nested relative to each-other: * guaranteed to be properly nested relative to each other:
* all startPrefixMapping events will occur before the * all startPrefixMapping events will occur immediately before the
* corresponding {@link #startElement startElement} event, * corresponding {@link #startElement startElement} event,
* and all {@link #endPrefixMapping endPrefixMapping} * and all {@link #endPrefixMapping endPrefixMapping}
* events will occur after the corresponding {@link #endElement * events will occur immediately after the corresponding
* endElement} event, but their order is not otherwise * {@link #endElement endElement} event,
* but their order is not otherwise
* guaranteed.</p> * guaranteed.</p>
* *
* <p>There should never be start/endPrefixMapping events for the * <p>There should never be start/endPrefixMapping events for the
* "xml" prefix, since it is predeclared and immutable.</p> * "xml" prefix, since it is predeclared and immutable.</p>
* *
* @param prefix The Namespace prefix being declared. * @param prefix The Namespace prefix being declared.
* An empty string is used for the default element namespace,
* which has no prefix.
* @param uri The Namespace URI the prefix is mapped to. * @param uri The Namespace URI the prefix is mapped to.
* @exception org.xml.sax.SAXException The client may throw * @exception org.xml.sax.SAXException The client may throw
* an exception during processing. * an exception during processing.
...@@ -162,12 +166,13 @@ public interface ContentHandler ...@@ -162,12 +166,13 @@ public interface ContentHandler
* End the scope of a prefix-URI mapping. * End the scope of a prefix-URI mapping.
* *
* <p>See {@link #startPrefixMapping startPrefixMapping} for * <p>See {@link #startPrefixMapping startPrefixMapping} for
* details. This event will always occur after the corresponding * details. These events will always occur immediately after the
* {@link #endElement endElement} event, but the order of * corresponding {@link #endElement endElement} event, but the order of
* {@link #endPrefixMapping endPrefixMapping} events is not otherwise * {@link #endPrefixMapping endPrefixMapping} events is not otherwise
* guaranteed.</p> * guaranteed.</p>
* *
* @param prefix The prefix that was being mapping. * @param prefix The prefix that was being mapping.
* This is the empty string when a default mapping scope ends.
* @exception org.xml.sax.SAXException The client may throw * @exception org.xml.sax.SAXException The client may throw
* an exception during processing. * an exception during processing.
* @see #startPrefixMapping * @see #startPrefixMapping
...@@ -220,6 +225,9 @@ public interface ContentHandler ...@@ -220,6 +225,9 @@ public interface ContentHandler
* property is true (it is false by default, and support for a * property is true (it is false by default, and support for a
* true value is optional).</p> * true value is optional).</p>
* *
* <p>Like {@link #characters characters()}, attribute values may have
* characters that need more than one <code>char</code> value. </p>
*
* @param uri The Namespace URI, or the empty string if the * @param uri The Namespace URI, or the empty string if the
* element has no Namespace URI or if Namespace * element has no Namespace URI or if Namespace
* processing is not being performed. * processing is not being performed.
...@@ -236,7 +244,7 @@ public interface ContentHandler ...@@ -236,7 +244,7 @@ public interface ContentHandler
* @see #endElement * @see #endElement
* @see org.xml.sax.Attributes * @see org.xml.sax.Attributes
*/ */
public void startElement (String namespaceURI, String localName, public void startElement (String uri, String localName,
String qName, Attributes atts) String qName, Attributes atts)
throws SAXException; throws SAXException;
...@@ -262,7 +270,7 @@ public interface ContentHandler ...@@ -262,7 +270,7 @@ public interface ContentHandler
* @exception org.xml.sax.SAXException Any SAX exception, possibly * @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception. * wrapping another exception.
*/ */
public void endElement (String namespaceURI, String localName, public void endElement (String uri, String localName,
String qName) String qName)
throws SAXException; throws SAXException;
...@@ -280,6 +288,23 @@ public interface ContentHandler ...@@ -280,6 +288,23 @@ public interface ContentHandler
* <p>The application must not attempt to read from the array * <p>The application must not attempt to read from the array
* outside of the specified range.</p> * outside of the specified range.</p>
* *
* <p>Individual characters may consist of more than one Java
* <code>char</code> value. There are two important cases where this
* happens, because characters can't be represented in just sixteen bits.
* In one case, characters are represented in a <em>Surrogate Pair</em>,
* using two special Unicode values. Such characters are in the so-called
* "Astral Planes", with a code point above U+FFFF. A second case involves
* composite characters, such as a base character combining with one or
* more accent characters. </p>
*
* <p> Your code should not assume that algorithms using
* <code>char</code>-at-a-time idioms will be working in character
* units; in some cases they will split characters. This is relevant
* wherever XML permits arbitrary characters, such as attribute values,
* processing instruction data, and comments as well as in data reported
* from this method. It's also generally relevant whenever Java code
* manipulates internationalized text; the issue isn't unique to XML.</p>
*
* <p>Note that some parsers will report whitespace in element * <p>Note that some parsers will report whitespace in element
* content using the {@link #ignorableWhitespace ignorableWhitespace} * content using the {@link #ignorableWhitespace ignorableWhitespace}
* method rather than this one (validating parsers <em>must</em> * method rather than this one (validating parsers <em>must</em>
...@@ -336,6 +361,10 @@ public interface ContentHandler ...@@ -336,6 +361,10 @@ public interface ContentHandler
* section 2.8) or a text declaration (XML 1.0, section 4.3.1) * section 2.8) or a text declaration (XML 1.0, section 4.3.1)
* using this method.</p> * using this method.</p>
* *
* <p>Like {@link #characters characters()}, processing instruction
* data may have characters that need more than one <code>char</code>
* value. </p>
*
* @param target The processing instruction target. * @param target The processing instruction target.
* @param data The processing instruction data, or null if * @param data The processing instruction data, or null if
* none was supplied. The data does not include any * none was supplied. The data does not include any
...@@ -349,8 +378,13 @@ public interface ContentHandler ...@@ -349,8 +378,13 @@ public interface ContentHandler
/** /**
* Receive notification of a skipped entity. * Receive notification of a skipped entity.
* This is not called for entity references within markup constructs
* such as element start tags or markup declarations. (The XML
* recommendation requires reporting skipped external entities.
* SAX also reports internal entity expansion/non-expansion, except
* within markup constructs.)
* *
* <p>The Parser will invoke this method once for each entity * <p>The Parser will invoke this method each time the entity is
* skipped. Non-validating processors may skip entities if they * skipped. Non-validating processors may skip entities if they
* have not seen the declarations (because, for example, the * have not seen the declarations (because, for example, the
* entity was declared in an external DTD subset). All processors * entity was declared in an external DTD subset). All processors
......
// SAX DTD handler. // SAX DTD handler.
// http://www.saxproject.org
// No warranty; no copyright -- use this as you will. // No warranty; no copyright -- use this as you will.
// $Id: DTDHandler.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ // $Id: DTDHandler.java,v 1.5.2.4 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax; package org.xml.sax;
...@@ -10,6 +11,8 @@ package org.xml.sax; ...@@ -10,6 +11,8 @@ package org.xml.sax;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>If a SAX application needs information about notations and * <p>If a SAX application needs information about notations and
...@@ -27,7 +30,10 @@ package org.xml.sax; ...@@ -27,7 +30,10 @@ package org.xml.sax;
* of the order in which the notations and unparsed entities were * of the order in which the notations and unparsed entities were
* declared; however, all DTD events must be reported after the * declared; however, all DTD events must be reported after the
* document handler's startDocument event, and before the first * document handler's startDocument event, and before the first
* startElement event.</p> * startElement event.
* (If the {@link org.xml.sax.ext.LexicalHandler LexicalHandler} is
* used, these events must also be reported before the endDTD event.)
* </p>
* *
* <p>It is up to the application to store the information for * <p>It is up to the application to store the information for
* future use (perhaps in a hash table or object tree). * future use (perhaps in a hash table or object tree).
...@@ -37,11 +43,9 @@ package org.xml.sax; ...@@ -37,11 +43,9 @@ package org.xml.sax;
* notation corresponding with the attribute value.</p> * notation corresponding with the attribute value.</p>
* *
* @since SAX 1.0 * @since SAX 1.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0 * @see org.xml.sax.XMLReader#setDTDHandler
* @see org.xml.sax.Parser#setDTDHandler
* @see org.xml.sax.HandlerBase
*/ */
public interface DTDHandler { public interface DTDHandler {
...@@ -50,7 +54,10 @@ public interface DTDHandler { ...@@ -50,7 +54,10 @@ public interface DTDHandler {
* Receive notification of a notation declaration event. * Receive notification of a notation declaration event.
* *
* <p>It is up to the application to record the notation for later * <p>It is up to the application to record the notation for later
* reference, if necessary.</p> * reference, if necessary;
* notations may appear as attribute values and in unparsed entity
* declarations, and are sometime used with processing instruction
* target names.</p>
* *
* <p>At least one of publicId and systemId must be non-null. * <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 * If a system identifier is present, and it is a URL, the SAX
...@@ -68,7 +75,7 @@ public interface DTDHandler { ...@@ -68,7 +75,7 @@ public interface DTDHandler {
* @exception org.xml.sax.SAXException Any SAX exception, possibly * @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception. * wrapping another exception.
* @see #unparsedEntityDecl * @see #unparsedEntityDecl
* @see org.xml.sax.AttributeList * @see org.xml.sax.Attributes
*/ */
public abstract void notationDecl (String name, public abstract void notationDecl (String name,
String publicId, String publicId,
...@@ -82,7 +89,9 @@ public interface DTDHandler { ...@@ -82,7 +89,9 @@ public interface DTDHandler {
* <p>Note that the notation name corresponds to a notation * <p>Note that the notation name corresponds to a notation
* reported by the {@link #notationDecl notationDecl} event. * reported by the {@link #notationDecl notationDecl} event.
* It is up to the application to record the entity for later * It is up to the application to record the entity for later
* reference, if necessary.</p> * reference, if necessary;
* unparsed entities may appear as attribute values.
* </p>
* *
* <p>If the system identifier is a URL, the parser must resolve it * <p>If the system identifier is a URL, the parser must resolve it
* fully before passing it to the application.</p> * fully before passing it to the application.</p>
...@@ -93,9 +102,9 @@ public interface DTDHandler { ...@@ -93,9 +102,9 @@ public interface DTDHandler {
* @param publicId The entity's public identifier, or null if none * @param publicId The entity's public identifier, or null if none
* was given. * was given.
* @param systemId The entity's system identifier. * @param systemId The entity's system identifier.
* @param notation name The name of the associated notation. * @param notationName The name of the associated notation.
* @see #notationDecl * @see #notationDecl
* @see org.xml.sax.AttributeList * @see org.xml.sax.Attributes
*/ */
public abstract void unparsedEntityDecl (String name, public abstract void unparsedEntityDecl (String name,
String publicId, String publicId,
......
// SAX document handler. // SAX document handler.
// http://www.saxproject.org
// No warranty; no copyright -- use this as you will. // No warranty; no copyright -- use this as you will.
// $Id: DocumentHandler.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ // $Id: DocumentHandler.java,v 1.3.2.3 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax; package org.xml.sax;
...@@ -10,6 +11,8 @@ package org.xml.sax; ...@@ -10,6 +11,8 @@ package org.xml.sax;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>This was the main event-handling interface for SAX1; in * <p>This was the main event-handling interface for SAX1; in
...@@ -35,9 +38,8 @@ package org.xml.sax; ...@@ -35,9 +38,8 @@ package org.xml.sax;
* {@link org.xml.sax.ContentHandler ContentHandler} * {@link org.xml.sax.ContentHandler ContentHandler}
* interface, which includes Namespace support. * interface, which includes Namespace support.
* @since SAX 1.0 * @since SAX 1.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.Parser#setDocumentHandler * @see org.xml.sax.Parser#setDocumentHandler
* @see org.xml.sax.Locator * @see org.xml.sax.Locator
* @see org.xml.sax.HandlerBase * @see org.xml.sax.HandlerBase
......
// SAX entity resolver. // SAX entity resolver.
// http://www.saxproject.org
// No warranty; no copyright -- use this as you will. // No warranty; no copyright -- use this as you will.
// $Id: EntityResolver.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ // $Id: EntityResolver.java,v 1.7.2.3 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax; package org.xml.sax;
...@@ -13,6 +14,8 @@ import java.io.IOException; ...@@ -13,6 +14,8 @@ import java.io.IOException;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>If a SAX application needs to implement customized handling * <p>If a SAX application needs to implement customized handling
...@@ -58,10 +61,9 @@ import java.io.IOException; ...@@ -58,10 +61,9 @@ import java.io.IOException;
* (possibly by using the public identifier).</p> * (possibly by using the public identifier).</p>
* *
* @since SAX 1.0 * @since SAX 1.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0 * @see org.xml.sax.XMLReader#setEntityResolver
* @see org.xml.sax.Parser#setEntityResolver
* @see org.xml.sax.InputSource * @see org.xml.sax.InputSource
*/ */
public interface EntityResolver { public interface EntityResolver {
...@@ -70,19 +72,26 @@ public interface EntityResolver { ...@@ -70,19 +72,26 @@ public interface EntityResolver {
/** /**
* Allow the application to resolve external entities. * Allow the application to resolve external entities.
* *
* <p>The Parser will call this method before opening any external * <p>The parser will call this method before opening any external
* entity except the top-level document entity (including the * entity except the top-level document entity. Such entities include
* external DTD subset, external entities referenced within the * the external DTD subset and external parameter entities referenced
* DTD, and external entities referenced within the document * within the DTD (in either case, only if the parser reads external
* element): the application may request that the parser resolve * parameter entities), and external general entities referenced
* within the document element (if the parser reads external general
* entities). The application may request that the parser locate
* the entity itself, that it use an alternative URI, or that it * the entity itself, that it use an alternative URI, or that it
* use an entirely different input source.</p> * use data provided by the application (as a character or byte
* input stream).</p>
* *
* <p>Application writers can use this method to redirect external * <p>Application writers can use this method to redirect external
* system identifiers to secure and/or local URIs, to look up * system identifiers to secure and/or local URIs, to look up
* public identifiers in a catalogue, or to read an entity from a * public identifiers in a catalogue, or to read an entity from a
* database or other input source (including, for example, a dialog * database or other input source (including, for example, a dialog
* box).</p> * box). Neither XML nor SAX specifies a preferred policy for using
* public or system IDs to resolve resources. However, SAX specifies
* how to interpret any InputSource returned by this method, and that
* if none is returned, then the system ID will be dereferenced as
* a URL. </p>
* *
* <p>If the system identifier is a URL, the SAX parser must * <p>If the system identifier is a URL, the SAX parser must
* resolve it fully before reporting it to the application.</p> * resolve it fully before reporting it to the application.</p>
......
// SAX error handler. // SAX error handler.
// http://www.saxproject.org
// No warranty; no copyright -- use this as you will. // No warranty; no copyright -- use this as you will.
// $Id: ErrorHandler.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ // $Id: ErrorHandler.java,v 1.4.2.3 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax; package org.xml.sax;
...@@ -11,6 +12,8 @@ package org.xml.sax; ...@@ -11,6 +12,8 @@ package org.xml.sax;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>If a SAX application needs to implement customized error * <p>If a SAX application needs to implement customized error
...@@ -33,10 +36,9 @@ package org.xml.sax; ...@@ -33,10 +36,9 @@ package org.xml.sax;
* could catch an exception and report a fatalError).</p> * could catch an exception and report a fatalError).</p>
* *
* @since SAX 1.0 * @since SAX 1.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0 * @see org.xml.sax.XMLReader#setErrorHandler
* @see org.xml.sax.Parser#setErrorHandler
* @see org.xml.sax.SAXParseException * @see org.xml.sax.SAXParseException
*/ */
public interface ErrorHandler { public interface ErrorHandler {
......
// SAX default handler base class. // SAX default handler base class.
// http://www.saxproject.org
// No warranty; no copyright -- use this as you will. // No warranty; no copyright -- use this as you will.
// $Id: HandlerBase.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ // $Id: HandlerBase.java,v 1.3.2.3 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax; package org.xml.sax;
...@@ -10,6 +11,8 @@ package org.xml.sax; ...@@ -10,6 +11,8 @@ package org.xml.sax;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>This class implements the default behaviour for four SAX1 * <p>This class implements the default behaviour for four SAX1
...@@ -32,9 +35,8 @@ package org.xml.sax; ...@@ -32,9 +35,8 @@ package org.xml.sax;
* {@link org.xml.sax.helpers.DefaultHandler DefaultHandler} * {@link org.xml.sax.helpers.DefaultHandler DefaultHandler}
* class. * class.
* @since SAX 1.0 * @since SAX 1.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.EntityResolver * @see org.xml.sax.EntityResolver
* @see org.xml.sax.DTDHandler * @see org.xml.sax.DTDHandler
* @see org.xml.sax.DocumentHandler * @see org.xml.sax.DocumentHandler
...@@ -58,7 +60,7 @@ public class HandlerBase ...@@ -58,7 +60,7 @@ public class HandlerBase
* in a subclass to do special translations such as catalog lookups * in a subclass to do special translations such as catalog lookups
* or URI redirection.</p> * or URI redirection.</p>
* *
* @param publicId The public identifier, or null if none is * @param publicId The public identifer, or null if none is
* available. * available.
* @param systemId The system identifier provided in the XML * @param systemId The system identifier provided in the XML
* document. * document.
......
// SAX input source. // SAX input source.
// http://www.saxproject.org
// No warranty; no copyright -- use this as you will. // No warranty; no copyright -- use this as you will.
// $Id: InputSource.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ // $Id: InputSource.java,v 1.5.2.4 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax; package org.xml.sax;
...@@ -13,6 +14,8 @@ import java.io.InputStream; ...@@ -13,6 +14,8 @@ import java.io.InputStream;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>This class allows a SAX application to encapsulate information * <p>This class allows a SAX application to encapsulate information
...@@ -20,28 +23,36 @@ import java.io.InputStream; ...@@ -20,28 +23,36 @@ import java.io.InputStream;
* a public identifier, a system identifier, a byte stream (possibly * a public identifier, a system identifier, a byte stream (possibly
* with a specified encoding), and/or a character stream.</p> * with a specified encoding), and/or a character stream.</p>
* *
* <p>There are two places that the application will deliver this * <p>There are two places that the application can deliver an
* input source to the parser: as the argument to the Parser.parse * input source to the parser: as the argument to the Parser.parse
* method, or as the return value of the EntityResolver.resolveEntity * method, or as the return value of the EntityResolver.resolveEntity
* method.</p> * method.</p>
* *
* <p>The SAX parser will use the InputSource object to determine how * <p>The SAX parser will use the InputSource object to determine how
* to read XML input. If there is a character stream available, the * to read XML input. If there is a character stream available, the
* parser will read that stream directly; if not, the parser will use * parser will read that stream directly, disregarding any text
* a byte stream, if available; if neither a character stream nor a * encoding declaration found in that stream.
* If there is no character stream, but there is
* a byte stream, the parser will use that byte stream, using the
* encoding specified in the InputSource or else (if no encoding is
* specified) autodetecting the character encoding using an algorithm
* such as the one in the XML specification. If neither a character
* stream nor a
* byte stream is available, the parser will attempt to open a URI * byte stream is available, the parser will attempt to open a URI
* connection to the resource identified by the system * connection to the resource identified by the system
* identifier.</p> * identifier.</p>
* *
* <p>An InputSource object belongs to the application: the SAX parser * <p>An InputSource object belongs to the application: the SAX parser
* shall never modify it in any way (it may modify a copy if * shall never modify it in any way (it may modify a copy if
* necessary).</p> * necessary). However, standard processing of both byte and
* character streams is to close them on as part of end-of-parse cleanup,
* so applications should not attempt to re-use such streams after they
* have been handed to a parser. </p>
* *
* @since SAX 1.0 * @since SAX 1.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0 * @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource)
* @see org.xml.sax.Parser#parse
* @see org.xml.sax.EntityResolver#resolveEntity * @see org.xml.sax.EntityResolver#resolveEntity
* @see java.io.InputStream * @see java.io.InputStream
* @see java.io.Reader * @see java.io.Reader
...@@ -69,7 +80,8 @@ public class InputSource { ...@@ -69,7 +80,8 @@ public class InputSource {
* public identifier as well, or setEncoding to specify * public identifier as well, or setEncoding to specify
* the character encoding, if known.</p> * the character encoding, if known.</p>
* *
* <p>If the system identifier is a URL, it must be full resolved.</p> * <p>If the system identifier is a URL, it must be fully
* resolved (it may not be a relative URL).</p>
* *
* @param systemId The system identifier (URI). * @param systemId The system identifier (URI).
* @see #setPublicId * @see #setPublicId
...@@ -87,9 +99,9 @@ public class InputSource { ...@@ -87,9 +99,9 @@ public class InputSource {
/** /**
* Create a new input source with a byte stream. * Create a new input source with a byte stream.
* *
* <p>Application writers may use setSystemId to provide a base * <p>Application writers should use setSystemId() to provide a base
* for resolving relative URIs, setPublicId to include a * for resolving relative URIs, may use setPublicId to include a
* public identifier, and/or setEncoding to specify the object's * public identifier, and may use setEncoding to specify the object's
* character encoding.</p> * character encoding.</p>
* *
* @param byteStream The raw byte stream containing the document. * @param byteStream The raw byte stream containing the document.
...@@ -108,8 +120,8 @@ public class InputSource { ...@@ -108,8 +120,8 @@ public class InputSource {
/** /**
* Create a new input source with a character stream. * Create a new input source with a character stream.
* *
* <p>Application writers may use setSystemId() to provide a base * <p>Application writers should use setSystemId() to provide a base
* for resolving relative URIs, and setPublicId to include a * for resolving relative URIs, and may use setPublicId to include a
* public identifier.</p> * public identifier.</p>
* *
* <p>The character stream shall not include a byte order mark.</p> * <p>The character stream shall not include a byte order mark.</p>
...@@ -169,7 +181,8 @@ public class InputSource { ...@@ -169,7 +181,8 @@ public class InputSource {
* object pointed to by the system identifier, it can register * object pointed to by the system identifier, it can register
* the encoding using the setEncoding method.</p> * the encoding using the setEncoding method.</p>
* *
* <p>If the system ID is a URL, it must be fully resolved.</p> * <p>If the system identifier is a URL, it must be fully
* resolved (it may not be a relative URL).</p>
* *
* @param systemId The system identifier as a string. * @param systemId The system identifier as a string.
* @see #setEncoding * @see #setEncoding
...@@ -191,7 +204,7 @@ public class InputSource { ...@@ -191,7 +204,7 @@ public class InputSource {
* *
* <p>If the system ID is a URL, it will be fully resolved.</p> * <p>If the system ID is a URL, it will be fully resolved.</p>
* *
* @return The system identifier. * @return The system identifier, or null if none was supplied.
* @see #setSystemId * @see #setSystemId
* @see #getEncoding * @see #getEncoding
*/ */
...@@ -263,6 +276,8 @@ public class InputSource { ...@@ -263,6 +276,8 @@ public class InputSource {
/** /**
* Get the character encoding for a byte stream or URI. * Get the character encoding for a byte stream or URI.
* This value will be ignored when the application provides a
* character stream.
* *
* @return The encoding, or null if none was supplied. * @return The encoding, or null if none was supplied.
* @see #setByteStream * @see #setByteStream
......
// SAX locator interface for document events. // SAX locator interface for document events.
// http://www.saxproject.org
// No warranty; no copyright -- use this as you will. // No warranty; no copyright -- use this as you will.
// $Id: Locator.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ // $Id: Locator.java,v 1.4.2.5 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax; package org.xml.sax;
...@@ -11,6 +12,8 @@ package org.xml.sax; ...@@ -11,6 +12,8 @@ package org.xml.sax;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>If a SAX parser provides location information to the SAX * <p>If a SAX parser provides location information to the SAX
...@@ -18,13 +21,13 @@ package org.xml.sax; ...@@ -18,13 +21,13 @@ package org.xml.sax;
* passing an instance to the application using the content * passing an instance to the application using the content
* handler's {@link org.xml.sax.ContentHandler#setDocumentLocator * handler's {@link org.xml.sax.ContentHandler#setDocumentLocator
* setDocumentLocator} method. The application can use the * setDocumentLocator} method. The application can use the
* object to obtain the location of any other content handler event * object to obtain the location of any other SAX event
* in the XML source document.</p> * in the XML source document.</p>
* *
* <p>Note that the results returned by the object will be valid only * <p>Note that the results returned by the object will be valid only
* during the scope of each content handler method: the application * during the scope of each callback method: the application
* will receive unpredictable results if it attempts to use the * will receive unpredictable results if it attempts to use the
* locator at any other time.</p> * locator at any other time, or after parsing completes.</p>
* *
* <p>SAX parsers are not required to supply a locator, but they are * <p>SAX parsers are not required to supply a locator, but they are
* very strongly encouraged to do so. If the parser supplies a * very strongly encouraged to do so. If the parser supplies a
...@@ -35,9 +38,8 @@ package org.xml.sax; ...@@ -35,9 +38,8 @@ package org.xml.sax;
* available.</p> * available.</p>
* *
* @since SAX 1.0 * @since SAX 1.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.ContentHandler#setDocumentLocator * @see org.xml.sax.ContentHandler#setDocumentLocator
*/ */
public interface Locator { public interface Locator {
...@@ -65,7 +67,9 @@ public interface Locator { ...@@ -65,7 +67,9 @@ public interface Locator {
* triggering the event appears.</p> * triggering the event appears.</p>
* *
* <p>If the system identifier is a URL, the parser must resolve it * <p>If the system identifier is a URL, the parser must resolve it
* fully before passing it to the application.</p> * fully before passing it to the application. For example, a file
* name must always be provided as a <em>file:...</em> URL, and other
* kinds of relative URI are also resolved against their bases.</p>
* *
* @return A string containing the system identifier, or null * @return A string containing the system identifier, or null
* if none is available. * if none is available.
...@@ -76,11 +80,16 @@ public interface Locator { ...@@ -76,11 +80,16 @@ public interface Locator {
/** /**
* Return the line number where the current document event ends. * Return the line number where the current document event ends.
* Lines are delimited by line ends, which are defined in
* the XML specification.
* *
* <p><strong>Warning:</strong> The return value from the method * <p><strong>Warning:</strong> The return value from the method
* is intended only as an approximation for the sake of error * is intended only as an approximation for the sake of diagnostics;
* reporting; it is not intended to provide sufficient information * it is not intended to provide sufficient information
* to edit the character content of the original XML document.</p> * to edit the character content of the original XML document.
* In some cases, these "line" numbers match what would be displayed
* as columns, and in others they may not match the source text
* due to internal entity expansion. </p>
* *
* <p>The return value is an approximation of the line number * <p>The return value is an approximation of the line number
* in the document entity or external parsed entity where the * in the document entity or external parsed entity where the
...@@ -88,7 +97,7 @@ public interface Locator { ...@@ -88,7 +97,7 @@ public interface Locator {
* *
* <p>If possible, the SAX driver should provide the line position * <p>If possible, the SAX driver should provide the line position
* of the first character after the text associated with the document * of the first character after the text associated with the document
* event. The first line in the document is line 1.</p> * event. The first line is line 1.</p>
* *
* @return The line number, or -1 if none is available. * @return The line number, or -1 if none is available.
* @see #getColumnNumber * @see #getColumnNumber
...@@ -98,11 +107,16 @@ public interface Locator { ...@@ -98,11 +107,16 @@ public interface Locator {
/** /**
* Return the column number where the current document event ends. * Return the column number where the current document event ends.
* This is one-based number of Java <code>char</code> values since
* the last line end.
* *
* <p><strong>Warning:</strong> The return value from the method * <p><strong>Warning:</strong> The return value from the method
* is intended only as an approximation for the sake of error * is intended only as an approximation for the sake of diagnostics;
* reporting; it is not intended to provide sufficient information * it is not intended to provide sufficient information
* to edit the character content of the original XML document.</p> * to edit the character content of the original XML document.
* For example, when lines contain combining character sequences, wide
* characters, surrogate pairs, or bi-directional text, the value may
* not correspond to the column in a text editor's display. </p>
* *
* <p>The return value is an approximation of the column number * <p>The return value is an approximation of the column number
* in the document entity or external parsed entity where the * in the document entity or external parsed entity where the
...@@ -110,10 +124,6 @@ public interface Locator { ...@@ -110,10 +124,6 @@ public interface Locator {
* *
* <p>If possible, the SAX driver should provide the line position * <p>If possible, the SAX driver should provide the line position
* of the first character after the text associated with the document * 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> * event. The first column in each line is column 1.</p>
* *
* @return The column number, or -1 if none is available. * @return The column number, or -1 if none is available.
......
// SAX parser interface. // SAX parser interface.
// http://www.saxproject.org
// No warranty; no copyright -- use this as you will. // No warranty; no copyright -- use this as you will.
// $Id: Parser.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ // $Id: Parser.java,v 1.3.2.3 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax; package org.xml.sax;
...@@ -14,6 +15,8 @@ import java.util.Locale; ...@@ -14,6 +15,8 @@ import java.util.Locale;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>This was the main event supplier interface for SAX1; it has * <p>This was the main event supplier interface for SAX1; it has
...@@ -37,9 +40,8 @@ import java.util.Locale; ...@@ -37,9 +40,8 @@ import java.util.Locale;
* {@link org.xml.sax.XMLReader XMLReader} * {@link org.xml.sax.XMLReader XMLReader}
* interface, which includes Namespace support. * interface, which includes Namespace support.
* @since SAX 1.0 * @since SAX 1.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.EntityResolver * @see org.xml.sax.EntityResolver
* @see org.xml.sax.DTDHandler * @see org.xml.sax.DTDHandler
* @see org.xml.sax.DocumentHandler * @see org.xml.sax.DocumentHandler
......
// SAX exception class. // SAX exception class.
// http://www.saxproject.org
// No warranty; no copyright -- use this as you will. // No warranty; no copyright -- use this as you will.
// $Id: SAXException.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ // $Id: SAXException.java,v 1.4.2.4 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax; package org.xml.sax;
...@@ -10,6 +11,8 @@ package org.xml.sax; ...@@ -10,6 +11,8 @@ package org.xml.sax;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>This class can contain basic error or warning information from * <p>This class can contain basic error or warning information from
...@@ -27,9 +30,8 @@ package org.xml.sax; ...@@ -27,9 +30,8 @@ package org.xml.sax;
* {@link org.xml.sax.SAXParseException SAXParseException} subclass.</p> * {@link org.xml.sax.SAXParseException SAXParseException} subclass.</p>
* *
* @since SAX 1.0 * @since SAX 1.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.SAXParseException * @see org.xml.sax.SAXParseException
*/ */
public class SAXException extends Exception { public class SAXException extends Exception {
...@@ -37,9 +39,18 @@ public class SAXException extends Exception { ...@@ -37,9 +39,18 @@ public class SAXException extends Exception {
/** /**
* Create a new SAXException. * Create a new SAXException.
*/
public SAXException ()
{
super();
this.exception = null;
}
/**
* Create a new SAXException.
* *
* @param message The error or warning message. * @param message The error or warning message.
* @see org.xml.sax.Parser#setLocale
*/ */
public SAXException (String message) { public SAXException (String message) {
super(message); super(message);
...@@ -71,7 +82,6 @@ public class SAXException extends Exception { ...@@ -71,7 +82,6 @@ public class SAXException extends Exception {
* *
* @param message The detail message. * @param message The detail message.
* @param e The exception to be wrapped in a SAXException. * @param e The exception to be wrapped in a SAXException.
* @see org.xml.sax.Parser#setLocale
*/ */
public SAXException (String message, Exception e) public SAXException (String message, Exception e)
{ {
...@@ -88,7 +98,6 @@ public class SAXException extends Exception { ...@@ -88,7 +98,6 @@ public class SAXException extends Exception {
* the detail message from the embedded exception.</p> * the detail message from the embedded exception.</p>
* *
* @return The error or warning message. * @return The error or warning message.
* @see org.xml.sax.Parser#setLocale
*/ */
public String getMessage () public String getMessage ()
{ {
......
// SAXNotRecognizedException.java - unrecognized feature or value. // SAXNotRecognizedException.java - unrecognized feature or value.
// Written by David Megginson, sax@megginson.com // http://www.saxproject.org
// Written by David Megginson
// NO WARRANTY! This class is in the Public Domain. // NO WARRANTY! This class is in the Public Domain.
// $Id: SAXNotRecognizedException.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ // $Id: SAXNotRecognizedException.java,v 1.4.2.3 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax; package org.xml.sax;
...@@ -14,6 +15,8 @@ package org.xml.sax; ...@@ -14,6 +15,8 @@ package org.xml.sax;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>An XMLReader will throw this exception when it finds an * <p>An XMLReader will throw this exception when it finds an
...@@ -21,15 +24,23 @@ package org.xml.sax; ...@@ -21,15 +24,23 @@ package org.xml.sax;
* extensions may use this class for other, similar purposes.</p> * extensions may use this class for other, similar purposes.</p>
* *
* @since SAX 2.0 * @since SAX 2.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.SAXNotSupportedException * @see org.xml.sax.SAXNotSupportedException
*/ */
public class SAXNotRecognizedException extends SAXException public class SAXNotRecognizedException extends SAXException
{ {
/** /**
* Default constructor.
*/
public SAXNotRecognizedException ()
{
super();
}
/**
* Construct a new exception with the given message. * Construct a new exception with the given message.
* *
* @param message The text message of the exception. * @param message The text message of the exception.
......
// SAXNotSupportedException.java - unsupported feature or value. // SAXNotSupportedException.java - unsupported feature or value.
// Written by David Megginson, sax@megginson.com // http://www.saxproject.org
// Written by David Megginson
// NO WARRANTY! This class is in the Public Domain. // NO WARRANTY! This class is in the Public Domain.
// $Id: SAXNotSupportedException.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ // $Id: SAXNotSupportedException.java,v 1.4.2.3 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax; package org.xml.sax;
...@@ -13,6 +14,8 @@ package org.xml.sax; ...@@ -13,6 +14,8 @@ package org.xml.sax;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>An XMLReader will throw this exception when it recognizes a * <p>An XMLReader will throw this exception when it recognizes a
...@@ -21,15 +24,23 @@ package org.xml.sax; ...@@ -21,15 +24,23 @@ package org.xml.sax;
* extensions may use this class for similar purposes.</p> * extensions may use this class for similar purposes.</p>
* *
* @since SAX 2.0 * @since SAX 2.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.SAXNotRecognizedException * @see org.xml.sax.SAXNotRecognizedException
*/ */
public class SAXNotSupportedException extends SAXException public class SAXNotSupportedException extends SAXException
{ {
/** /**
* Construct a new exception with no message.
*/
public SAXNotSupportedException ()
{
super();
}
/**
* Construct a new exception with the given message. * Construct a new exception with the given message.
* *
* @param message The text message of the exception. * @param message The text message of the exception.
......
// SAX exception class. // SAX exception class.
// http://www.saxproject.org
// No warranty; no copyright -- use this as you will. // No warranty; no copyright -- use this as you will.
// $Id: SAXParseException.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ // $Id: SAXParseException.java,v 1.3.2.5 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax; package org.xml.sax;
...@@ -10,10 +11,13 @@ package org.xml.sax; ...@@ -10,10 +11,13 @@ package org.xml.sax;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>This exception will include information for locating the error * <p>This exception may include information for locating the error
* in the original XML document. Note that although the application * in the original XML document, as if it came from a {@link Locator}
* object. Note that although the application
* will receive a SAXParseException as the argument to the handlers * will receive a SAXParseException as the argument to the handlers
* in the {@link org.xml.sax.ErrorHandler ErrorHandler} interface, * in the {@link org.xml.sax.ErrorHandler ErrorHandler} interface,
* the application is not actually required to throw the exception; * the application is not actually required to throw the exception;
...@@ -24,9 +28,8 @@ package org.xml.sax; ...@@ -24,9 +28,8 @@ package org.xml.sax;
* SAXException}, it inherits the ability to wrap another exception.</p> * SAXException}, it inherits the ability to wrap another exception.</p>
* *
* @since SAX 1.0 * @since SAX 1.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.SAXException * @see org.xml.sax.SAXException
* @see org.xml.sax.Locator * @see org.xml.sax.Locator
* @see org.xml.sax.ErrorHandler * @see org.xml.sax.ErrorHandler
...@@ -50,7 +53,6 @@ public class SAXParseException extends SAXException { ...@@ -50,7 +53,6 @@ public class SAXParseException extends SAXException {
* @param locator The locator object for the error or warning (may be * @param locator The locator object for the error or warning (may be
* null). * null).
* @see org.xml.sax.Locator * @see org.xml.sax.Locator
* @see org.xml.sax.Parser#setLocale
*/ */
public SAXParseException (String message, Locator locator) { public SAXParseException (String message, Locator locator) {
super(message); super(message);
...@@ -77,7 +79,6 @@ public class SAXParseException extends SAXException { ...@@ -77,7 +79,6 @@ public class SAXParseException extends SAXException {
* null). * null).
* @param e Any exception. * @param e Any exception.
* @see org.xml.sax.Locator * @see org.xml.sax.Locator
* @see org.xml.sax.Parser#setLocale
*/ */
public SAXParseException (String message, Locator locator, public SAXParseException (String message, Locator locator,
Exception e) { Exception e) {
...@@ -96,19 +97,21 @@ public class SAXParseException extends SAXException { ...@@ -96,19 +97,21 @@ public class SAXParseException extends SAXException {
* *
* <p>This constructor is most useful for parser writers.</p> * <p>This constructor is most useful for parser writers.</p>
* *
* <p>If the system identifier is a URL, the parser must resolve it * <p>All parameters except the message are as if
* fully before creating the exception.</p> * they were provided by a {@link Locator}. For example, if the
* system identifier is a URL (including relative filename), the
* caller must resolve it fully before creating the exception.</p>
*
* *
* @param message The error or warning message. * @param message The error or warning message.
* @param publicId The public identifier of the entity that generated * @param publicId The public identifer of the entity that generated
* the error or warning. * the error or warning.
* @param systemId The system identifier of the entity that generated * @param systemId The system identifer of the entity that generated
* the error or warning. * the error or warning.
* @param lineNumber The line number of the end of the text that * @param lineNumber The line number of the end of the text that
* caused the error or warning. * caused the error or warning.
* @param columnNumber The column number of the end of the text that * @param columnNumber The column number of the end of the text that
* cause the error or warning. * cause the error or warning.
* @see org.xml.sax.Parser#setLocale
*/ */
public SAXParseException (String message, String publicId, String systemId, public SAXParseException (String message, String publicId, String systemId,
int lineNumber, int columnNumber) int lineNumber, int columnNumber)
...@@ -125,21 +128,22 @@ public class SAXParseException extends SAXException { ...@@ -125,21 +128,22 @@ public class SAXParseException extends SAXException {
* need to wrap an exception that is not a subclass of * need to wrap an exception that is not a subclass of
* {@link org.xml.sax.SAXException SAXException}.</p> * {@link org.xml.sax.SAXException SAXException}.</p>
* *
* <p>If the system identifier is a URL, the parser must resolve it * <p>All parameters except the message and exception are as if
* fully before creating the exception.</p> * they were provided by a {@link Locator}. For example, if the
* system identifier is a URL (including relative filename), the
* caller must resolve it fully before creating the exception.</p>
* *
* @param message The error or warning message, or null to use * @param message The error or warning message, or null to use
* the message from the embedded exception. * the message from the embedded exception.
* @param publicId The public identifier of the entity that generated * @param publicId The public identifer of the entity that generated
* the error or warning. * the error or warning.
* @param systemId The system identifier of the entity that generated * @param systemId The system identifer of the entity that generated
* the error or warning. * the error or warning.
* @param lineNumber The line number of the end of the text that * @param lineNumber The line number of the end of the text that
* caused the error or warning. * caused the error or warning.
* @param columnNumber The column number of the end of the text that * @param columnNumber The column number of the end of the text that
* cause the error or warning. * cause the error or warning.
* @param e Another exception to embed in this one. * @param e Another exception to embed in this one.
* @see org.xml.sax.Parser#setLocale
*/ */
public SAXParseException (String message, String publicId, String systemId, public SAXParseException (String message, String publicId, String systemId,
int lineNumber, int columnNumber, Exception e) int lineNumber, int columnNumber, Exception e)
...@@ -185,7 +189,7 @@ public class SAXParseException extends SAXException { ...@@ -185,7 +189,7 @@ public class SAXParseException extends SAXException {
/** /**
* Get the system identifier of the entity where the exception occurred. * Get the system identifier of the entity where the exception occurred.
* *
* <p>If the system identifier is a URL, it will be resolved * <p>If the system identifier is a URL, it will have been resolved
* fully.</p> * fully.</p>
* *
* @return A string containing the system identifier, or null * @return A string containing the system identifier, or null
...@@ -201,6 +205,8 @@ public class SAXParseException extends SAXException { ...@@ -201,6 +205,8 @@ public class SAXParseException extends SAXException {
/** /**
* The line number of the end of the text where the exception occurred. * The line number of the end of the text where the exception occurred.
* *
* <p>The first line is line 1.</p>
*
* @return An integer representing the line number, or -1 * @return An integer representing the line number, or -1
* if none is available. * if none is available.
* @see org.xml.sax.Locator#getLineNumber * @see org.xml.sax.Locator#getLineNumber
......
// XMLFilter.java - filter SAX2 events. // XMLFilter.java - filter SAX2 events.
// Written by David Megginson, sax@megginson.com // http://www.saxproject.org
// Written by David Megginson
// NO WARRANTY! This class is in the Public Domain. // NO WARRANTY! This class is in the Public Domain.
// $Id: XMLFilter.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ // $Id: XMLFilter.java,v 1.3.2.3 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax; package org.xml.sax;
...@@ -14,6 +15,8 @@ package org.xml.sax; ...@@ -14,6 +15,8 @@ package org.xml.sax;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>An XML filter is like an XML reader, except that it obtains its * <p>An XML filter is like an XML reader, except that it obtains its
...@@ -28,9 +31,8 @@ package org.xml.sax; ...@@ -28,9 +31,8 @@ package org.xml.sax;
* ErrorHandler} events automatically.</p> * ErrorHandler} events automatically.</p>
* *
* @since SAX 2.0 * @since SAX 2.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.helpers.XMLFilterImpl * @see org.xml.sax.helpers.XMLFilterImpl
*/ */
public interface XMLFilter extends XMLReader public interface XMLFilter extends XMLReader
......
// DeclHandler.java - Optional handler for DTD declaration events. // DeclHandler.java - Optional handler for DTD declaration events.
// http://www.saxproject.org
// Public Domain: no warranty. // Public Domain: no warranty.
// $Id: DeclHandler.java,v 1.1 2000/10/02 02:43:19 sboag Exp $ // $Id: DeclHandler.java,v 1.2.2.5 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax.ext; package org.xml.sax.ext;
...@@ -13,11 +14,14 @@ import org.xml.sax.SAXException; ...@@ -13,11 +14,14 @@ import org.xml.sax.SAXException;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>This is an optional extension handler for SAX2 to provide * <p>This is an optional extension handler for SAX2 to provide more
* information about DTD declarations in an XML document. XML * complete information about DTD declarations in an XML document.
* readers are not required to support this handler.</p> * XML readers are not required to recognize this handler, and it
* is not part of core-only SAX2 distributions.</p>
* *
* <p>Note that data-related DTD declarations (unparsed entities and * <p>Note that data-related DTD declarations (unparsed entities and
* notations) are already reported through the {@link * notations) are already reported through the {@link
...@@ -30,18 +34,16 @@ import org.xml.sax.SAXException; ...@@ -30,18 +34,16 @@ import org.xml.sax.SAXException;
* *
* <p>To set the DeclHandler for an XML reader, use the * <p>To set the DeclHandler for an XML reader, use the
* {@link org.xml.sax.XMLReader#setProperty setProperty} method * {@link org.xml.sax.XMLReader#setProperty setProperty} method
* with the propertyId "http://xml.org/sax/handlers/DeclHandler". * with the property name
* If the reader does not support declaration events, it will throw a * <code>http://xml.org/sax/properties/declaration-handler</code>
* and an object implementing this interface (or null) as the value.
* If the reader does not report declaration events, it will throw a
* {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException} * {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException}
* or a
* {@link org.xml.sax.SAXNotSupportedException SAXNotSupportedException}
* when you attempt to register the handler.</p> * when you attempt to register the handler.</p>
* *
* @since SAX 2.0 * @since SAX 2.0 (extensions 1.0)
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0beta
* @see org.xml.sax.XMLReader
*/ */
public interface DeclHandler public interface DeclHandler
{ {
...@@ -52,8 +54,11 @@ public interface DeclHandler ...@@ -52,8 +54,11 @@ public interface DeclHandler
* <p>The content model will consist of the string "EMPTY", the * <p>The content model will consist of the string "EMPTY", the
* string "ANY", or a parenthesised group, optionally followed * string "ANY", or a parenthesised group, optionally followed
* by an occurrence indicator. The model will be normalized so * by an occurrence indicator. The model will be normalized so
* that all whitespace is removed,and will include the enclosing * that all parameter entities are fully resolved and all whitespace
* parentheses.</p> * is removed,and will include the enclosing parentheses. Other
* normalization (such as removing redundant parentheses or
* simplifying occurrence indicators) is at the discretion of the
* parser.</p>
* *
* @param name The element type name. * @param name The element type name.
* @param model The content model as a normalized string. * @param model The content model as a normalized string.
...@@ -69,13 +74,19 @@ public interface DeclHandler ...@@ -69,13 +74,19 @@ public interface DeclHandler
* <p>Only the effective (first) declaration for an attribute will * <p>Only the effective (first) declaration for an attribute will
* be reported. The type will be one of the strings "CDATA", * be reported. The type will be one of the strings "CDATA",
* "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", * "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY",
* "ENTITIES", or "NOTATION", or a parenthesized token group with * "ENTITIES", a parenthesized token group with
* the separator "|" and all whitespace removed.</p> * the separator "|" and all whitespace removed, or the word
* "NOTATION" followed by a space followed by a parenthesized
* token group with all whitespace removed.</p>
*
* <p>The value will be the value as reported to applications,
* appropriately normalized and with entity and character
* references expanded. </p>
* *
* @param eName The name of the associated element. * @param eName The name of the associated element.
* @param aName The name of the attribute. * @param aName The name of the attribute.
* @param type A string representing the attribute type. * @param type A string representing the attribute type.
* @param valueDefault A string representing the attribute default * @param mode A string representing the attribute defaulting mode
* ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if * ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if
* none of these applies. * none of these applies.
* @param value A string representing the attribute's default value, * @param value A string representing the attribute's default value,
...@@ -85,7 +96,7 @@ public interface DeclHandler ...@@ -85,7 +96,7 @@ public interface DeclHandler
public abstract void attributeDecl (String eName, public abstract void attributeDecl (String eName,
String aName, String aName,
String type, String type,
String valueDefault, String mode,
String value) String value)
throws SAXException; throws SAXException;
...@@ -94,7 +105,8 @@ public interface DeclHandler ...@@ -94,7 +105,8 @@ public interface DeclHandler
* Report an internal entity declaration. * Report an internal entity declaration.
* *
* <p>Only the effective (first) declaration for each entity * <p>Only the effective (first) declaration for each entity
* will be reported.</p> * will be reported. All parameter entities in the value
* will be expanded, but general entities will not.</p>
* *
* @param name The name of the entity. If it is a parameter * @param name The name of the entity. If it is a parameter
* entity, the name will begin with '%'. * entity, the name will begin with '%'.
......
// LexicalHandler.java - optional handler for lexical parse events. // LexicalHandler.java - optional handler for lexical parse events.
// http://www.saxproject.org
// Public Domain: no warranty. // Public Domain: no warranty.
// $Id: LexicalHandler.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ // $Id: LexicalHandler.java,v 1.2.2.4 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax.ext; package org.xml.sax.ext;
...@@ -12,12 +13,15 @@ import org.xml.sax.SAXException; ...@@ -12,12 +13,15 @@ import org.xml.sax.SAXException;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>This is an optional extension handler for SAX2 to provide * <p>This is an optional extension handler for SAX2 to provide
* lexical information about an XML document, such as comments * lexical information about an XML document, such as comments
* and CDATA section boundaries; XML readers are not required to * and CDATA section boundaries.
* support this handler.</p> * XML readers are not required to recognize this handler, and it
* is not part of core-only SAX2 distributions.</p>
* *
* <p>The events in the lexical handler apply to the entire document, * <p>The events in the lexical handler apply to the entire document,
* not just to the document element, and all lexical handler events * not just to the document element, and all lexical handler events
...@@ -26,20 +30,16 @@ import org.xml.sax.SAXException; ...@@ -26,20 +30,16 @@ import org.xml.sax.SAXException;
* *
* <p>To set the LexicalHandler for an XML reader, use the * <p>To set the LexicalHandler for an XML reader, use the
* {@link org.xml.sax.XMLReader#setProperty setProperty} method * {@link org.xml.sax.XMLReader#setProperty setProperty} method
* with the propertyId "http://xml.org/sax/handlers/LexicalHandler". * with the property name
* If the reader does not support lexical events, it will throw a * <code>http://xml.org/sax/properties/lexical-handler</code>
* and an object implementing this interface (or null) as the value.
* If the reader does not report lexical events, it will throw a
* {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException} * {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException}
* or a
* {@link org.xml.sax.SAXNotSupportedException SAXNotSupportedException}
* when you attempt to register the handler.</p> * when you attempt to register the handler.</p>
* *
* @since SAX 2.0 * @since SAX 2.0 (extensions 1.0)
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0beta
* @see org.xml.sax.XMLReader#setProperty
* @see org.xml.sax.SAXNotRecognizedException
* @see org.xml.sax.SAXNotSupportedException
*/ */
public interface LexicalHandler public interface LexicalHandler
{ {
...@@ -47,19 +47,36 @@ public interface LexicalHandler ...@@ -47,19 +47,36 @@ public interface LexicalHandler
/** /**
* Report the start of DTD declarations, if any. * Report the start of DTD declarations, if any.
* *
* <p>Any declarations are assumed to be in the internal subset * <p>This method is intended to report the beginning of the
* unless otherwise indicated by a {@link #startEntity startEntity} * DOCTYPE declaration; if the document has no DOCTYPE declaration,
* event.</p> * this method will not be invoked.</p>
*
* <p>All declarations reported through
* {@link org.xml.sax.DTDHandler DTDHandler} or
* {@link org.xml.sax.ext.DeclHandler DeclHandler} events must appear
* between the startDTD and {@link #endDTD endDTD} events.
* Declarations are assumed to belong to the internal DTD subset
* unless they appear between {@link #startEntity startEntity}
* and {@link #endEntity endEntity} events. Comments and
* processing instructions from the DTD should also be reported
* between the startDTD and endDTD events, in their original
* order of (logical) occurrence; they are not required to
* appear in their correct locations relative to DTDHandler
* or DeclHandler events, however.</p>
* *
* <p>Note that the start/endDTD events will appear within * <p>Note that the start/endDTD events will appear within
* the start/endDocument events from ContentHandler and * the start/endDocument events from ContentHandler and
* before the first startElement event.</p> * before the first
* {@link org.xml.sax.ContentHandler#startElement startElement}
* event.</p>
* *
* @param name The document type name. * @param name The document type name.
* @param publicId The declared public identifier for the * @param publicId The declared public identifier for the
* external DTD subset, or null if none was declared. * external DTD subset, or null if none was declared.
* @param systemId The declared system identifier for the * @param systemId The declared system identifier for the
* external DTD subset, or null if none was declared. * external DTD subset, or null if none was declared.
* (Note that this is not resolved against the document
* base URI.)
* @exception SAXException The application may raise an * @exception SAXException The application may raise an
* exception. * exception.
* @see #endDTD * @see #endDTD
...@@ -73,6 +90,10 @@ public interface LexicalHandler ...@@ -73,6 +90,10 @@ public interface LexicalHandler
/** /**
* Report the end of DTD declarations. * Report the end of DTD declarations.
* *
* <p>This method is intended to report the end of the
* DOCTYPE declaration; if the document has no DOCTYPE declaration,
* this method will not be invoked.</p>
*
* @exception SAXException The application may raise an exception. * @exception SAXException The application may raise an exception.
* @see #startDTD * @see #startDTD
*/ */
...@@ -81,22 +102,49 @@ public interface LexicalHandler ...@@ -81,22 +102,49 @@ public interface LexicalHandler
/** /**
* Report the beginning of an entity in content. * Report the beginning of some internal and external XML entities.
* *
* <p><strong>NOTE:</entity> entity references in attribute * <p>The reporting of parameter entities (including
* values -- and the start and end of the document entity -- * the external DTD subset) is optional, and SAX2 drivers that
* are never reported.</p> * report LexicalHandler events may not implement it; you can use the
* <code
* >http://xml.org/sax/features/lexical-handler/parameter-entities</code>
* feature to query or control the reporting of parameter entities.</p>
* *
* <p>The start and end of the external DTD subset are reported * <p>General entities are reported with their regular names,
* using the pseudo-name "[dtd]". All other events must be * parameter entities have '%' prepended to their names, and
* properly nested within start/end entity events.</p> * the external DTD subset has the pseudo-entity name "[dtd]".</p>
*
* <p>When a SAX2 driver is providing these events, all other
* events must be properly nested within start/end entity
* events. There is no additional requirement that events from
* {@link org.xml.sax.ext.DeclHandler DeclHandler} or
* {@link org.xml.sax.DTDHandler DTDHandler} be properly ordered.</p>
* *
* <p>Note that skipped entities will be reported through the * <p>Note that skipped entities will be reported through the
* {@link org.xml.sax.ContentHandler#skippedEntity skippedEntity} * {@link org.xml.sax.ContentHandler#skippedEntity skippedEntity}
* event, which is part of the ContentHandler interface.</p> * event, which is part of the ContentHandler interface.</p>
* *
* <p>Because of the streaming event model that SAX uses, some
* entity boundaries cannot be reported under any
* circumstances:</p>
*
* <ul>
* <li>general entities within attribute values</li>
* <li>parameter entities within declarations</li>
* </ul>
*
* <p>These will be silently expanded, with no indication of where
* the original entity boundaries were.</p>
*
* <p>Note also that the boundaries of character references (which
* are not really entities anyway) are not reported.</p>
*
* <p>All start/endEntity events must be properly nested.
*
* @param name The name of the entity. If it is a parameter * @param name The name of the entity. If it is a parameter
* entity, the name will begin with '%'. * entity, the name will begin with '%', and if it is the
* external DTD subset, it will be "[dtd]".
* @exception SAXException The application may raise an exception. * @exception SAXException The application may raise an exception.
* @see #endEntity * @see #endEntity
* @see org.xml.sax.ext.DeclHandler#internalEntityDecl * @see org.xml.sax.ext.DeclHandler#internalEntityDecl
...@@ -122,7 +170,8 @@ public interface LexicalHandler ...@@ -122,7 +170,8 @@ public interface LexicalHandler
* *
* <p>The contents of the CDATA section will be reported through * <p>The contents of the CDATA section will be reported through
* the regular {@link org.xml.sax.ContentHandler#characters * the regular {@link org.xml.sax.ContentHandler#characters
* characters} event.</p> * characters} event; this event is intended only to report
* the boundary.</p>
* *
* @exception SAXException The application may raise an exception. * @exception SAXException The application may raise an exception.
* @see #endCDATA * @see #endCDATA
...@@ -146,7 +195,9 @@ public interface LexicalHandler ...@@ -146,7 +195,9 @@ public interface LexicalHandler
* *
* <p>This callback will be used for comments inside or outside the * <p>This callback will be used for comments inside or outside the
* document element, including comments in the external DTD * document element, including comments in the external DTD
* subset (if read).</p> * subset (if read). Comments in the DTD must be properly
* nested inside start/endDTD and start/endEntity events (if
* used).</p>
* *
* @param ch An array holding the characters in the comment. * @param ch An array holding the characters in the comment.
* @param start The starting position in the array. * @param start The starting position in the array.
......
<HTML><HEAD>
</HEAD><BODY>
<p>
This package contains interfaces to optional SAX2 handlers.
<p>See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
for more information about SAX.</p>
<p>
The package is independent of the SAX2 core, though the functionality
exposed generally needs to be implemented within a parser.
That independence has several consequences:</p>
<ul>
<li>SAX2 drivers are <em>not</em> required to recognize these handlers,
and you cannot assume that the class files will be present in every SAX2
installation.</li>
<li>This package may be updated independently of SAX2 (i.e. new
handlers may be added without updating SAX2 itself).</li>
<li>The handlers are not implemented by the SAX2
<code>org.xml.sax.helpers.DefaultHandler</code> or
<code>org.xml.sax.helpers.XMLFilterImpl</code> classes.
You can subclass these if you need such behaviour.</li>
<li>The handlers need to be registered differently than regular SAX2
handlers.</li>
</ul>
<p>This package, SAX2-ext, is a standardized extension to SAX2. It is
designed both to allow SAX parsers to pass certain types of information
to applications, and to serve as a simple model for other SAX2 parser
extension packages. Not all such extension packages should need to
be recognized directly by parsers, however.
As an example, most schema systems can be cleanly layered on top
of parsers supporting the standardized SAX2 interfaces. </p>
<p><strong>NOTE:</strong> this package alone does add any
functionality; it simply provides optional interfaces for SAX2 drivers
to use. You must use a SAX2 driver that recognizes these interfaces if
you actually want to have access to lexical and declaration
information.</p>
</BODY></HTML>
// SAX default implementation for AttributeList. // SAX default implementation for AttributeList.
// http://www.saxproject.org
// No warranty; no copyright -- use this as you will. // No warranty; no copyright -- use this as you will.
// $Id: AttributeListImpl.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ // $Id: AttributeListImpl.java,v 1.3.2.3 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax.helpers; package org.xml.sax.helpers;
...@@ -15,6 +16,8 @@ import java.util.Vector; ...@@ -15,6 +16,8 @@ import java.util.Vector;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>AttributeList implements the deprecated SAX1 {@link * <p>AttributeList implements the deprecated SAX1 {@link
...@@ -55,9 +58,8 @@ import java.util.Vector; ...@@ -55,9 +58,8 @@ import java.util.Vector;
* {@link org.xml.sax.helpers.AttributesImpl * {@link org.xml.sax.helpers.AttributesImpl
* AttributesImpl} helper class. * AttributesImpl} helper class.
* @since SAX 1.0 * @since SAX 1.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.AttributeList * @see org.xml.sax.AttributeList
* @see org.xml.sax.DocumentHandler#startElement * @see org.xml.sax.DocumentHandler#startElement
*/ */
......
// AttributesImpl.java - default implementation of Attributes. // AttributesImpl.java - default implementation of Attributes.
// Written by David Megginson, sax@megginson.com // http://www.saxproject.org
// Written by David Megginson
// NO WARRANTY! This class is in the public domain. // NO WARRANTY! This class is in the public domain.
// $Id: AttributesImpl.java,v 1.2 2001/05/31 16:03:17 garyp Exp $ // $Id: AttributesImpl.java,v 1.6.2.3 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax.helpers; package org.xml.sax.helpers;
...@@ -16,6 +17,8 @@ import org.xml.sax.Attributes; ...@@ -16,6 +17,8 @@ import org.xml.sax.Attributes;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>This class provides a default implementation of the SAX2 * <p>This class provides a default implementation of the SAX2
...@@ -39,9 +42,8 @@ import org.xml.sax.Attributes; ...@@ -39,9 +42,8 @@ import org.xml.sax.Attributes;
* implementation using a single array rather than a set of Vectors.</p> * implementation using a single array rather than a set of Vectors.</p>
* *
* @since SAX 2.0 * @since SAX 2.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
*/ */
public class AttributesImpl implements Attributes public class AttributesImpl implements Attributes
{ {
...@@ -320,12 +322,16 @@ public class AttributesImpl implements Attributes ...@@ -320,12 +322,16 @@ public class AttributesImpl implements Attributes
/** /**
* Clear the attribute list for reuse. * Clear the attribute list for reuse.
* *
* <p>Note that no memory is actually freed by this call: * <p>Note that little memory is freed by this call:
* the current arrays are kept so that they can be * the current array is kept so it can be
* reused.</p> * reused.</p>
*/ */
public void clear () public void clear ()
{ {
if (data != null) {
for (int i = 0; i < (length * 5); i++)
data [i] = null;
}
length = 0; length = 0;
} }
...@@ -342,6 +348,7 @@ public class AttributesImpl implements Attributes ...@@ -342,6 +348,7 @@ public class AttributesImpl implements Attributes
{ {
clear(); clear();
length = atts.getLength(); length = atts.getLength();
if (length > 0) {
data = new String[length*5]; data = new String[length*5];
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
data[i*5] = atts.getURI(i); data[i*5] = atts.getURI(i);
...@@ -351,6 +358,7 @@ public class AttributesImpl implements Attributes ...@@ -351,6 +358,7 @@ public class AttributesImpl implements Attributes
data[i*5+4] = atts.getValue(i); data[i*5+4] = atts.getValue(i);
} }
} }
}
/** /**
...@@ -430,15 +438,16 @@ public class AttributesImpl implements Attributes ...@@ -430,15 +438,16 @@ public class AttributesImpl implements Attributes
public void removeAttribute (int index) public void removeAttribute (int index)
{ {
if (index >= 0 && index < length) { if (index >= 0 && index < length) {
data[index*5] = null;
data[index*5+1] = null;
data[index*5+2] = null;
data[index*5+3] = null;
data[index*5+4] = null;
if (index < length - 1) { if (index < length - 1) {
System.arraycopy(data, (index+1)*5, data, index*5, System.arraycopy(data, (index+1)*5, data, index*5,
(length-index-1)*5); (length-index-1)*5);
} }
index = (length - 1) * 5;
data [index++] = null;
data [index++] = null;
data [index++] = null;
data [index++] = null;
data [index] = null;
length--; length--;
} else { } else {
badIndex(index); badIndex(index);
...@@ -556,23 +565,28 @@ public class AttributesImpl implements Attributes ...@@ -556,23 +565,28 @@ public class AttributesImpl implements Attributes
* @param n The minimum number of attributes that the array must * @param n The minimum number of attributes that the array must
* be able to hold. * be able to hold.
*/ */
private void ensureCapacity (int n) private void ensureCapacity (int n) {
{ if (n <= 0) {
if (n > 0 && data == null) { return;
data = new String[25];
} }
int max;
int max = data.length; if (data == null || data.length == 0) {
if (max >= n * 5) { max = 25;
}
else if (data.length >= n * 5) {
return; return;
} }
else {
max = data.length;
}
while (max < n * 5) { while (max < n * 5) {
max *= 2; max *= 2;
} }
String newData[] = new String[max]; String newData[] = new String[max];
if (length > 0) {
System.arraycopy(data, 0, newData, 0, length*5); System.arraycopy(data, 0, newData, 0, length*5);
}
data = newData; data = newData;
} }
......
// DefaultHandler.java - default implementation of the core handlers. // DefaultHandler.java - default implementation of the core handlers.
// Written by David Megginson, sax@megginson.com // http://www.saxproject.org
// Written by David Megginson
// NO WARRANTY! This class is in the public domain. // NO WARRANTY! This class is in the public domain.
// $Id: DefaultHandler.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ // $Id: DefaultHandler.java,v 1.5.2.3 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax.helpers; package org.xml.sax.helpers;
import java.io.IOException;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.Locator; import org.xml.sax.Locator;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
...@@ -23,6 +26,8 @@ import org.xml.sax.SAXParseException; ...@@ -23,6 +26,8 @@ import org.xml.sax.SAXParseException;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>This class is available as a convenience base class for SAX2 * <p>This class is available as a convenience base class for SAX2
...@@ -46,8 +51,7 @@ import org.xml.sax.SAXParseException; ...@@ -46,8 +51,7 @@ import org.xml.sax.SAXParseException;
* *
* @since SAX 2.0 * @since SAX 2.0
* @author David Megginson, * @author David Megginson,
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.EntityResolver * @see org.xml.sax.EntityResolver
* @see org.xml.sax.DTDHandler * @see org.xml.sax.DTDHandler
* @see org.xml.sax.ContentHandler * @see org.xml.sax.ContentHandler
...@@ -71,18 +75,20 @@ public class DefaultHandler ...@@ -71,18 +75,20 @@ public class DefaultHandler
* in a subclass to do special translations such as catalog lookups * in a subclass to do special translations such as catalog lookups
* or URI redirection.</p> * or URI redirection.</p>
* *
* @param publicId The public identifier, or null if none is * @param publicId The public identifer, or null if none is
* available. * available.
* @param systemId The system identifier provided in the XML * @param systemId The system identifier provided in the XML
* document. * document.
* @return The new input source, or null to require the * @return The new input source, or null to require the
* default behaviour. * default behaviour.
* @exception java.io.IOException If there is an error setting
* up the new input source.
* @exception org.xml.sax.SAXException Any SAX exception, possibly * @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception. * wrapping another exception.
* @see org.xml.sax.EntityResolver#resolveEntity * @see org.xml.sax.EntityResolver#resolveEntity
*/ */
public InputSource resolveEntity (String publicId, String systemId) public InputSource resolveEntity (String publicId, String systemId)
throws SAXException throws IOException, SAXException
{ {
return null; return null;
} }
...@@ -248,8 +254,17 @@ public class DefaultHandler ...@@ -248,8 +254,17 @@ public class DefaultHandler
* each element (such as allocating a new tree node or writing * each element (such as allocating a new tree node or writing
* output to a file).</p> * output to a file).</p>
* *
* @param name The element type name. * @param uri The Namespace URI, or the empty string if the
* @param attributes The specified or defaulted attributes. * element has no Namespace URI or if Namespace
* processing is not being performed.
* @param localName The local name (without prefix), or the
* empty string if Namespace processing is not being
* performed.
* @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.
* @exception org.xml.sax.SAXException Any SAX exception, possibly * @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception. * wrapping another exception.
* @see org.xml.sax.ContentHandler#startElement * @see org.xml.sax.ContentHandler#startElement
...@@ -270,8 +285,14 @@ public class DefaultHandler ...@@ -270,8 +285,14 @@ public class DefaultHandler
* each element (such as finalising a tree node or writing * each element (such as finalising a tree node or writing
* output to a file).</p> * output to a file).</p>
* *
* @param name The element type name. * @param uri The Namespace URI, or the empty string if the
* @param attributes The specified or defaulted attributes. * element has no Namespace URI or if Namespace
* processing is not being performed.
* @param localName The local name (without prefix), or the
* empty string if Namespace processing is not being
* performed.
* @param qName The qualified name (with prefix), or the
* empty string if qualified names are not available.
* @exception org.xml.sax.SAXException Any SAX exception, possibly * @exception org.xml.sax.SAXException Any SAX exception, possibly
* wrapping another exception. * wrapping another exception.
* @see org.xml.sax.ContentHandler#endElement * @see org.xml.sax.ContentHandler#endElement
......
// SAX default implementation for Locator. // SAX default implementation for Locator.
// http://www.saxproject.org
// No warranty; no copyright -- use this as you will. // No warranty; no copyright -- use this as you will.
// $Id: LocatorImpl.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ // $Id: LocatorImpl.java,v 1.3.2.3 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax.helpers; package org.xml.sax.helpers;
...@@ -13,6 +14,8 @@ import org.xml.sax.Locator; ...@@ -13,6 +14,8 @@ import org.xml.sax.Locator;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>This class is available mainly for application writers, who * <p>This class is available mainly for application writers, who
...@@ -42,9 +45,8 @@ import org.xml.sax.Locator; ...@@ -42,9 +45,8 @@ import org.xml.sax.Locator;
* requested, rather than constantly updating a Locator object.</p> * requested, rather than constantly updating a Locator object.</p>
* *
* @since SAX 1.0 * @since SAX 1.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.Locator Locator * @see org.xml.sax.Locator Locator
*/ */
public class LocatorImpl implements Locator public class LocatorImpl implements Locator
......
// NewInstance.java - create a new instance of a class by name.
// http://www.saxproject.org
// Written by Edwin Goei, edwingo@apache.org
// and by David Brownell, dbrownell@users.sourceforge.net
// NO WARRANTY! This class is in the Public Domain.
// $Id: NewInstance.java,v 1.1.2.4 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax.helpers;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
/**
* Create a new instance of a class by name.
*
* <blockquote>
* <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote>
*
* <p>This class contains a static method for creating an instance of a
* class from an explicit class name. It tries to use the thread's context
* ClassLoader if possible and falls back to using
* Class.forName(String).</p>
*
* <p>This code is designed to compile and run on JDK version 1.1 and later
* including versions of Java 2.</p>
*
* @author Edwin Goei, David Brownell
* @version 2.0.1 (sax2r2)
*/
class NewInstance {
/**
* Creates a new instance of the specified class name
*
* Package private so this code is not exposed at the API level.
*/
static Object newInstance (ClassLoader classLoader, String className)
throws ClassNotFoundException, IllegalAccessException,
InstantiationException
{
Class driverClass;
if (classLoader == null) {
driverClass = Class.forName(className);
} else {
driverClass = classLoader.loadClass(className);
}
return driverClass.newInstance();
}
/**
* Figure out which ClassLoader to use. For JDK 1.2 and later use
* the context ClassLoader.
*/
static ClassLoader getClassLoader ()
{
Method m = null;
try {
m = Thread.class.getMethod("getContextClassLoader", null);
} catch (NoSuchMethodException e) {
// Assume that we are running JDK 1.1, use the current ClassLoader
return NewInstance.class.getClassLoader();
}
try {
return (ClassLoader) m.invoke(Thread.currentThread(), null);
} catch (IllegalAccessException e) {
// assert(false)
throw new UnknownError(e.getMessage());
} catch (InvocationTargetException e) {
// assert(e.getTargetException() instanceof SecurityException)
throw new UnknownError(e.getMessage());
}
}
}
// SAX parser factory. // SAX parser factory.
// http://www.saxproject.org
// No warranty; no copyright -- use this as you will. // No warranty; no copyright -- use this as you will.
// $Id: ParserFactory.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ // $Id: ParserFactory.java,v 1.4.2.3 2002/01/29 21:34:14 dbrownell Exp $
package org.xml.sax.helpers; package org.xml.sax.helpers;
...@@ -19,6 +20,8 @@ import org.xml.sax.Parser; ...@@ -19,6 +20,8 @@ import org.xml.sax.Parser;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p><strong>Note:</strong> This class is designed to work with the now-deprecated * <p><strong>Note:</strong> This class is designed to work with the now-deprecated
...@@ -40,11 +43,8 @@ import org.xml.sax.Parser; ...@@ -40,11 +43,8 @@ import org.xml.sax.Parser;
* {@link org.xml.sax.Parser Parser} * {@link org.xml.sax.Parser Parser}
* interface. * interface.
* @since SAX 1.0 * @since SAX 1.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.Parser
* @see java.lang.Class
*/ */
public class ParserFactory { public class ParserFactory {
...@@ -121,9 +121,9 @@ public class ParserFactory { ...@@ -121,9 +121,9 @@ public class ParserFactory {
InstantiationException, InstantiationException,
ClassCastException ClassCastException
{ {
return (Parser)(Class.forName(className).newInstance()); return (Parser) NewInstance.newInstance (
NewInstance.getClassLoader (), className);
} }
} }
// end of ParserFactory.java
// XMLReaderAdapter.java - adapt an SAX2 XMLReader to a SAX1 Parser // XMLReaderAdapter.java - adapt an SAX2 XMLReader to a SAX1 Parser
// Written by David Megginson, sax@megginson.com // http://www.saxproject.org
// Written by David Megginson
// NO WARRANTY! This class is in the public domain. // NO WARRANTY! This class is in the public domain.
// $Id: XMLReaderAdapter.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ // $Id: XMLReaderAdapter.java,v 1.5.2.3 2002/01/29 21:34:15 dbrownell Exp $
package org.xml.sax.helpers; package org.xml.sax.helpers;
...@@ -31,6 +32,8 @@ import org.xml.sax.SAXNotSupportedException; ...@@ -31,6 +32,8 @@ import org.xml.sax.SAXNotSupportedException;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>This class wraps a SAX2 {@link org.xml.sax.XMLReader XMLReader} * <p>This class wraps a SAX2 {@link org.xml.sax.XMLReader XMLReader}
...@@ -42,9 +45,8 @@ import org.xml.sax.SAXNotSupportedException; ...@@ -42,9 +45,8 @@ import org.xml.sax.SAXNotSupportedException;
* property, that will also be used to improve efficiency.</p> * property, that will also be used to improve efficiency.</p>
* *
* @since SAX 2.0 * @since SAX 2.0
* @author David Megginson, * @author David Megginson
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.Parser * @see org.xml.sax.Parser
* @see org.xml.sax.XMLReader * @see org.xml.sax.XMLReader
*/ */
...@@ -120,6 +122,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler ...@@ -120,6 +122,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler
* *
* @param The locale for error reporting. * @param The locale for error reporting.
* @see org.xml.sax.Parser#setLocale * @see org.xml.sax.Parser#setLocale
* @exception org.xml.sax.SAXException Thrown unless overridden.
*/ */
public void setLocale (Locale locale) public void setLocale (Locale locale)
throws SAXException throws SAXException
...@@ -255,6 +258,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler ...@@ -255,6 +258,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler
*/ */
public void setDocumentLocator (Locator locator) public void setDocumentLocator (Locator locator)
{ {
if (documentHandler != null)
documentHandler.setDocumentLocator(locator); documentHandler.setDocumentLocator(locator);
} }
...@@ -269,6 +273,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler ...@@ -269,6 +273,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler
public void startDocument () public void startDocument ()
throws SAXException throws SAXException
{ {
if (documentHandler != null)
documentHandler.startDocument(); documentHandler.startDocument();
} }
...@@ -283,6 +288,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler ...@@ -283,6 +288,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler
public void endDocument () public void endDocument ()
throws SAXException throws SAXException
{ {
if (documentHandler != null)
documentHandler.endDocument(); documentHandler.endDocument();
} }
...@@ -325,9 +331,11 @@ public class XMLReaderAdapter implements Parser, ContentHandler ...@@ -325,9 +331,11 @@ public class XMLReaderAdapter implements Parser, ContentHandler
String qName, Attributes atts) String qName, Attributes atts)
throws SAXException throws SAXException
{ {
if (documentHandler != null) {
qAtts.setAttributes(atts); qAtts.setAttributes(atts);
documentHandler.startElement(qName, qAtts); documentHandler.startElement(qName, qAtts);
} }
}
/** /**
...@@ -344,6 +352,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler ...@@ -344,6 +352,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler
String qName) String qName)
throws SAXException throws SAXException
{ {
if (documentHandler != null)
documentHandler.endElement(qName); documentHandler.endElement(qName);
} }
...@@ -361,6 +370,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler ...@@ -361,6 +370,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler
public void characters (char ch[], int start, int length) public void characters (char ch[], int start, int length)
throws SAXException throws SAXException
{ {
if (documentHandler != null)
documentHandler.characters(ch, start, length); documentHandler.characters(ch, start, length);
} }
...@@ -378,6 +388,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler ...@@ -378,6 +388,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler
public void ignorableWhitespace (char ch[], int start, int length) public void ignorableWhitespace (char ch[], int start, int length)
throws SAXException throws SAXException
{ {
if (documentHandler != null)
documentHandler.ignorableWhitespace(ch, start, length); documentHandler.ignorableWhitespace(ch, start, length);
} }
...@@ -394,6 +405,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler ...@@ -394,6 +405,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler
public void processingInstruction (String target, String data) public void processingInstruction (String target, String data)
throws SAXException throws SAXException
{ {
if (documentHandler != null)
documentHandler.processingInstruction(target, data); documentHandler.processingInstruction(target, data);
} }
...@@ -403,6 +415,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler ...@@ -403,6 +415,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler
* *
* @param name The name of the skipped entity. * @param name The name of the skipped entity.
* @see org.xml.sax.ContentHandler#skippedEntity * @see org.xml.sax.ContentHandler#skippedEntity
* @exception org.xml.sax.SAXException Throwable by subclasses.
*/ */
public void skippedEntity (String name) public void skippedEntity (String name)
throws SAXException throws SAXException
......
// XMLReaderFactory.java - factory for creating a new reader. // XMLReaderFactory.java - factory for creating a new reader.
// Written by David Megginson, sax@megginson.com // http://www.saxproject.org
// Written by David Megginson
// and by David Brownell
// NO WARRANTY! This class is in the Public Domain. // NO WARRANTY! This class is in the Public Domain.
// $Id: XMLReaderFactory.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ // $Id: XMLReaderFactory.java,v 1.5.2.4 2002/01/29 21:34:15 dbrownell Exp $
package org.xml.sax.helpers; package org.xml.sax.helpers;
import org.xml.sax.Parser; import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import org.xml.sax.XMLReader; import org.xml.sax.XMLReader;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
...@@ -16,12 +20,12 @@ import org.xml.sax.SAXException; ...@@ -16,12 +20,12 @@ import org.xml.sax.SAXException;
* <blockquote> * <blockquote>
* <em>This module, both source code and documentation, is in the * <em>This module, both source code and documentation, is in the
* Public Domain, and comes with <strong>NO WARRANTY</strong>.</em> * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
* See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
* for further information.
* </blockquote> * </blockquote>
* *
* <p>This class contains static methods for creating an XML reader * <p>This class contains static methods for creating an XML reader
* from an explicit class name, or for creating an XML reader based * from an explicit class name, or based on runtime defaults:</p>
* on the value of the <code>org.xml.sax.driver</code> system
* property:</p>
* *
* <pre> * <pre>
* try { * try {
...@@ -31,23 +35,20 @@ import org.xml.sax.SAXException; ...@@ -31,23 +35,20 @@ import org.xml.sax.SAXException;
* } * }
* </pre> * </pre>
* *
* <p>Note that these methods will not be usable in environments where * <p><strong>Note to Distributions bundled with parsers:</strong>
* system properties are not accessible or where the application or * You should modify the implementation of the no-arguments
* applet is not permitted to load classes dynamically.</p> * <em>createXMLReader</em> to handle cases where the external
* * configuration mechanisms aren't set up. That method should do its
* <p><strong>Note to implementors:</strong> SAX implementations in specialized * best to return a parser when one is in the class path, even when
* environments may replace this class with a different one optimized for the * nothing bound its class name to <code>org.xml.sax.driver</code> so
* environment, as long as its method signatures remain the same.</p> * those configuration mechanisms would see it.</p>
* *
* @since SAX 2.0 * @since SAX 2.0
* @author David Megginson, * @author David Megginson, David Brownell
* <a href="mailto:sax@megginson.com">sax@megginson.com</a> * @version 2.0.1 (sax2r2)
* @version 2.0
* @see org.xml.sax.XMLReader
*/ */
final public class XMLReaderFactory final public class XMLReaderFactory
{ {
/** /**
* Private constructor. * Private constructor.
* *
...@@ -57,43 +58,103 @@ final public class XMLReaderFactory ...@@ -57,43 +58,103 @@ final public class XMLReaderFactory
{ {
} }
private static final String property = "org.xml.sax.driver";
/** /**
* Attempt to create an XML reader from a system property. * Attempt to create an XMLReader from system defaults.
* In environments which can support it, the name of the XMLReader
* class is determined by trying each these options in order, and
* using the first one which succeeds:</p> <ul>
*
* <li>If the system property <code>org.xml.sax.driver</code>
* has a value, that is used as an XMLReader class name. </li>
*
* <li>The JAR "Services API" is used to look for a class name
* in the <em>META-INF/services/org.xml.sax.driver</em> file in
* jarfiles available to the runtime.</li>
* *
* <p>This method uses the value of the system property * <li> SAX parser distributions are strongly encouraged to provide
* "org.xml.sax.driver" as the full name of a Java class * a default XMLReader class name that will take effect only when
* and tries to instantiate that class as a SAX2 * previous options (on this list) are not successful.</li>
* XMLReader.</p>
* *
* <p>Note that many Java interpreters allow system properties * <li>Finally, if {@link ParserFactory#makeParser()} can
* to be specified on the command line.</p> * return a system default SAX1 parser, that parser is wrapped in
* a {@link ParserAdapter}. (This is a migration aid for SAX1
* environments, where the <code>org.xml.sax.parser</code> system
* property will often be usable.) </li>
*
* </ul>
*
* <p> In environments such as small embedded systems, which can not
* support that flexibility, other mechanisms to determine the default
* may be used. </p>
*
* <p>Note that many Java environments allow system properties to be
* initialized on a command line. This means that <em>in most cases</em>
* setting a good value for that property ensures that calls to this
* method will succeed, except when security policies intervene.
* This will also maximize application portability to older SAX
* environments, with less robust implementations of this method.
* </p>
* *
* @return A new XMLReader. * @return A new XMLReader.
* @exception org.xml.sax.SAXException If the value of the * @exception org.xml.sax.SAXException If no default XMLReader class
* "org.xml.sax.driver" system property is null, * can be identified and instantiated.
* or if the class cannot be loaded and instantiated.
* @see #createXMLReader(java.lang.String) * @see #createXMLReader(java.lang.String)
*/ */
public static XMLReader createXMLReader () public static XMLReader createXMLReader ()
throws SAXException throws SAXException
{ {
String className = System.getProperty("org.xml.sax.driver"); String className = null;
ClassLoader loader = NewInstance.getClassLoader ();
// 1. try the JVM-instance-wide system property
try { className = System.getProperty (property); }
catch (Exception e) { /* normally fails for applets */ }
// 2. if that fails, try META-INF/services/
if (className == null) { if (className == null) {
Parser parser;
try { try {
parser = ParserFactory.makeParser(); String service = "META-INF/services/" + property;
InputStream in;
BufferedReader reader;
if (loader == null)
in = ClassLoader.getSystemResourceAsStream (service);
else
in = loader.getResourceAsStream (service);
if (in != null) {
reader = new BufferedReader (
new InputStreamReader (in, "UTF8"));
className = reader.readLine ();
in.close ();
}
} catch (Exception e) { } 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); // 3. Distro-specific fallback
if (className == null) {
// BEGIN DISTRIBUTION-SPECIFIC
// EXAMPLE:
// className = "com.example.sax.XmlReader";
// or a $JAVA_HOME/jre/lib/*properties setting...
// END DISTRIBUTION-SPECIFIC
}
// do we know the XMLReader implementation class yet?
if (className != null)
return loadClass (loader, className);
// 4. panic -- adapt any SAX1 parser
try {
return new ParserAdapter (ParserFactory.makeParser ());
} catch (Exception e) {
throw new SAXException ("Can't create default XMLReader; "
+ "is system property org.xml.sax.driver set?");
} }
} }
...@@ -104,6 +165,10 @@ final public class XMLReaderFactory ...@@ -104,6 +165,10 @@ final public class XMLReaderFactory
* <p>Given a class name, this method attempts to load * <p>Given a class name, this method attempts to load
* and instantiate the class as an XML reader.</p> * and instantiate the class as an XML reader.</p>
* *
* <p>Note that this method will not be usable in environments where
* the caller (perhaps an applet) is not permitted to load classes
* dynamically.</p>
*
* @return A new XML reader. * @return A new XML reader.
* @exception org.xml.sax.SAXException If the class cannot be * @exception org.xml.sax.SAXException If the class cannot be
* loaded, instantiated, and cast to XMLReader. * loaded, instantiated, and cast to XMLReader.
...@@ -112,8 +177,14 @@ final public class XMLReaderFactory ...@@ -112,8 +177,14 @@ final public class XMLReaderFactory
public static XMLReader createXMLReader (String className) public static XMLReader createXMLReader (String className)
throws SAXException throws SAXException
{ {
return loadClass (NewInstance.getClassLoader (), className);
}
private static XMLReader loadClass (ClassLoader loader, String className)
throws SAXException
{
try { try {
return (XMLReader)(Class.forName(className).newInstance()); return (XMLReader) NewInstance.newInstance (loader, className);
} catch (ClassNotFoundException e1) { } catch (ClassNotFoundException e1) {
throw new SAXException("SAX2 driver class " + className + throw new SAXException("SAX2 driver class " + className +
" not found", e1); " not found", e1);
...@@ -128,9 +199,5 @@ final public class XMLReaderFactory ...@@ -128,9 +199,5 @@ final public class XMLReaderFactory
throw new SAXException("SAX2 driver class " + className + throw new SAXException("SAX2 driver class " + className +
" does not implement XMLReader", e4); " does not implement XMLReader", e4);
} }
} }
} }
// end of XMLReaderFactory.java
<HTML><HEAD>
<!-- $Id: package.html,v 1.3.2.1 2001/11/09 20:32:58 dbrownell Exp $ -->
</HEAD><BODY>
<p>This package contains "helper" classes, including
support for bootstrapping SAX-based applications.
<p>See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
for more information about SAX.</p>
</BODY></HTML>
<html><head>
<!-- $Id: package.html,v 1.2.2.2 2002/01/12 21:42:21 dbrownell Exp $ -->
</head><body>
<p> This package provides the core SAX APIs.
Some SAX1 APIs are deprecated to encourage integration of
namespace-awareness into designs of new applications
and into maintainance of existing infrastructure. </p>
<p>See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
for more information about SAX.</p>
<h2> SAX2 Standard Feature Flags </h2>
<p> One of the essential characteristics of SAX2 is that it added
feature flags which can be used to examine and perhaps modify
parser modes, in particular modes such as validation.
Since features are identified by (absolute) URIs, anyone
can define such features.
Currently defined standard feature URIs have the prefix
<code>http://xml.org/sax/features/</code> before an identifier such as
<code>validation</code>. Turn features on or off using
<em>setFeature</em>. Those standard identifiers are: </p>
<table border="1" cellpadding="3" cellspacing="0" width="100%">
<tr align="center" bgcolor="#ccccff">
<th>Feature ID</th>
<th>Default</th>
<th>Description</th>
</tr>
<tr>
<td>external-general-entities</td>
<td><em>unspecified</em></td>
<td> Reports whether this parser processes external
general entities; always true if validating</td>
</tr>
<tr>
<td>external-parameter-entities</td>
<td><em>unspecified</em></td>
<td> Reports whether this parser processes external
parameter entities; always true if validating</td>
</tr>
<tr>
<td>lexical-handler/parameter-entities</td>
<td><em>unspecified</em></td>
<td> true indicates that the LexicalHandler will report the
beginning and end of parameter entities
</td>
</tr>
<tr>
<td>namespaces</td>
<td>true</td>
<td> true indicates namespace URIs and unprefixed local names
for element and attribute names will be available </td>
</tr>
<tr>
<td>namespace-prefixes</td>
<td>false</td>
<td> true indicates XML 1.0 names (with prefixes) and attributes
(including <em>xmlns*</em> attributes) will be available </td>
</tr>
<tr>
<td>string-interning</td>
<td><em>unspecified</em></td>
<td> true if all XML names (for elements, prefixes, attributes,
entities, notations, and local names),
as well as Namespace URIs, will have been interned
using <em>java.lang.String.intern</em>. This supports fast
testing of equality/inequality against string constants.</td>
</tr>
<tr>
<td>validation</td>
<td><em>unspecified</em></td>
<td> controls whether the parser is reporting all validity
errors; if true, all external entities will be read. </td>
</tr>
</table>
<p> Support for the default values of the
<em>namespaces</em> and <em>namespace-prefixes</em>
properties is required.
</p>
<p> For default values not specified by SAX2,
each XMLReader implementation specifies its default,
or may choose not to expose the feature flag.
Unless otherwise specified here,
implementations may support changing current values
of these standard feature flags, but not while parsing.
</p>
<h2> SAX2 Standard Handler and Property IDs </h2>
<p> For parser interface characteristics that are described
as objects, a separate namespace is defined. The
objects in this namespace are again identified by URI, and
the standard property URIs have the prefix
<code>http://xml.org/sax/properties/</code> before an identifier such as
<code>lexical-handler</code> or
<code>dom-node</code>. Manage those properties using
<em>setProperty()</em>. Those identifiers are: </p>
<table border="1" cellpadding="3" cellspacing="0" width="100%">
<tr align="center" bgcolor="#ccccff">
<th>Property ID</th>
<th>Description</th>
</tr>
<tr>
<td>declaration-handler</td>
<td> Used to see most DTD declarations except those treated
as lexical ("document element name is ...") or which are
mandatory for all SAX parsers (<em>DTDHandler</em>).
The Object must implement <a href="ext/DeclHandler.html"
><em>org.xml.sax.ext.DeclHandler</em></a>.
</td>
</tr>
<tr>
<td>dom-node</td>
<td> For "DOM Walker" style parsers, which ignore their
<em>parser.parse()</em> parameters, this is used to
specify the DOM (sub)tree being walked by the parser.
The Object must implement the
<em>org.w3c.dom.Node</em> interface.
</td>
</tr>
<tr>
<td>lexical-handler</td>
<td> Used to see some syntax events that are essential in some
applications: comments, CDATA delimeters, selected general
entity inclusions, and the start and end of the DTD
(and declaration of document element name).
The Object must implement <a href="ext/LexicalHandler.html"
><em>org.xml.sax.ext.LexicalHandler</em></a>.
</td>
</tr>
<tr>
<td>xml-string</td>
<td> Readable only during a parser callback, this exposes a <b>TBS</b>
chunk of characters responsible for the current event. </td>
</tr>
</table>
<p> All of these standard properties are optional;
XMLReader implementations need not support them.
</p>
</body></html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment