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
This commit is contained in:
parent
51d6eed48e
commit
7a163ec05c
36 changed files with 9164 additions and 8501 deletions
|
@ -1,3 +1,13 @@
|
|||
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>
|
||||
|
||||
* java/util/natResourceBundle.cc: Include
|
||||
|
|
|
@ -2252,6 +2252,7 @@ org/xml/sax/helpers/AttributesImpl.java \
|
|||
org/xml/sax/helpers/DefaultHandler.java \
|
||||
org/xml/sax/helpers/LocatorImpl.java \
|
||||
org/xml/sax/helpers/NamespaceSupport.java \
|
||||
org/xml/sax/helpers/NewInstance.java \
|
||||
org/xml/sax/helpers/ParserAdapter.java \
|
||||
org/xml/sax/helpers/ParserFactory.java \
|
||||
org/xml/sax/helpers/XMLFilterImpl.java \
|
||||
|
|
|
@ -2002,6 +2002,7 @@ org/xml/sax/helpers/AttributesImpl.java \
|
|||
org/xml/sax/helpers/DefaultHandler.java \
|
||||
org/xml/sax/helpers/LocatorImpl.java \
|
||||
org/xml/sax/helpers/NamespaceSupport.java \
|
||||
org/xml/sax/helpers/NewInstance.java \
|
||||
org/xml/sax/helpers/ParserAdapter.java \
|
||||
org/xml/sax/helpers/ParserFactory.java \
|
||||
org/xml/sax/helpers/XMLFilterImpl.java \
|
||||
|
@ -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/LocatorImpl.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/ParserFactory.P \
|
||||
.deps/org/xml/sax/helpers/XMLFilterImpl.P \
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SAX Attribute List Interface.
|
||||
// http://www.saxproject.org
|
||||
// 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;
|
||||
|
||||
|
@ -10,6 +11,8 @@ package org.xml.sax;
|
|||
* <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 is the original SAX1 interface for reporting an element's
|
||||
|
@ -61,9 +64,8 @@ package org.xml.sax;
|
|||
* {@link org.xml.sax.Attributes Attributes}
|
||||
* interface, which includes Namespace support.
|
||||
* @since SAX 1.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.DocumentHandler#startElement startElement
|
||||
* @see org.xml.sax.helpers.AttributeListImpl AttributeListImpl
|
||||
*/
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// 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.
|
||||
|
||||
// $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;
|
||||
|
@ -14,6 +15,8 @@ package org.xml.sax;
|
|||
* <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 interface allows access to a list of attributes in
|
||||
|
@ -30,7 +33,13 @@ package org.xml.sax;
|
|||
* contain attributes used as Namespace declarations (xmlns*) unless
|
||||
* the <code>http://xml.org/sax/features/namespace-prefixes</code>
|
||||
* feature is set to <var>true</var> (it is <var>false</var> by
|
||||
* default).</p>
|
||||
* 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>,
|
||||
* access by qualified name may not be available; if the
|
||||
|
@ -47,10 +56,10 @@ package org.xml.sax;
|
|||
* vary from implementation to implementation.</p>
|
||||
*
|
||||
* @since SAX 2.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @see org.xml.sax.helpers.AttributeListImpl
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.helpers.AttributesImpl
|
||||
* @see org.xml.sax.ext.DeclHandler#attributeDecl
|
||||
*/
|
||||
public interface Attributes
|
||||
{
|
||||
|
@ -167,7 +176,7 @@ public interface Attributes
|
|||
* @return The index of the attribute, or -1 if it does not
|
||||
* appear in the list.
|
||||
*/
|
||||
public int getIndex (String uri, String localPart);
|
||||
public int getIndex (String uri, String localName);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// 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.
|
||||
|
||||
// $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;
|
||||
|
||||
|
@ -13,6 +14,8 @@ package org.xml.sax;
|
|||
* <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 is the main interface that most SAX applications
|
||||
|
@ -48,9 +51,8 @@ package org.xml.sax;
|
|||
* bug.</p>
|
||||
*
|
||||
* @since SAX 2.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.XMLReader
|
||||
* @see org.xml.sax.DTDHandler
|
||||
* @see org.xml.sax.ErrorHandler
|
||||
|
@ -90,8 +92,7 @@ public interface ContentHandler
|
|||
* Receive notification of the beginning of a document.
|
||||
*
|
||||
* <p>The SAX parser will invoke this method only once, before any
|
||||
* other methods in this interface or in {@link org.xml.sax.DTDHandler
|
||||
* DTDHandler} (except for {@link #setDocumentLocator
|
||||
* other event callbacks (except for {@link #setDocumentLocator
|
||||
* setDocumentLocator}).</p>
|
||||
*
|
||||
* @exception org.xml.sax.SAXException Any SAX exception, possibly
|
||||
|
@ -136,18 +137,21 @@ public interface ContentHandler
|
|||
* itself, if necessary.</p>
|
||||
*
|
||||
* <p>Note that start/endPrefixMapping events are not
|
||||
* guaranteed to be properly nested relative to each-other:
|
||||
* all startPrefixMapping events will occur before the
|
||||
* guaranteed to be properly nested relative to each other:
|
||||
* all startPrefixMapping events will occur immediately before the
|
||||
* corresponding {@link #startElement startElement} event,
|
||||
* and all {@link #endPrefixMapping endPrefixMapping}
|
||||
* events will occur after the corresponding {@link #endElement
|
||||
* endElement} event, but their order is not otherwise
|
||||
* events will occur immediately after the corresponding
|
||||
* {@link #endElement endElement} event,
|
||||
* but their order is not otherwise
|
||||
* guaranteed.</p>
|
||||
*
|
||||
* <p>There should never be start/endPrefixMapping events for the
|
||||
* "xml" prefix, since it is predeclared and immutable.</p>
|
||||
*
|
||||
* @param prefix The Namespace prefix being declared.
|
||||
* An empty string is used for the default element namespace,
|
||||
* which has no prefix.
|
||||
* @param uri The Namespace URI the prefix is mapped to.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
|
@ -162,12 +166,13 @@ public interface ContentHandler
|
|||
* End the scope of a prefix-URI mapping.
|
||||
*
|
||||
* <p>See {@link #startPrefixMapping startPrefixMapping} for
|
||||
* details. This event will always occur after the corresponding
|
||||
* {@link #endElement endElement} event, but the order of
|
||||
* details. These events will always occur immediately after the
|
||||
* corresponding {@link #endElement endElement} event, but the order of
|
||||
* {@link #endPrefixMapping endPrefixMapping} events is not otherwise
|
||||
* guaranteed.</p>
|
||||
*
|
||||
* @param prefix The prefix that was being mapping.
|
||||
* This is the empty string when a default mapping scope ends.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
* @see #startPrefixMapping
|
||||
|
@ -220,6 +225,9 @@ public interface ContentHandler
|
|||
* property is true (it is false by default, and support for a
|
||||
* 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
|
||||
* element has no Namespace URI or if Namespace
|
||||
* processing is not being performed.
|
||||
|
@ -236,7 +244,7 @@ public interface ContentHandler
|
|||
* @see #endElement
|
||||
* @see org.xml.sax.Attributes
|
||||
*/
|
||||
public void startElement (String namespaceURI, String localName,
|
||||
public void startElement (String uri, String localName,
|
||||
String qName, Attributes atts)
|
||||
throws SAXException;
|
||||
|
||||
|
@ -262,7 +270,7 @@ public interface ContentHandler
|
|||
* @exception org.xml.sax.SAXException Any SAX exception, possibly
|
||||
* wrapping another exception.
|
||||
*/
|
||||
public void endElement (String namespaceURI, String localName,
|
||||
public void endElement (String uri, String localName,
|
||||
String qName)
|
||||
throws SAXException;
|
||||
|
||||
|
@ -280,6 +288,23 @@ public interface ContentHandler
|
|||
* <p>The application must not attempt to read from the array
|
||||
* 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
|
||||
* content using the {@link #ignorableWhitespace ignorableWhitespace}
|
||||
* method rather than this one (validating parsers <em>must</em>
|
||||
|
@ -336,6 +361,10 @@ public interface ContentHandler
|
|||
* section 2.8) or a text declaration (XML 1.0, section 4.3.1)
|
||||
* 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 data The processing instruction data, or null if
|
||||
* none was supplied. The data does not include any
|
||||
|
@ -349,8 +378,13 @@ public interface ContentHandler
|
|||
|
||||
/**
|
||||
* 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
|
||||
* have not seen the declarations (because, for example, the
|
||||
* entity was declared in an external DTD subset). All processors
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SAX DTD handler.
|
||||
// http://www.saxproject.org
|
||||
// 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;
|
||||
|
||||
|
@ -10,6 +11,8 @@ package org.xml.sax;
|
|||
* <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>If a SAX application needs information about notations and
|
||||
|
@ -27,7 +30,10 @@ package org.xml.sax;
|
|||
* of the order in which the notations and unparsed entities were
|
||||
* declared; however, all DTD events must be reported after the
|
||||
* 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
|
||||
* future use (perhaps in a hash table or object tree).
|
||||
|
@ -37,11 +43,9 @@ package org.xml.sax;
|
|||
* notation corresponding with the attribute value.</p>
|
||||
*
|
||||
* @since SAX 1.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @see org.xml.sax.Parser#setDTDHandler
|
||||
* @see org.xml.sax.HandlerBase
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.XMLReader#setDTDHandler
|
||||
*/
|
||||
public interface DTDHandler {
|
||||
|
||||
|
@ -50,7 +54,10 @@ public interface DTDHandler {
|
|||
* Receive notification of a notation declaration event.
|
||||
*
|
||||
* <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.
|
||||
* If a system identifier is present, and it is a URL, the SAX
|
||||
|
@ -68,7 +75,7 @@ public interface DTDHandler {
|
|||
* @exception org.xml.sax.SAXException Any SAX exception, possibly
|
||||
* wrapping another exception.
|
||||
* @see #unparsedEntityDecl
|
||||
* @see org.xml.sax.AttributeList
|
||||
* @see org.xml.sax.Attributes
|
||||
*/
|
||||
public abstract void notationDecl (String name,
|
||||
String publicId,
|
||||
|
@ -82,7 +89,9 @@ public interface DTDHandler {
|
|||
* <p>Note that the notation name corresponds to a notation
|
||||
* reported by the {@link #notationDecl notationDecl} event.
|
||||
* 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
|
||||
* fully before passing it to the application.</p>
|
||||
|
@ -93,9 +102,9 @@ public interface DTDHandler {
|
|||
* @param publicId The entity's public identifier, or null if none
|
||||
* was given.
|
||||
* @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 org.xml.sax.AttributeList
|
||||
* @see org.xml.sax.Attributes
|
||||
*/
|
||||
public abstract void unparsedEntityDecl (String name,
|
||||
String publicId,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SAX document handler.
|
||||
// http://www.saxproject.org
|
||||
// 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;
|
||||
|
||||
|
@ -10,6 +11,8 @@ package org.xml.sax;
|
|||
* <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 was the main event-handling interface for SAX1; in
|
||||
|
@ -35,9 +38,8 @@ package org.xml.sax;
|
|||
* {@link org.xml.sax.ContentHandler ContentHandler}
|
||||
* interface, which includes Namespace support.
|
||||
* @since SAX 1.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.Parser#setDocumentHandler
|
||||
* @see org.xml.sax.Locator
|
||||
* @see org.xml.sax.HandlerBase
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SAX entity resolver.
|
||||
// http://www.saxproject.org
|
||||
// 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;
|
||||
|
||||
|
@ -13,6 +14,8 @@ import java.io.IOException;
|
|||
* <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>If a SAX application needs to implement customized handling
|
||||
|
@ -58,10 +61,9 @@ import java.io.IOException;
|
|||
* (possibly by using the public identifier).</p>
|
||||
*
|
||||
* @since SAX 1.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @see org.xml.sax.Parser#setEntityResolver
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.XMLReader#setEntityResolver
|
||||
* @see org.xml.sax.InputSource
|
||||
*/
|
||||
public interface EntityResolver {
|
||||
|
@ -70,19 +72,26 @@ public interface EntityResolver {
|
|||
/**
|
||||
* Allow the application to resolve external entities.
|
||||
*
|
||||
* <p>The Parser will call this method before opening any external
|
||||
* entity except the top-level document entity (including the
|
||||
* external DTD subset, external entities referenced within the
|
||||
* DTD, and external entities referenced within the document
|
||||
* element): the application may request that the parser resolve
|
||||
* <p>The parser will call this method before opening any external
|
||||
* entity except the top-level document entity. Such entities include
|
||||
* the external DTD subset and external parameter entities referenced
|
||||
* within the DTD (in either case, only if the parser reads external
|
||||
* 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
|
||||
* 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
|
||||
* system identifiers to secure and/or local URIs, to look up
|
||||
* public identifiers in a catalogue, or to read an entity from a
|
||||
* 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
|
||||
* resolve it fully before reporting it to the application.</p>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SAX error handler.
|
||||
// http://www.saxproject.org
|
||||
// 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;
|
||||
|
||||
|
@ -11,6 +12,8 @@ package org.xml.sax;
|
|||
* <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>If a SAX application needs to implement customized error
|
||||
|
@ -33,10 +36,9 @@ package org.xml.sax;
|
|||
* could catch an exception and report a fatalError).</p>
|
||||
*
|
||||
* @since SAX 1.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @see org.xml.sax.Parser#setErrorHandler
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.XMLReader#setErrorHandler
|
||||
* @see org.xml.sax.SAXParseException
|
||||
*/
|
||||
public interface ErrorHandler {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SAX default handler base class.
|
||||
// http://www.saxproject.org
|
||||
// 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;
|
||||
|
||||
|
@ -10,6 +11,8 @@ package org.xml.sax;
|
|||
* <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 implements the default behaviour for four SAX1
|
||||
|
@ -32,9 +35,8 @@ package org.xml.sax;
|
|||
* {@link org.xml.sax.helpers.DefaultHandler DefaultHandler}
|
||||
* class.
|
||||
* @since SAX 1.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.EntityResolver
|
||||
* @see org.xml.sax.DTDHandler
|
||||
* @see org.xml.sax.DocumentHandler
|
||||
|
@ -58,7 +60,7 @@ public class HandlerBase
|
|||
* in a subclass to do special translations such as catalog lookups
|
||||
* 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.
|
||||
* @param systemId The system identifier provided in the XML
|
||||
* document.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SAX input source.
|
||||
// http://www.saxproject.org
|
||||
// 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;
|
||||
|
||||
|
@ -13,6 +14,8 @@ import java.io.InputStream;
|
|||
* <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 allows a SAX application to encapsulate information
|
||||
|
@ -20,28 +23,36 @@ import java.io.InputStream;
|
|||
* a public identifier, a system identifier, a byte stream (possibly
|
||||
* 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
|
||||
* method, or as the return value of the EntityResolver.resolveEntity
|
||||
* method.</p>
|
||||
*
|
||||
* <p>The SAX parser will use the InputSource object to determine how
|
||||
* to read XML input. If there is a character stream available, the
|
||||
* parser will read that stream directly; if not, the parser will use
|
||||
* a byte stream, if available; if neither a character stream nor a
|
||||
* parser will read that stream directly, disregarding any text
|
||||
* 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
|
||||
* connection to the resource identified by the system
|
||||
* identifier.</p>
|
||||
*
|
||||
* <p>An InputSource object belongs to the application: the SAX parser
|
||||
* 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
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @see org.xml.sax.Parser#parse
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource)
|
||||
* @see org.xml.sax.EntityResolver#resolveEntity
|
||||
* @see java.io.InputStream
|
||||
* @see java.io.Reader
|
||||
|
@ -69,7 +80,8 @@ public class InputSource {
|
|||
* public identifier as well, or setEncoding to specify
|
||||
* 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).
|
||||
* @see #setPublicId
|
||||
|
@ -87,9 +99,9 @@ public class InputSource {
|
|||
/**
|
||||
* Create a new input source with a byte stream.
|
||||
*
|
||||
* <p>Application writers may use setSystemId to provide a base
|
||||
* for resolving relative URIs, setPublicId to include a
|
||||
* public identifier, and/or setEncoding to specify the object's
|
||||
* <p>Application writers should use setSystemId() to provide a base
|
||||
* for resolving relative URIs, may use setPublicId to include a
|
||||
* public identifier, and may use setEncoding to specify the object's
|
||||
* character encoding.</p>
|
||||
*
|
||||
* @param byteStream The raw byte stream containing the document.
|
||||
|
@ -108,8 +120,8 @@ public class InputSource {
|
|||
/**
|
||||
* Create a new input source with a character stream.
|
||||
*
|
||||
* <p>Application writers may use setSystemId() to provide a base
|
||||
* for resolving relative URIs, and setPublicId to include a
|
||||
* <p>Application writers should use setSystemId() to provide a base
|
||||
* for resolving relative URIs, and may use setPublicId to include a
|
||||
* public identifier.</p>
|
||||
*
|
||||
* <p>The character stream shall not include a byte order mark.</p>
|
||||
|
@ -169,7 +181,8 @@ public class InputSource {
|
|||
* object pointed to by the system identifier, it can register
|
||||
* 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.
|
||||
* @see #setEncoding
|
||||
|
@ -191,7 +204,7 @@ public class InputSource {
|
|||
*
|
||||
* <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 #getEncoding
|
||||
*/
|
||||
|
@ -263,6 +276,8 @@ public class InputSource {
|
|||
|
||||
/**
|
||||
* 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.
|
||||
* @see #setByteStream
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SAX locator interface for document events.
|
||||
// http://www.saxproject.org
|
||||
// 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;
|
||||
|
||||
|
@ -11,6 +12,8 @@ package org.xml.sax;
|
|||
* <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>If a SAX parser provides location information to the SAX
|
||||
|
@ -18,13 +21,13 @@ package org.xml.sax;
|
|||
* passing an instance to the application using the content
|
||||
* handler's {@link org.xml.sax.ContentHandler#setDocumentLocator
|
||||
* setDocumentLocator} method. The application can use the
|
||||
* object to obtain the location of any other content handler event
|
||||
* object to obtain the location of any other SAX event
|
||||
* in the XML source document.</p>
|
||||
*
|
||||
* <p>Note that the results returned by the object will be valid only
|
||||
* during the scope of each content handler method: the application
|
||||
* during the scope of each callback method: the application
|
||||
* 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
|
||||
* very strongly encouraged to do so. If the parser supplies a
|
||||
|
@ -35,9 +38,8 @@ package org.xml.sax;
|
|||
* available.</p>
|
||||
*
|
||||
* @since SAX 1.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.ContentHandler#setDocumentLocator
|
||||
*/
|
||||
public interface Locator {
|
||||
|
@ -65,7 +67,9 @@ public interface Locator {
|
|||
* triggering the event appears.</p>
|
||||
*
|
||||
* <p>If the system identifier is a URL, the parser must resolve it
|
||||
* fully before passing it to the application.</p>
|
||||
* 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
|
||||
* if none is available.
|
||||
|
@ -76,11 +80,16 @@ public interface Locator {
|
|||
|
||||
/**
|
||||
* 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
|
||||
* is intended only as an approximation for the sake of error
|
||||
* reporting; it is not intended to provide sufficient information
|
||||
* to edit the character content of the original XML document.</p>
|
||||
* is intended only as an approximation for the sake of diagnostics;
|
||||
* it is not intended to provide sufficient information
|
||||
* 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
|
||||
* in the document entity or external parsed entity where the
|
||||
|
@ -88,7 +97,7 @@ public interface Locator {
|
|||
*
|
||||
* <p>If possible, the SAX driver should provide the line position
|
||||
* of the first character after the text associated with the document
|
||||
* event. The first line in the document is line 1.</p>
|
||||
* event. The first line is line 1.</p>
|
||||
*
|
||||
* @return The line number, or -1 if none is available.
|
||||
* @see #getColumnNumber
|
||||
|
@ -98,11 +107,16 @@ public interface Locator {
|
|||
|
||||
/**
|
||||
* 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
|
||||
* is intended only as an approximation for the sake of error
|
||||
* reporting; it is not intended to provide sufficient information
|
||||
* to edit the character content of the original XML document.</p>
|
||||
* is intended only as an approximation for the sake of diagnostics;
|
||||
* it is not intended to provide sufficient information
|
||||
* 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
|
||||
* in the document entity or external parsed entity where the
|
||||
|
@ -110,10 +124,6 @@ public interface Locator {
|
|||
*
|
||||
* <p>If possible, the SAX driver should provide the line position
|
||||
* of the first character after the text associated with the document
|
||||
* event.</p>
|
||||
*
|
||||
* <p>If possible, the SAX driver should provide the line position
|
||||
* of the first character after the text associated with the document
|
||||
* event. The first column in each line is column 1.</p>
|
||||
*
|
||||
* @return The column number, or -1 if none is available.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SAX parser interface.
|
||||
// http://www.saxproject.org
|
||||
// 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;
|
||||
|
||||
|
@ -14,6 +15,8 @@ import java.util.Locale;
|
|||
* <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 was the main event supplier interface for SAX1; it has
|
||||
|
@ -37,9 +40,8 @@ import java.util.Locale;
|
|||
* {@link org.xml.sax.XMLReader XMLReader}
|
||||
* interface, which includes Namespace support.
|
||||
* @since SAX 1.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.EntityResolver
|
||||
* @see org.xml.sax.DTDHandler
|
||||
* @see org.xml.sax.DocumentHandler
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SAX exception class.
|
||||
// http://www.saxproject.org
|
||||
// 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;
|
||||
|
||||
|
@ -10,6 +11,8 @@ package org.xml.sax;
|
|||
* <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 can contain basic error or warning information from
|
||||
|
@ -27,19 +30,27 @@ package org.xml.sax;
|
|||
* {@link org.xml.sax.SAXParseException SAXParseException} subclass.</p>
|
||||
*
|
||||
* @since SAX 1.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.SAXParseException
|
||||
*/
|
||||
public class SAXException extends Exception {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new SAXException.
|
||||
*/
|
||||
public SAXException ()
|
||||
{
|
||||
super();
|
||||
this.exception = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new SAXException.
|
||||
*
|
||||
* @param message The error or warning message.
|
||||
* @see org.xml.sax.Parser#setLocale
|
||||
*/
|
||||
public SAXException (String message) {
|
||||
super(message);
|
||||
|
@ -71,7 +82,6 @@ public class SAXException extends Exception {
|
|||
*
|
||||
* @param message The detail message.
|
||||
* @param e The exception to be wrapped in a SAXException.
|
||||
* @see org.xml.sax.Parser#setLocale
|
||||
*/
|
||||
public SAXException (String message, Exception e)
|
||||
{
|
||||
|
@ -88,7 +98,6 @@ public class SAXException extends Exception {
|
|||
* the detail message from the embedded exception.</p>
|
||||
*
|
||||
* @return The error or warning message.
|
||||
* @see org.xml.sax.Parser#setLocale
|
||||
*/
|
||||
public String getMessage ()
|
||||
{
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// 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.
|
||||
|
||||
// $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;
|
||||
|
@ -14,6 +15,8 @@ package org.xml.sax;
|
|||
* <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>An XMLReader will throw this exception when it finds an
|
||||
|
@ -21,14 +24,22 @@ package org.xml.sax;
|
|||
* extensions may use this class for other, similar purposes.</p>
|
||||
*
|
||||
* @since SAX 2.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.SAXNotSupportedException
|
||||
*/
|
||||
public class SAXNotRecognizedException extends SAXException
|
||||
{
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public SAXNotRecognizedException ()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new exception with the given message.
|
||||
*
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// 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.
|
||||
|
||||
// $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;
|
||||
|
@ -13,6 +14,8 @@ package org.xml.sax;
|
|||
* <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>An XMLReader will throw this exception when it recognizes a
|
||||
|
@ -21,14 +24,22 @@ package org.xml.sax;
|
|||
* extensions may use this class for similar purposes.</p>
|
||||
*
|
||||
* @since SAX 2.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.SAXNotRecognizedException
|
||||
*/
|
||||
public class SAXNotSupportedException extends SAXException
|
||||
{
|
||||
|
||||
/**
|
||||
* Construct a new exception with no message.
|
||||
*/
|
||||
public SAXNotSupportedException ()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new exception with the given message.
|
||||
*
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SAX exception class.
|
||||
// http://www.saxproject.org
|
||||
// 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;
|
||||
|
||||
|
@ -10,10 +11,13 @@ package org.xml.sax;
|
|||
* <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 exception will include information for locating the error
|
||||
* in the original XML document. Note that although the application
|
||||
* <p>This exception may include information for locating the error
|
||||
* 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
|
||||
* in the {@link org.xml.sax.ErrorHandler ErrorHandler} interface,
|
||||
* the application is not actually required to throw the exception;
|
||||
|
@ -24,9 +28,8 @@ package org.xml.sax;
|
|||
* SAXException}, it inherits the ability to wrap another exception.</p>
|
||||
*
|
||||
* @since SAX 1.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.SAXException
|
||||
* @see org.xml.sax.Locator
|
||||
* @see org.xml.sax.ErrorHandler
|
||||
|
@ -50,7 +53,6 @@ public class SAXParseException extends SAXException {
|
|||
* @param locator The locator object for the error or warning (may be
|
||||
* null).
|
||||
* @see org.xml.sax.Locator
|
||||
* @see org.xml.sax.Parser#setLocale
|
||||
*/
|
||||
public SAXParseException (String message, Locator locator) {
|
||||
super(message);
|
||||
|
@ -77,7 +79,6 @@ public class SAXParseException extends SAXException {
|
|||
* null).
|
||||
* @param e Any exception.
|
||||
* @see org.xml.sax.Locator
|
||||
* @see org.xml.sax.Parser#setLocale
|
||||
*/
|
||||
public SAXParseException (String message, Locator locator,
|
||||
Exception e) {
|
||||
|
@ -96,19 +97,21 @@ public class SAXParseException extends SAXException {
|
|||
*
|
||||
* <p>This constructor is most useful for parser writers.</p>
|
||||
*
|
||||
* <p>If the system identifier is a URL, the parser must resolve it
|
||||
* fully before creating the exception.</p>
|
||||
* <p>All parameters except the message are as if
|
||||
* 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 publicId The public identifier of the entity that generated
|
||||
* @param publicId The public identifer of the entity that generated
|
||||
* 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.
|
||||
* @param lineNumber The line number of the end of the text that
|
||||
* caused the error or warning.
|
||||
* @param columnNumber The column number of the end of the text that
|
||||
* cause the error or warning.
|
||||
* @see org.xml.sax.Parser#setLocale
|
||||
*/
|
||||
public SAXParseException (String message, String publicId, String systemId,
|
||||
int lineNumber, int columnNumber)
|
||||
|
@ -125,21 +128,22 @@ public class SAXParseException extends SAXException {
|
|||
* need to wrap an exception that is not a subclass of
|
||||
* {@link org.xml.sax.SAXException SAXException}.</p>
|
||||
*
|
||||
* <p>If the system identifier is a URL, the parser must resolve it
|
||||
* fully before creating the exception.</p>
|
||||
* <p>All parameters except the message and exception are as if
|
||||
* 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
|
||||
* 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.
|
||||
* @param systemId The system identifier of the entity that generated
|
||||
* @param systemId The system identifer of the entity that generated
|
||||
* the error or warning.
|
||||
* @param lineNumber The line number of the end of the text that
|
||||
* caused the error or warning.
|
||||
* @param columnNumber The column number of the end of the text that
|
||||
* cause the error or warning.
|
||||
* @param e Another exception to embed in this one.
|
||||
* @see org.xml.sax.Parser#setLocale
|
||||
*/
|
||||
public SAXParseException (String message, String publicId, String systemId,
|
||||
int lineNumber, int columnNumber, Exception e)
|
||||
|
@ -185,7 +189,7 @@ public class SAXParseException extends SAXException {
|
|||
/**
|
||||
* 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>
|
||||
*
|
||||
* @return A string containing the system identifier, or null
|
||||
|
@ -201,6 +205,8 @@ public class SAXParseException extends SAXException {
|
|||
/**
|
||||
* 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
|
||||
* if none is available.
|
||||
* @see org.xml.sax.Locator#getLineNumber
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// 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.
|
||||
|
||||
// $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;
|
||||
|
@ -14,6 +15,8 @@ package org.xml.sax;
|
|||
* <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>An XML filter is like an XML reader, except that it obtains its
|
||||
|
@ -28,9 +31,8 @@ package org.xml.sax;
|
|||
* ErrorHandler} events automatically.</p>
|
||||
*
|
||||
* @since SAX 2.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.helpers.XMLFilterImpl
|
||||
*/
|
||||
public interface XMLFilter extends XMLReader
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// XMLReader.java - read an XML document.
|
||||
// Written by David Megginson, sax@megginson.com
|
||||
// http://www.saxproject.org
|
||||
// Written by David Megginson
|
||||
// NO WARRANTY! This class is in the Public Domain.
|
||||
|
||||
// $Id: XMLReader.java,v 1.1 2000/10/02 02:43:17 sboag Exp $
|
||||
// $Id: XMLReader.java,v 1.3.2.5 2002/01/29 21:34:14 dbrownell Exp $
|
||||
|
||||
package org.xml.sax;
|
||||
|
||||
|
@ -15,6 +16,8 @@ import java.io.IOException;
|
|||
* <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><strong>Note:</strong> despite its name, this interface does
|
||||
|
@ -36,7 +39,7 @@ import java.io.IOException;
|
|||
* <p>This interface replaces the (now deprecated) SAX 1.0 {@link
|
||||
* org.xml.sax.Parser Parser} interface. The XMLReader interface
|
||||
* contains two important enhancements over the old Parser
|
||||
* interface:</p>
|
||||
* interface (as well as some minor ones):</p>
|
||||
*
|
||||
* <ol>
|
||||
* <li>it adds a standard way to query and set features and
|
||||
|
@ -49,9 +52,8 @@ import java.io.IOException;
|
|||
* a SAX2 XMLReader and vice-versa.</p>
|
||||
*
|
||||
* @since SAX 2.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.XMLFilter
|
||||
* @see org.xml.sax.helpers.ParserAdapter
|
||||
* @see org.xml.sax.helpers.XMLReaderAdapter
|
||||
|
@ -66,22 +68,23 @@ public interface XMLReader
|
|||
|
||||
|
||||
/**
|
||||
* Look up the value of a feature.
|
||||
* Look up the value of a feature flag.
|
||||
*
|
||||
* <p>The feature name is any fully-qualified URI. It is
|
||||
* possible for an XMLReader to recognize a feature name but
|
||||
* to be unable to return its value; this is especially true
|
||||
* in the case of an adapter for a SAX1 Parser, which has
|
||||
* no way of knowing whether the underlying parser is
|
||||
* performing validation or expanding external entities.</p>
|
||||
* temporarily be unable to return its value.
|
||||
* Some feature values may be available only in specific
|
||||
* contexts, such as before, during, or after a parse.
|
||||
* Also, some feature values may not be programmatically accessible.
|
||||
* (In the case of an adapter for SAX1 {@link Parser}, there is no
|
||||
* implementation-independent way to expose whether the underlying
|
||||
* parser is performing validation, expanding external entities,
|
||||
* and so forth.) </p>
|
||||
*
|
||||
* <p>All XMLReaders are required to recognize the
|
||||
* http://xml.org/sax/features/namespaces and the
|
||||
* http://xml.org/sax/features/namespace-prefixes feature names.</p>
|
||||
*
|
||||
* <p>Some feature values may be available only in specific
|
||||
* contexts, such as before, during, or after a parse.</p>
|
||||
*
|
||||
* <p>Typical usage is something like this:</p>
|
||||
*
|
||||
* <pre>
|
||||
|
@ -112,9 +115,9 @@ public interface XMLReader
|
|||
* using names built on their own URIs.</p>
|
||||
*
|
||||
* @param name The feature name, which is a fully-qualified URI.
|
||||
* @return The current state of the feature (true or false).
|
||||
* @exception org.xml.sax.SAXNotRecognizedException When the
|
||||
* XMLReader does not recognize the feature name.
|
||||
* @return The current value of the feature (true or false).
|
||||
* @exception org.xml.sax.SAXNotRecognizedException If the feature
|
||||
* value can't be assigned or retrieved.
|
||||
* @exception org.xml.sax.SAXNotSupportedException When the
|
||||
* XMLReader recognizes the feature name but
|
||||
* cannot determine its value at this time.
|
||||
|
@ -125,27 +128,23 @@ public interface XMLReader
|
|||
|
||||
|
||||
/**
|
||||
* Set the state of a feature.
|
||||
* Set the value of a feature flag.
|
||||
*
|
||||
* <p>The feature name is any fully-qualified URI. It is
|
||||
* possible for an XMLReader to recognize a feature name but
|
||||
* to be unable to set its value; this is especially true
|
||||
* in the case of an adapter for a SAX1 {@link org.xml.sax.Parser Parser},
|
||||
* which has no way of affecting whether the underlying parser is
|
||||
* validating, for example.</p>
|
||||
* possible for an XMLReader to expose a feature value but
|
||||
* to be unable to change the current value.
|
||||
* Some feature values may be immutable or mutable only
|
||||
* in specific contexts, such as before, during, or after
|
||||
* a parse.</p>
|
||||
*
|
||||
* <p>All XMLReaders are required to support setting
|
||||
* http://xml.org/sax/features/namespaces to true and
|
||||
* http://xml.org/sax/features/namespace-prefixes to false.</p>
|
||||
*
|
||||
* <p>Some feature values may be immutable or mutable only
|
||||
* in specific contexts, such as before, during, or after
|
||||
* a parse.</p>
|
||||
*
|
||||
* @param name The feature name, which is a fully-qualified URI.
|
||||
* @param state The requested state of the feature (true or false).
|
||||
* @exception org.xml.sax.SAXNotRecognizedException When the
|
||||
* XMLReader does not recognize the feature name.
|
||||
* @param value The requested value of the feature (true or false).
|
||||
* @exception org.xml.sax.SAXNotRecognizedException If the feature
|
||||
* value can't be assigned or retrieved.
|
||||
* @exception org.xml.sax.SAXNotSupportedException When the
|
||||
* XMLReader recognizes the feature name but
|
||||
* cannot set the requested value.
|
||||
|
@ -160,24 +159,21 @@ public interface XMLReader
|
|||
*
|
||||
* <p>The property name is any fully-qualified URI. It is
|
||||
* possible for an XMLReader to recognize a property name but
|
||||
* to be unable to return its state; this is especially true
|
||||
* in the case of an adapter for a SAX1 {@link org.xml.sax.Parser
|
||||
* Parser}.</p>
|
||||
* temporarily be unable to return its value.
|
||||
* Some property values may be available only in specific
|
||||
* contexts, such as before, during, or after a parse.</p>
|
||||
*
|
||||
* <p>XMLReaders are not required to recognize any specific
|
||||
* property names, though an initial core set is documented for
|
||||
* SAX2.</p>
|
||||
*
|
||||
* <p>Some property values may be available only in specific
|
||||
* contexts, such as before, during, or after a parse.</p>
|
||||
*
|
||||
* <p>Implementors are free (and encouraged) to invent their own properties,
|
||||
* using names built on their own URIs.</p>
|
||||
*
|
||||
* @param name The property name, which is a fully-qualified URI.
|
||||
* @return The current value of the property.
|
||||
* @exception org.xml.sax.SAXNotRecognizedException When the
|
||||
* XMLReader does not recognize the property name.
|
||||
* @exception org.xml.sax.SAXNotRecognizedException If the property
|
||||
* value can't be assigned or retrieved.
|
||||
* @exception org.xml.sax.SAXNotSupportedException When the
|
||||
* XMLReader recognizes the property name but
|
||||
* cannot determine its value at this time.
|
||||
|
@ -192,25 +188,22 @@ public interface XMLReader
|
|||
*
|
||||
* <p>The property name is any fully-qualified URI. It is
|
||||
* possible for an XMLReader to recognize a property name but
|
||||
* to be unable to set its value; this is especially true
|
||||
* in the case of an adapter for a SAX1 {@link org.xml.sax.Parser
|
||||
* Parser}.</p>
|
||||
*
|
||||
* <p>XMLReaders are not required to recognize setting
|
||||
* any specific property names, though a core set is provided with
|
||||
* SAX2.</p>
|
||||
*
|
||||
* <p>Some property values may be immutable or mutable only
|
||||
* to be unable to change the current value.
|
||||
* Some property values may be immutable or mutable only
|
||||
* in specific contexts, such as before, during, or after
|
||||
* a parse.</p>
|
||||
*
|
||||
* <p>XMLReaders are not required to recognize setting
|
||||
* any specific property names, though a core set is defined by
|
||||
* SAX2.</p>
|
||||
*
|
||||
* <p>This method is also the standard mechanism for setting
|
||||
* extended handlers.</p>
|
||||
*
|
||||
* @param name The property name, which is a fully-qualified URI.
|
||||
* @param state The requested value for the property.
|
||||
* @exception org.xml.sax.SAXNotRecognizedException When the
|
||||
* XMLReader does not recognize the property name.
|
||||
* @param value The requested value for the property.
|
||||
* @exception org.xml.sax.SAXNotRecognizedException If the property
|
||||
* value can't be assigned or retrieved.
|
||||
* @exception org.xml.sax.SAXNotSupportedException When the
|
||||
* XMLReader recognizes the property name but
|
||||
* cannot set the requested value.
|
||||
|
@ -236,8 +229,6 @@ public interface XMLReader
|
|||
* resolver immediately.</p>
|
||||
*
|
||||
* @param resolver The entity resolver.
|
||||
* @exception java.lang.NullPointerException If the resolver
|
||||
* argument is null.
|
||||
* @see #getEntityResolver
|
||||
*/
|
||||
public void setEntityResolver (EntityResolver resolver);
|
||||
|
@ -264,8 +255,6 @@ public interface XMLReader
|
|||
* handler immediately.</p>
|
||||
*
|
||||
* @param handler The DTD handler.
|
||||
* @exception java.lang.NullPointerException If the handler
|
||||
* argument is null.
|
||||
* @see #getDTDHandler
|
||||
*/
|
||||
public void setDTDHandler (DTDHandler handler);
|
||||
|
@ -293,8 +282,6 @@ public interface XMLReader
|
|||
* handler immediately.</p>
|
||||
*
|
||||
* @param handler The content handler.
|
||||
* @exception java.lang.NullPointerException If the handler
|
||||
* argument is null.
|
||||
* @see #getContentHandler
|
||||
*/
|
||||
public void setContentHandler (ContentHandler handler);
|
||||
|
@ -324,8 +311,6 @@ public interface XMLReader
|
|||
* handler immediately.</p>
|
||||
*
|
||||
* @param handler The error handler.
|
||||
* @exception java.lang.NullPointerException If the handler
|
||||
* argument is null.
|
||||
* @see #getErrorHandler
|
||||
*/
|
||||
public void setErrorHandler (ErrorHandler handler);
|
||||
|
@ -411,5 +396,3 @@ public interface XMLReader
|
|||
throws IOException, SAXException;
|
||||
|
||||
}
|
||||
|
||||
// end of XMLReader.java
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// DeclHandler.java - Optional handler for DTD declaration events.
|
||||
// http://www.saxproject.org
|
||||
// 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;
|
||||
|
||||
|
@ -13,11 +14,14 @@ import org.xml.sax.SAXException;
|
|||
* <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 is an optional extension handler for SAX2 to provide
|
||||
* information about DTD declarations in an XML document. XML
|
||||
* readers are not required to support this handler.</p>
|
||||
* <p>This is an optional extension handler for SAX2 to provide more
|
||||
* complete information about DTD declarations in an XML document.
|
||||
* 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
|
||||
* notations) are already reported through the {@link
|
||||
|
@ -30,18 +34,16 @@ import org.xml.sax.SAXException;
|
|||
*
|
||||
* <p>To set the DeclHandler for an XML reader, use the
|
||||
* {@link org.xml.sax.XMLReader#setProperty setProperty} method
|
||||
* with the propertyId "http://xml.org/sax/handlers/DeclHandler".
|
||||
* If the reader does not support declaration events, it will throw a
|
||||
* with the property name
|
||||
* <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}
|
||||
* or a
|
||||
* {@link org.xml.sax.SAXNotSupportedException SAXNotSupportedException}
|
||||
* when you attempt to register the handler.</p>
|
||||
*
|
||||
* @since SAX 2.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0beta
|
||||
* @see org.xml.sax.XMLReader
|
||||
* @since SAX 2.0 (extensions 1.0)
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
*/
|
||||
public interface DeclHandler
|
||||
{
|
||||
|
@ -52,8 +54,11 @@ public interface DeclHandler
|
|||
* <p>The content model will consist of the string "EMPTY", the
|
||||
* string "ANY", or a parenthesised group, optionally followed
|
||||
* by an occurrence indicator. The model will be normalized so
|
||||
* that all whitespace is removed,and will include the enclosing
|
||||
* parentheses.</p>
|
||||
* that all parameter entities are fully resolved and all whitespace
|
||||
* 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 model The content model as a normalized string.
|
||||
|
@ -69,13 +74,19 @@ public interface DeclHandler
|
|||
* <p>Only the effective (first) declaration for an attribute will
|
||||
* be reported. The type will be one of the strings "CDATA",
|
||||
* "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY",
|
||||
* "ENTITIES", or "NOTATION", or a parenthesized token group with
|
||||
* the separator "|" and all whitespace removed.</p>
|
||||
* "ENTITIES", a parenthesized token group with
|
||||
* 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 aName The name of the attribute.
|
||||
* @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
|
||||
* none of these applies.
|
||||
* @param value A string representing the attribute's default value,
|
||||
|
@ -85,7 +96,7 @@ public interface DeclHandler
|
|||
public abstract void attributeDecl (String eName,
|
||||
String aName,
|
||||
String type,
|
||||
String valueDefault,
|
||||
String mode,
|
||||
String value)
|
||||
throws SAXException;
|
||||
|
||||
|
@ -94,7 +105,8 @@ public interface DeclHandler
|
|||
* Report an internal entity declaration.
|
||||
*
|
||||
* <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
|
||||
* entity, the name will begin with '%'.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// LexicalHandler.java - optional handler for lexical parse events.
|
||||
// http://www.saxproject.org
|
||||
// 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;
|
||||
|
||||
|
@ -12,12 +13,15 @@ import org.xml.sax.SAXException;
|
|||
* <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 is an optional extension handler for SAX2 to provide
|
||||
* lexical information about an XML document, such as comments
|
||||
* and CDATA section boundaries; XML readers are not required to
|
||||
* support this handler.</p>
|
||||
* and CDATA section boundaries.
|
||||
* 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,
|
||||
* not just to the document element, and all lexical handler events
|
||||
|
@ -26,20 +30,16 @@ import org.xml.sax.SAXException;
|
|||
*
|
||||
* <p>To set the LexicalHandler for an XML reader, use the
|
||||
* {@link org.xml.sax.XMLReader#setProperty setProperty} method
|
||||
* with the propertyId "http://xml.org/sax/handlers/LexicalHandler".
|
||||
* If the reader does not support lexical events, it will throw a
|
||||
* with the property name
|
||||
* <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}
|
||||
* or a
|
||||
* {@link org.xml.sax.SAXNotSupportedException SAXNotSupportedException}
|
||||
* when you attempt to register the handler.</p>
|
||||
*
|
||||
* @since SAX 2.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0beta
|
||||
* @see org.xml.sax.XMLReader#setProperty
|
||||
* @see org.xml.sax.SAXNotRecognizedException
|
||||
* @see org.xml.sax.SAXNotSupportedException
|
||||
* @since SAX 2.0 (extensions 1.0)
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
*/
|
||||
public interface LexicalHandler
|
||||
{
|
||||
|
@ -47,19 +47,36 @@ public interface LexicalHandler
|
|||
/**
|
||||
* Report the start of DTD declarations, if any.
|
||||
*
|
||||
* <p>Any declarations are assumed to be in the internal subset
|
||||
* unless otherwise indicated by a {@link #startEntity startEntity}
|
||||
* event.</p>
|
||||
* <p>This method is intended to report the beginning of the
|
||||
* DOCTYPE declaration; if the document has no DOCTYPE declaration,
|
||||
* 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
|
||||
* 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 publicId The declared public identifier for the
|
||||
* external DTD subset, or null if none was declared.
|
||||
* @param systemId The declared system identifier for the
|
||||
* 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.
|
||||
* @see #endDTD
|
||||
|
@ -73,6 +90,10 @@ public interface LexicalHandler
|
|||
/**
|
||||
* 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.
|
||||
* @see #startDTD
|
||||
*/
|
||||
|
@ -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
|
||||
* values -- and the start and end of the document entity --
|
||||
* are never reported.</p>
|
||||
* <p>The reporting of parameter entities (including
|
||||
* the external DTD subset) is optional, and SAX2 drivers that
|
||||
* 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
|
||||
* using the pseudo-name "[dtd]". All other events must be
|
||||
* properly nested within start/end entity events.</p>
|
||||
* <p>General entities are reported with their regular names,
|
||||
* parameter entities have '%' prepended to their names, and
|
||||
* 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
|
||||
* {@link org.xml.sax.ContentHandler#skippedEntity skippedEntity}
|
||||
* 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
|
||||
* 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.
|
||||
* @see #endEntity
|
||||
* @see org.xml.sax.ext.DeclHandler#internalEntityDecl
|
||||
|
@ -122,7 +170,8 @@ public interface LexicalHandler
|
|||
*
|
||||
* <p>The contents of the CDATA section will be reported through
|
||||
* 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.
|
||||
* @see #endCDATA
|
||||
|
@ -146,7 +195,9 @@ public interface LexicalHandler
|
|||
*
|
||||
* <p>This callback will be used for comments inside or outside the
|
||||
* 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 start The starting position in the array.
|
||||
|
|
49
libjava/org/xml/sax/ext/package.html
Normal file
49
libjava/org/xml/sax/ext/package.html
Normal file
|
@ -0,0 +1,49 @@
|
|||
<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>
|
|
@ -1,6 +1,7 @@
|
|||
// SAX default implementation for AttributeList.
|
||||
// http://www.saxproject.org
|
||||
// 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;
|
||||
|
||||
|
@ -15,6 +16,8 @@ import java.util.Vector;
|
|||
* <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>AttributeList implements the deprecated SAX1 {@link
|
||||
|
@ -55,9 +58,8 @@ import java.util.Vector;
|
|||
* {@link org.xml.sax.helpers.AttributesImpl
|
||||
* AttributesImpl} helper class.
|
||||
* @since SAX 1.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.AttributeList
|
||||
* @see org.xml.sax.DocumentHandler#startElement
|
||||
*/
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// 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.
|
||||
|
||||
// $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;
|
||||
|
@ -16,6 +17,8 @@ import org.xml.sax.Attributes;
|
|||
* <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 provides a default implementation of the SAX2
|
||||
|
@ -39,9 +42,8 @@ import org.xml.sax.Attributes;
|
|||
* implementation using a single array rather than a set of Vectors.</p>
|
||||
*
|
||||
* @since SAX 2.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
*/
|
||||
public class AttributesImpl implements Attributes
|
||||
{
|
||||
|
@ -320,12 +322,16 @@ public class AttributesImpl implements Attributes
|
|||
/**
|
||||
* Clear the attribute list for reuse.
|
||||
*
|
||||
* <p>Note that no memory is actually freed by this call:
|
||||
* the current arrays are kept so that they can be
|
||||
* <p>Note that little memory is freed by this call:
|
||||
* the current array is kept so it can be
|
||||
* reused.</p>
|
||||
*/
|
||||
public void clear ()
|
||||
{
|
||||
if (data != null) {
|
||||
for (int i = 0; i < (length * 5); i++)
|
||||
data [i] = null;
|
||||
}
|
||||
length = 0;
|
||||
}
|
||||
|
||||
|
@ -340,15 +346,17 @@ public class AttributesImpl implements Attributes
|
|||
*/
|
||||
public void setAttributes (Attributes atts)
|
||||
{
|
||||
clear();
|
||||
length = atts.getLength();
|
||||
data = new String[length*5];
|
||||
for (int i = 0; i < length; i++) {
|
||||
data[i*5] = atts.getURI(i);
|
||||
data[i*5+1] = atts.getLocalName(i);
|
||||
data[i*5+2] = atts.getQName(i);
|
||||
data[i*5+3] = atts.getType(i);
|
||||
data[i*5+4] = atts.getValue(i);
|
||||
clear();
|
||||
length = atts.getLength();
|
||||
if (length > 0) {
|
||||
data = new String[length*5];
|
||||
for (int i = 0; i < length; i++) {
|
||||
data[i*5] = atts.getURI(i);
|
||||
data[i*5+1] = atts.getLocalName(i);
|
||||
data[i*5+2] = atts.getQName(i);
|
||||
data[i*5+3] = atts.getType(i);
|
||||
data[i*5+4] = atts.getValue(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -430,15 +438,16 @@ public class AttributesImpl implements Attributes
|
|||
public void removeAttribute (int index)
|
||||
{
|
||||
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) {
|
||||
System.arraycopy(data, (index+1)*5, data, index*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--;
|
||||
} else {
|
||||
badIndex(index);
|
||||
|
@ -556,24 +565,29 @@ public class AttributesImpl implements Attributes
|
|||
* @param n The minimum number of attributes that the array must
|
||||
* be able to hold.
|
||||
*/
|
||||
private void ensureCapacity (int n)
|
||||
{
|
||||
if (n > 0 && data == null) {
|
||||
data = new String[25];
|
||||
}
|
||||
private void ensureCapacity (int n) {
|
||||
if (n <= 0) {
|
||||
return;
|
||||
}
|
||||
int max;
|
||||
if (data == null || data.length == 0) {
|
||||
max = 25;
|
||||
}
|
||||
else if (data.length >= n * 5) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
max = data.length;
|
||||
}
|
||||
while (max < n * 5) {
|
||||
max *= 2;
|
||||
}
|
||||
|
||||
int max = data.length;
|
||||
if (max >= n * 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
while (max < n * 5) {
|
||||
max *= 2;
|
||||
}
|
||||
String newData[] = new String[max];
|
||||
System.arraycopy(data, 0, newData, 0, length*5);
|
||||
data = newData;
|
||||
String newData[] = new String[max];
|
||||
if (length > 0) {
|
||||
System.arraycopy(data, 0, newData, 0, length*5);
|
||||
}
|
||||
data = newData;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
// 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.
|
||||
|
||||
// $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;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.Locator;
|
||||
import org.xml.sax.Attributes;
|
||||
|
@ -23,6 +26,8 @@ import org.xml.sax.SAXParseException;
|
|||
* <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 is available as a convenience base class for SAX2
|
||||
|
@ -46,8 +51,7 @@ import org.xml.sax.SAXParseException;
|
|||
*
|
||||
* @since SAX 2.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.EntityResolver
|
||||
* @see org.xml.sax.DTDHandler
|
||||
* @see org.xml.sax.ContentHandler
|
||||
|
@ -71,18 +75,20 @@ public class DefaultHandler
|
|||
* in a subclass to do special translations such as catalog lookups
|
||||
* 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.
|
||||
* @param systemId The system identifier provided in the XML
|
||||
* document.
|
||||
* @return The new input source, or null to require the
|
||||
* 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
|
||||
* wrapping another exception.
|
||||
* @see org.xml.sax.EntityResolver#resolveEntity
|
||||
*/
|
||||
public InputSource resolveEntity (String publicId, String systemId)
|
||||
throws SAXException
|
||||
throws IOException, SAXException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -248,8 +254,17 @@ public class DefaultHandler
|
|||
* each element (such as allocating a new tree node or writing
|
||||
* output to a file).</p>
|
||||
*
|
||||
* @param name The element type name.
|
||||
* @param attributes The specified or defaulted attributes.
|
||||
* @param uri The Namespace URI, or the empty string if the
|
||||
* 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
|
||||
* wrapping another exception.
|
||||
* @see org.xml.sax.ContentHandler#startElement
|
||||
|
@ -270,8 +285,14 @@ public class DefaultHandler
|
|||
* each element (such as finalising a tree node or writing
|
||||
* output to a file).</p>
|
||||
*
|
||||
* @param name The element type name.
|
||||
* @param attributes The specified or defaulted attributes.
|
||||
* @param uri The Namespace URI, or the empty string if the
|
||||
* 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
|
||||
* wrapping another exception.
|
||||
* @see org.xml.sax.ContentHandler#endElement
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SAX default implementation for Locator.
|
||||
// http://www.saxproject.org
|
||||
// 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;
|
||||
|
||||
|
@ -13,6 +14,8 @@ import org.xml.sax.Locator;
|
|||
* <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 is available mainly for application writers, who
|
||||
|
@ -42,9 +45,8 @@ import org.xml.sax.Locator;
|
|||
* requested, rather than constantly updating a Locator object.</p>
|
||||
*
|
||||
* @since SAX 1.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.Locator Locator
|
||||
*/
|
||||
public class LocatorImpl implements Locator
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// NamespaceSupport.java - generic Namespace support for SAX.
|
||||
// Written by David Megginson, sax@megginson.com
|
||||
// http://www.saxproject.org
|
||||
// Written by David Megginson
|
||||
// This class is in the Public Domain. NO WARRANTY!
|
||||
|
||||
// $Id: NamespaceSupport.java,v 1.1 2000/10/02 02:43:20 sboag Exp $
|
||||
// $Id: NamespaceSupport.java,v 1.6.2.5 2002/01/29 21:34:14 dbrownell Exp $
|
||||
|
||||
package org.xml.sax.helpers;
|
||||
|
||||
|
@ -13,11 +14,14 @@ import java.util.Vector;
|
|||
|
||||
|
||||
/**
|
||||
* Encapsulate Namespace logic for use by SAX drivers.
|
||||
* Encapsulate Namespace logic for use by applications using SAX,
|
||||
* or internally by SAX drivers.
|
||||
*
|
||||
* <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 encapsulates the logic of Namespace processing:
|
||||
|
@ -39,16 +43,16 @@ import java.util.Vector;
|
|||
* support.declarePrefix("", "http://www.w3.org/1999/xhtml");
|
||||
* support.declarePrefix("dc", "http://www.purl.org/dc#");
|
||||
*
|
||||
* String parts[] = support.processName("p", parts, false);
|
||||
* parts = support.processName("p", parts, false);
|
||||
* System.out.println("Namespace URI: " + parts[0]);
|
||||
* System.out.println("Local name: " + parts[1]);
|
||||
* System.out.println("Raw name: " + parts[2]);
|
||||
|
||||
* String parts[] = support.processName("dc:title", parts, false);
|
||||
*
|
||||
* parts = support.processName("dc:title", parts, false);
|
||||
* System.out.println("Namespace URI: " + parts[0]);
|
||||
* System.out.println("Local name: " + parts[1]);
|
||||
* System.out.println("Raw name: " + parts[2]);
|
||||
|
||||
*
|
||||
* support.popContext();
|
||||
* </pre>
|
||||
*
|
||||
|
@ -57,10 +61,14 @@ import java.util.Vector;
|
|||
* prefix/URI mapping is repeated for each context (for example), this
|
||||
* class will be somewhat less efficient.</p>
|
||||
*
|
||||
* <p>Although SAX drivers (parsers) may choose to use this class to
|
||||
* implement namespace handling, they are not required to do so.
|
||||
* Applications must track namespace information themselves if they
|
||||
* want to use namespace information.
|
||||
*
|
||||
* @since SAX 2.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
*/
|
||||
public class NamespaceSupport
|
||||
{
|
||||
|
@ -72,7 +80,9 @@ public class NamespaceSupport
|
|||
|
||||
|
||||
/**
|
||||
* The XML Namespace as a constant.
|
||||
* The XML Namespace URI as a constant.
|
||||
* The value is <code>http://www.w3.org/XML/1998/namespace</code>
|
||||
* as defined in the XML Namespaces specification.
|
||||
*
|
||||
* <p>This is the Namespace URI that is automatically mapped
|
||||
* to the "xml" prefix.</p>
|
||||
|
@ -125,21 +135,45 @@ public class NamespaceSupport
|
|||
|
||||
/**
|
||||
* Start a new Namespace context.
|
||||
*
|
||||
* <p>Normally, you should push a new context at the beginning
|
||||
* of each XML element: the new context will automatically inherit
|
||||
* The new context will automatically inherit
|
||||
* the declarations of its parent context, but it will also keep
|
||||
* track of which declarations were made within this context.</p>
|
||||
* track of which declarations were made within this context.
|
||||
*
|
||||
* <p>Event callback code should start a new context once per element.
|
||||
* This means being ready to call this in either of two places.
|
||||
* For elements that don't include namespace declarations, the
|
||||
* <em>ContentHandler.startElement()</em> callback is the right place.
|
||||
* For elements with such a declaration, it'd done in the first
|
||||
* <em>ContentHandler.startPrefixMapping()</em> callback.
|
||||
* A boolean flag can be used to
|
||||
* track whether a context has been started yet. When either of
|
||||
* those methods is called, it checks the flag to see if a new context
|
||||
* needs to be started. If so, it starts the context and sets the
|
||||
* flag. After <em>ContentHandler.startElement()</em>
|
||||
* does that, it always clears the flag.
|
||||
*
|
||||
* <p>Normally, SAX drivers would push a new context at the beginning
|
||||
* of each XML element. Then they perform a first pass over the
|
||||
* attributes to process all namespace declarations, making
|
||||
* <em>ContentHandler.startPrefixMapping()</em> callbacks.
|
||||
* Then a second pass is made, to determine the namespace-qualified
|
||||
* names for all attributes and for the element name.
|
||||
* Finally all the information for the
|
||||
* <em>ContentHandler.startElement()</em> callback is available,
|
||||
* so it can then be made.
|
||||
*
|
||||
* <p>The Namespace support object always starts with a base context
|
||||
* already in force: in this context, only the "xml" prefix is
|
||||
* declared.</p>
|
||||
*
|
||||
* @see org.xml.sax.ContentHandler
|
||||
* @see #popContext
|
||||
*/
|
||||
public void pushContext ()
|
||||
{
|
||||
int max = contexts.length;
|
||||
|
||||
contexts [contextPos].declsOK = false;
|
||||
contextPos++;
|
||||
|
||||
// Extend the array if necessary
|
||||
|
@ -178,6 +212,7 @@ public class NamespaceSupport
|
|||
*/
|
||||
public void popContext ()
|
||||
{
|
||||
contexts[contextPos].clear();
|
||||
contextPos--;
|
||||
if (contextPos < 0) {
|
||||
throw new EmptyStackException();
|
||||
|
@ -193,29 +228,42 @@ public class NamespaceSupport
|
|||
|
||||
|
||||
/**
|
||||
* Declare a Namespace prefix.
|
||||
* Declare a Namespace prefix. All prefixes must be declared
|
||||
* before they are referenced. For example, a SAX driver (parser)
|
||||
* would scan an element's attributes
|
||||
* in two passes: first for namespace declarations,
|
||||
* then a second pass using {@link #processName processName()} to
|
||||
* interpret prefixes against (potentially redefined) prefixes.
|
||||
*
|
||||
* <p>This method declares a prefix in the current Namespace
|
||||
* context; the prefix will remain in force until this context
|
||||
* is popped, unless it is shadowed in a descendant context.</p>
|
||||
*
|
||||
* <p>To declare a default Namespace, use the empty string. The
|
||||
* prefix must not be "xml" or "xmlns".</p>
|
||||
* <p>To declare the default element Namespace, use the empty string as
|
||||
* the prefix.</p>
|
||||
*
|
||||
* <p>Note that you must <em>not</em> declare a prefix after
|
||||
* you've pushed and popped another Namespace.</p>
|
||||
* you've pushed and popped another Namespace context, or
|
||||
* treated the declarations phase as complete by processing
|
||||
* a prefixed name.</p>
|
||||
*
|
||||
* <p>Note that there is an asymmetry in this library: while {@link
|
||||
* #getPrefix getPrefix} will not return the default "" prefix,
|
||||
* even if you have declared one; to check for a default prefix,
|
||||
* <p>Note that there is an asymmetry in this library: {@link
|
||||
* #getPrefix getPrefix} will not return the "" prefix,
|
||||
* even if you have declared a default element namespace.
|
||||
* To check for a default namespace,
|
||||
* you have to look it up explicitly using {@link #getURI getURI}.
|
||||
* This asymmetry exists to make it easier to look up prefixes
|
||||
* for attribute names, where the default prefix is not allowed.</p>
|
||||
*
|
||||
* @param prefix The prefix to declare, or null for the empty
|
||||
* string.
|
||||
* @param prefix The prefix to declare, or the empty string to
|
||||
* indicate the default element namespace. This may never have
|
||||
* the value "xml" or "xmlns".
|
||||
* @param uri The Namespace URI to associate with the prefix.
|
||||
* @return true if the prefix was legal, false otherwise
|
||||
* @exception IllegalStateException when a prefix is declared
|
||||
* after looking up a name in the context, or after pushing
|
||||
* another context on top of it.
|
||||
*
|
||||
* @see #processName
|
||||
* @see #getURI
|
||||
* @see #getPrefix
|
||||
|
@ -232,7 +280,8 @@ public class NamespaceSupport
|
|||
|
||||
|
||||
/**
|
||||
* Process a raw XML 1.0 name.
|
||||
* Process a raw XML 1.0 name, after all declarations in the current
|
||||
* context have been handled by {@link #declarePrefix declarePrefix()}.
|
||||
*
|
||||
* <p>This method processes a raw XML 1.0 name in the current
|
||||
* context by removing the prefix and looking it up among the
|
||||
|
@ -255,7 +304,7 @@ public class NamespaceSupport
|
|||
*
|
||||
* <p>Note that attribute names are processed differently than
|
||||
* element names: an unprefixed element name will received the
|
||||
* default Namespace (if any), while an unprefixed element name
|
||||
* default Namespace (if any), while an unprefixed attribute name
|
||||
* will not.</p>
|
||||
*
|
||||
* @param qName The raw XML 1.0 name to be processed.
|
||||
|
@ -419,9 +468,14 @@ public class NamespaceSupport
|
|||
/**
|
||||
* Internal class for a single Namespace context.
|
||||
*
|
||||
* <p>This module caches and reuses Namespace contexts, so the number allocated
|
||||
* <p>This module caches and reuses Namespace contexts,
|
||||
* so the number allocated
|
||||
* will be equal to the element depth of the document, not to the total
|
||||
* number of elements (i.e. 5-10 rather than tens of thousands).</p>
|
||||
* number of elements (i.e. 5-10 rather than tens of thousands).
|
||||
* Also, data structures used to represent contexts are shared when
|
||||
* possible (child contexts without declarations) to further reduce
|
||||
* the amount of memory that's consumed.
|
||||
* </p>
|
||||
*/
|
||||
final class Context {
|
||||
|
||||
|
@ -436,6 +490,8 @@ public class NamespaceSupport
|
|||
|
||||
/**
|
||||
* (Re)set the parent of this Namespace context.
|
||||
* The context must either have been freshly constructed,
|
||||
* or must have been cleared.
|
||||
*
|
||||
* @param context The parent Namespace context object.
|
||||
*/
|
||||
|
@ -448,7 +504,24 @@ public class NamespaceSupport
|
|||
elementNameTable = parent.elementNameTable;
|
||||
attributeNameTable = parent.attributeNameTable;
|
||||
defaultNS = parent.defaultNS;
|
||||
tablesDirty = false;
|
||||
declSeen = false;
|
||||
declsOK = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes associated state become collectible,
|
||||
* invalidating this context.
|
||||
* {@link #setParent} must be called before
|
||||
* this context may be used again.
|
||||
*/
|
||||
void clear ()
|
||||
{
|
||||
parent = null;
|
||||
prefixTable = null;
|
||||
uriTable = null;
|
||||
elementNameTable = null;
|
||||
attributeNameTable = null;
|
||||
defaultNS = null;
|
||||
}
|
||||
|
||||
|
||||
|
@ -462,7 +535,10 @@ public class NamespaceSupport
|
|||
void declarePrefix (String prefix, String uri)
|
||||
{
|
||||
// Lazy processing...
|
||||
if (!tablesDirty) {
|
||||
if (!declsOK)
|
||||
throw new IllegalStateException (
|
||||
"can't declare any more prefixes in this context");
|
||||
if (!declSeen) {
|
||||
copyTables();
|
||||
}
|
||||
if (declarations == null) {
|
||||
|
@ -501,11 +577,14 @@ public class NamespaceSupport
|
|||
String name[];
|
||||
Hashtable table;
|
||||
|
||||
// detect errors in call sequence
|
||||
declsOK = false;
|
||||
|
||||
// Select the appropriate table.
|
||||
if (isAttribute) {
|
||||
table = elementNameTable;
|
||||
} else {
|
||||
table = attributeNameTable;
|
||||
} else {
|
||||
table = elementNameTable;
|
||||
}
|
||||
|
||||
// Start by looking in the cache, and
|
||||
|
@ -517,8 +596,11 @@ public class NamespaceSupport
|
|||
}
|
||||
|
||||
// We haven't seen this name in this
|
||||
// context before.
|
||||
// context before. Maybe in the parent
|
||||
// context, but we can't assume prefix
|
||||
// bindings are the same.
|
||||
name = new String[3];
|
||||
name[2] = qName.intern();
|
||||
int index = qName.indexOf(':');
|
||||
|
||||
|
||||
|
@ -529,8 +611,7 @@ public class NamespaceSupport
|
|||
} else {
|
||||
name[0] = defaultNS;
|
||||
}
|
||||
name[1] = qName.intern();
|
||||
name[2] = name[1];
|
||||
name[1] = name[2];
|
||||
}
|
||||
|
||||
// Prefix
|
||||
|
@ -548,12 +629,11 @@ public class NamespaceSupport
|
|||
}
|
||||
name[0] = uri;
|
||||
name[1] = local.intern();
|
||||
name[2] = qName.intern();
|
||||
}
|
||||
|
||||
// Save in the cache for future use.
|
||||
// (Could be shared with parent context...)
|
||||
table.put(name[2], name);
|
||||
tablesDirty = true;
|
||||
return name;
|
||||
}
|
||||
|
||||
|
@ -659,7 +739,7 @@ public class NamespaceSupport
|
|||
}
|
||||
elementNameTable = new Hashtable();
|
||||
attributeNameTable = new Hashtable();
|
||||
tablesDirty = true;
|
||||
declSeen = true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -673,6 +753,7 @@ public class NamespaceSupport
|
|||
Hashtable elementNameTable;
|
||||
Hashtable attributeNameTable;
|
||||
String defaultNS = null;
|
||||
boolean declsOK = true;
|
||||
|
||||
|
||||
|
||||
|
@ -681,7 +762,7 @@ public class NamespaceSupport
|
|||
////////////////////////////////////////////////////////////////
|
||||
|
||||
private Vector declarations = null;
|
||||
private boolean tablesDirty = false;
|
||||
private boolean declSeen = false;
|
||||
private Context parent = null;
|
||||
}
|
||||
}
|
||||
|
|
80
libjava/org/xml/sax/helpers/NewInstance.java
Normal file
80
libjava/org/xml/sax/helpers/NewInstance.java
Normal file
|
@ -0,0 +1,80 @@
|
|||
// 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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,15 @@
|
|||
// ParserAdapter.java - adapt a SAX1 Parser to a SAX2 XMLReader.
|
||||
// Written by David Megginson, sax@megginson.com
|
||||
// http://www.saxproject.org
|
||||
// Written by David Megginson
|
||||
// NO WARRANTY! This class is in the public domain.
|
||||
|
||||
// $Id: ParserAdapter.java,v 1.1 2000/10/02 02:43:20 sboag Exp $
|
||||
// $Id: ParserAdapter.java,v 1.8.2.4 2002/01/29 21:34:14 dbrownell Exp $
|
||||
|
||||
package org.xml.sax.helpers;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.xml.sax.Parser; // deprecated
|
||||
import org.xml.sax.InputSource;
|
||||
|
@ -33,6 +35,8 @@ import org.xml.sax.SAXNotSupportedException;
|
|||
* <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 wraps a SAX1 {@link org.xml.sax.Parser Parser}
|
||||
|
@ -45,9 +49,8 @@ import org.xml.sax.SAXNotSupportedException;
|
|||
* attribute names.</p>
|
||||
*
|
||||
* @since SAX 2.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.helpers.XMLReaderAdapter
|
||||
* @see org.xml.sax.XMLReader
|
||||
* @see org.xml.sax.Parser
|
||||
|
@ -67,7 +70,7 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
* <p>Use the "org.xml.sax.parser" property to locate the
|
||||
* embedded SAX1 driver.</p>
|
||||
*
|
||||
* @exception org.xml.sax.SAXException If the embedded driver
|
||||
* @exception SAXException If the embedded driver
|
||||
* cannot be instantiated or if the
|
||||
* org.xml.sax.parser property is not specified.
|
||||
*/
|
||||
|
@ -156,46 +159,37 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
private final static String FEATURES = "http://xml.org/sax/features/";
|
||||
private final static String NAMESPACES = FEATURES + "namespaces";
|
||||
private final static String NAMESPACE_PREFIXES = FEATURES + "namespace-prefixes";
|
||||
private final static String VALIDATION = FEATURES + "validation";
|
||||
private final static String EXTERNAL_GENERAL =
|
||||
FEATURES + "external-general-entities";
|
||||
private final static String EXTERNAL_PARAMETER =
|
||||
FEATURES + "external-parameter-entities";
|
||||
|
||||
|
||||
/**
|
||||
* Set a feature for the parser.
|
||||
* Set a feature flag for the parser.
|
||||
*
|
||||
* <p>The only features supported are namespaces and
|
||||
* <p>The only features recognized are namespaces and
|
||||
* namespace-prefixes.</p>
|
||||
*
|
||||
* @param name The feature name, as a complete URI.
|
||||
* @param state The requested feature state.
|
||||
* @exception org.xml.sax.SAXNotRecognizedException If the feature
|
||||
* name is not known.
|
||||
* @exception org.xml.sax.SAXNotSupportedException If the feature
|
||||
* state is not supported.
|
||||
* @param value The requested feature value.
|
||||
* @exception SAXNotRecognizedException If the feature
|
||||
* can't be assigned or retrieved.
|
||||
* @exception SAXNotSupportedException If the feature
|
||||
* can't be assigned that value.
|
||||
* @see org.xml.sax.XMLReader#setFeature
|
||||
*/
|
||||
public void setFeature (String name, boolean state)
|
||||
public void setFeature (String name, boolean value)
|
||||
throws SAXNotRecognizedException, SAXNotSupportedException
|
||||
{
|
||||
if (name.equals(NAMESPACES)) {
|
||||
checkNotParsing("feature", name);
|
||||
namespaces = state;
|
||||
namespaces = value;
|
||||
if (!namespaces && !prefixes) {
|
||||
prefixes = true;
|
||||
}
|
||||
} else if (name.equals(NAMESPACE_PREFIXES)) {
|
||||
checkNotParsing("feature", name);
|
||||
prefixes = state;
|
||||
prefixes = value;
|
||||
if (!prefixes && !namespaces) {
|
||||
namespaces = true;
|
||||
}
|
||||
} else if (name.equals(VALIDATION) ||
|
||||
name.equals(EXTERNAL_GENERAL) ||
|
||||
name.equals(EXTERNAL_PARAMETER)) {
|
||||
throw new SAXNotSupportedException("Feature: " + name);
|
||||
} else {
|
||||
throw new SAXNotRecognizedException("Feature: " + name);
|
||||
}
|
||||
|
@ -203,17 +197,17 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
|
||||
|
||||
/**
|
||||
* Check a parser feature.
|
||||
* Check a parser feature flag.
|
||||
*
|
||||
* <p>The only features supported are namespaces and
|
||||
* <p>The only features recognized are namespaces and
|
||||
* namespace-prefixes.</p>
|
||||
*
|
||||
* @param name The feature name, as a complete URI.
|
||||
* @return The current feature state.
|
||||
* @exception org.xml.sax.SAXNotRecognizedException If the feature
|
||||
* name is not known.
|
||||
* @exception org.xml.sax.SAXNotSupportedException If querying the
|
||||
* feature state is not supported.
|
||||
* @return The current feature value.
|
||||
* @exception SAXNotRecognizedException If the feature
|
||||
* value can't be assigned or retrieved.
|
||||
* @exception SAXNotSupportedException If the
|
||||
* feature is not currently readable.
|
||||
* @see org.xml.sax.XMLReader#setFeature
|
||||
*/
|
||||
public boolean getFeature (String name)
|
||||
|
@ -223,10 +217,6 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
return namespaces;
|
||||
} else if (name.equals(NAMESPACE_PREFIXES)) {
|
||||
return prefixes;
|
||||
} else if (name.equals(VALIDATION) ||
|
||||
name.equals(EXTERNAL_GENERAL) ||
|
||||
name.equals(EXTERNAL_PARAMETER)) {
|
||||
throw new SAXNotSupportedException("Feature: " + name);
|
||||
} else {
|
||||
throw new SAXNotRecognizedException("Feature: " + name);
|
||||
}
|
||||
|
@ -236,14 +226,14 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
/**
|
||||
* Set a parser property.
|
||||
*
|
||||
* <p>No special properties are currently supported.</p>
|
||||
* <p>No properties are currently recognized.</p>
|
||||
*
|
||||
* @param name The property name.
|
||||
* @param value The property value.
|
||||
* @exception org.xml.sax.SAXNotRecognizedException If the feature
|
||||
* name is not known.
|
||||
* @exception org.xml.sax.SAXNotSupportedException If the feature
|
||||
* state is not supported.
|
||||
* @exception SAXNotRecognizedException If the property
|
||||
* value can't be assigned or retrieved.
|
||||
* @exception SAXNotSupportedException If the property
|
||||
* can't be assigned that value.
|
||||
* @see org.xml.sax.XMLReader#setProperty
|
||||
*/
|
||||
public void setProperty (String name, Object value)
|
||||
|
@ -256,14 +246,14 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
/**
|
||||
* Get a parser property.
|
||||
*
|
||||
* <p>No special properties are currently supported.</p>
|
||||
* <p>No properties are currently recognized.</p>
|
||||
*
|
||||
* @param name The property name.
|
||||
* @return The property value.
|
||||
* @exception org.xml.sax.SAXNotRecognizedException If the feature
|
||||
* name is not known.
|
||||
* @exception org.xml.sax.SAXNotSupportedException If the feature
|
||||
* state is not supported.
|
||||
* @exception SAXNotRecognizedException If the property
|
||||
* value can't be assigned or retrieved.
|
||||
* @exception SAXNotSupportedException If the property
|
||||
* value is not currently readable.
|
||||
* @see org.xml.sax.XMLReader#getProperty
|
||||
*/
|
||||
public Object getProperty (String name)
|
||||
|
@ -277,15 +267,10 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
* Set the entity resolver.
|
||||
*
|
||||
* @param resolver The new entity resolver.
|
||||
* @exception java.lang.NullPointerException If the entity resolver
|
||||
* parameter is null.
|
||||
* @see org.xml.sax.XMLReader#setEntityResolver
|
||||
*/
|
||||
public void setEntityResolver (EntityResolver resolver)
|
||||
{
|
||||
if (resolver == null) {
|
||||
throw new NullPointerException("Null entity resolver");
|
||||
}
|
||||
entityResolver = resolver;
|
||||
}
|
||||
|
||||
|
@ -306,15 +291,10 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
* Set the DTD handler.
|
||||
*
|
||||
* @param resolver The new DTD handler.
|
||||
* @exception java.lang.NullPointerException If the DTD handler
|
||||
* parameter is null.
|
||||
* @see org.xml.sax.XMLReader#setEntityResolver
|
||||
*/
|
||||
public void setDTDHandler (DTDHandler handler)
|
||||
{
|
||||
if (handler == null) {
|
||||
throw new NullPointerException("Null DTD handler");
|
||||
}
|
||||
dtdHandler = handler;
|
||||
}
|
||||
|
||||
|
@ -335,15 +315,10 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
* Set the content handler.
|
||||
*
|
||||
* @param resolver The new content handler.
|
||||
* @exception java.lang.NullPointerException If the content handler
|
||||
* parameter is null.
|
||||
* @see org.xml.sax.XMLReader#setEntityResolver
|
||||
*/
|
||||
public void setContentHandler (ContentHandler handler)
|
||||
{
|
||||
if (handler == null) {
|
||||
throw new NullPointerException("Null content handler");
|
||||
}
|
||||
contentHandler = handler;
|
||||
}
|
||||
|
||||
|
@ -364,15 +339,10 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
* Set the error handler.
|
||||
*
|
||||
* @param resolver The new error handler.
|
||||
* @exception java.lang.NullPointerException If the error handler
|
||||
* parameter is null.
|
||||
* @see org.xml.sax.XMLReader#setEntityResolver
|
||||
*/
|
||||
public void setErrorHandler (ErrorHandler handler)
|
||||
{
|
||||
if (handler == null) {
|
||||
throw new NullPointerException("Null error handler");
|
||||
}
|
||||
errorHandler = handler;
|
||||
}
|
||||
|
||||
|
@ -395,7 +365,7 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
* @param systemId The absolute URL of the document.
|
||||
* @exception java.io.IOException If there is a problem reading
|
||||
* the raw content of the document.
|
||||
* @exception org.xml.sax.SAXException If there is a problem
|
||||
* @exception SAXException If there is a problem
|
||||
* processing the document.
|
||||
* @see #parse(org.xml.sax.InputSource)
|
||||
* @see org.xml.sax.Parser#parse(java.lang.String)
|
||||
|
@ -413,7 +383,7 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
* @param input An input source for the document.
|
||||
* @exception java.io.IOException If there is a problem reading
|
||||
* the raw content of the document.
|
||||
* @exception org.xml.sax.SAXException If there is a problem
|
||||
* @exception SAXException If there is a problem
|
||||
* processing the document.
|
||||
* @see #parse(java.lang.String)
|
||||
* @see org.xml.sax.Parser#parse(org.xml.sax.InputSource)
|
||||
|
@ -442,6 +412,7 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
|
||||
|
||||
/**
|
||||
* Adapter implementation method; do not call.
|
||||
* Adapt a SAX1 document locator event.
|
||||
*
|
||||
* @param locator A document locator.
|
||||
|
@ -457,9 +428,10 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
|
||||
|
||||
/**
|
||||
* Adapter implementation method; do not call.
|
||||
* Adapt a SAX1 start document event.
|
||||
*
|
||||
* @exception org.xml.sax.SAXException The client may raise a
|
||||
* @exception SAXException The client may raise a
|
||||
* processing exception.
|
||||
* @see org.xml.sax.DocumentHandler#startDocument
|
||||
*/
|
||||
|
@ -473,9 +445,10 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
|
||||
|
||||
/**
|
||||
* Adapter implementation method; do not call.
|
||||
* Adapt a SAX1 end document event.
|
||||
*
|
||||
* @exception org.xml.sax.SAXException The client may raise a
|
||||
* @exception SAXException The client may raise a
|
||||
* processing exception.
|
||||
* @see org.xml.sax.DocumentHandler#endDocument
|
||||
*/
|
||||
|
@ -489,16 +462,25 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
|
||||
|
||||
/**
|
||||
* Adapter implementation method; do not call.
|
||||
* Adapt a SAX1 startElement event.
|
||||
*
|
||||
* <p>If necessary, perform Namespace processing.</p>
|
||||
*
|
||||
* @param qName The qualified (prefixed) name.
|
||||
* @param qAtts The XML 1.0 attribute list (with qnames).
|
||||
* @exception SAXException The client may raise a
|
||||
* processing exception.
|
||||
*/
|
||||
public void startElement (String qName, AttributeList qAtts)
|
||||
throws SAXException
|
||||
{
|
||||
// These are exceptions from the
|
||||
// first pass; they should be
|
||||
// ignored if there's a second pass,
|
||||
// but reported otherwise.
|
||||
Vector exceptions = null;
|
||||
|
||||
// If we're not doing Namespace
|
||||
// processing, dispatch this quickly.
|
||||
if (!namespaces) {
|
||||
|
@ -513,80 +495,103 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
|
||||
// OK, we're doing Namespace processing.
|
||||
nsSupport.pushContext();
|
||||
boolean seenDecl = false;
|
||||
atts.clear();
|
||||
|
||||
// Take a first pass and copy all
|
||||
// attributes into the SAX2 attribute
|
||||
// list, noting any Namespace
|
||||
// declarations.
|
||||
int length = qAtts.getLength();
|
||||
|
||||
// First pass: handle NS decls
|
||||
for (int i = 0; i < length; i++) {
|
||||
String attQName = qAtts.getName(i);
|
||||
|
||||
if (!attQName.startsWith("xmlns"))
|
||||
continue;
|
||||
// Could be a declaration...
|
||||
String prefix;
|
||||
int n = attQName.indexOf(':');
|
||||
|
||||
// xmlns=...
|
||||
if (n == -1 && attQName.length () == 5) {
|
||||
prefix = "";
|
||||
} else if (n != 5) {
|
||||
// XML namespaces spec doesn't discuss "xmlnsf:oo"
|
||||
// (and similarly named) attributes ... at most, warn
|
||||
continue;
|
||||
} else // xmlns:foo=...
|
||||
prefix = attQName.substring(n+1);
|
||||
|
||||
String value = qAtts.getValue(i);
|
||||
if (!nsSupport.declarePrefix(prefix, value)) {
|
||||
reportError("Illegal Namespace prefix: " + prefix);
|
||||
continue;
|
||||
}
|
||||
if (contentHandler != null)
|
||||
contentHandler.startPrefixMapping(prefix, value);
|
||||
}
|
||||
|
||||
// Second pass: copy all relevant
|
||||
// attributes into the SAX2 AttributeList
|
||||
// using updated prefix bindings
|
||||
atts.clear();
|
||||
for (int i = 0; i < length; i++) {
|
||||
String attQName = qAtts.getName(i);
|
||||
String type = qAtts.getType(i);
|
||||
String value = qAtts.getValue(i);
|
||||
|
||||
// Found a declaration...
|
||||
// Declaration?
|
||||
if (attQName.startsWith("xmlns")) {
|
||||
String prefix;
|
||||
int n = attQName.indexOf(':');
|
||||
if (n == -1) {
|
||||
|
||||
if (n == -1 && attQName.length () == 5) {
|
||||
prefix = "";
|
||||
} else if (n != 5) {
|
||||
// XML namespaces spec doesn't discuss "xmlnsf:oo"
|
||||
// (and similarly named) attributes ... ignore
|
||||
prefix = null;
|
||||
} else {
|
||||
prefix = attQName.substring(n+1);
|
||||
}
|
||||
if (!nsSupport.declarePrefix(prefix, value)) {
|
||||
reportError("Illegal Namespace prefix: " + prefix);
|
||||
}
|
||||
if (contentHandler != null) {
|
||||
contentHandler.startPrefixMapping(prefix, value);
|
||||
}
|
||||
// We may still have to add this to
|
||||
// the list.
|
||||
if (prefixes) {
|
||||
atts.addAttribute("", "", attQName.intern(),
|
||||
// Yes, decl: report or prune
|
||||
if (prefix != null) {
|
||||
if (prefixes)
|
||||
atts.addAttribute("", "", attQName.intern(),
|
||||
type, value);
|
||||
continue;
|
||||
}
|
||||
seenDecl = true;
|
||||
}
|
||||
|
||||
// This isn't a declaration.
|
||||
} else {
|
||||
String attName[] = processName(attQName, true);
|
||||
// Not a declaration -- report
|
||||
try {
|
||||
String attName[] = processName(attQName, true, true);
|
||||
atts.addAttribute(attName[0], attName[1], attName[2],
|
||||
type, value);
|
||||
} catch (SAXException e) {
|
||||
if (exceptions == null)
|
||||
exceptions = new Vector();
|
||||
exceptions.addElement(e);
|
||||
atts.addAttribute("", attQName, attQName, type, value);
|
||||
}
|
||||
}
|
||||
|
||||
// If there was a Namespace declaration,
|
||||
// we have to make a second pass just
|
||||
// to be safe -- this will happen very
|
||||
// rarely, possibly only once for each
|
||||
// document.
|
||||
if (seenDecl) {
|
||||
length = atts.getLength();
|
||||
for (int i = 0; i < length; i++) {
|
||||
String attQName = atts.getQName(i);
|
||||
if (!attQName.startsWith("xmlns")) {
|
||||
String attName[] = processName(attQName, true);
|
||||
atts.setURI(i, attName[0]);
|
||||
atts.setLocalName(i, attName[1]);
|
||||
}
|
||||
}
|
||||
// now handle the deferred exception reports
|
||||
if (exceptions != null && errorHandler != null) {
|
||||
for (int i = 0; i < exceptions.size(); i++)
|
||||
errorHandler.error((SAXParseException)
|
||||
(exceptions.elementAt(i)));
|
||||
}
|
||||
|
||||
// OK, finally report the event.
|
||||
if (contentHandler != null) {
|
||||
String name[] = processName(qName, false);
|
||||
String name[] = processName(qName, false, false);
|
||||
contentHandler.startElement(name[0], name[1], name[2], atts);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adapter implementation method; do not call.
|
||||
* Adapt a SAX1 end element event.
|
||||
*
|
||||
* @param qName The qualified (prefixed) name.
|
||||
* @exception org.xml.sax.SAXException The client may raise a
|
||||
* @exception SAXException The client may raise a
|
||||
* processing exception.
|
||||
* @see org.xml.sax.DocumentHandler#endElement
|
||||
*/
|
||||
|
@ -603,7 +608,7 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
}
|
||||
|
||||
// Split the name.
|
||||
String names[] = processName(qName, false);
|
||||
String names[] = processName(qName, false, false);
|
||||
if (contentHandler != null) {
|
||||
contentHandler.endElement(names[0], names[1], names[2]);
|
||||
Enumeration prefixes = nsSupport.getDeclaredPrefixes();
|
||||
|
@ -617,12 +622,13 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
|
||||
|
||||
/**
|
||||
* Adapter implementation method; do not call.
|
||||
* Adapt a SAX1 characters event.
|
||||
*
|
||||
* @param ch An array of characters.
|
||||
* @param start The starting position in the array.
|
||||
* @param length The number of characters to use.
|
||||
* @exception org.xml.sax.SAXException The client may raise a
|
||||
* @exception SAXException The client may raise a
|
||||
* processing exception.
|
||||
* @see org.xml.sax.DocumentHandler#characters
|
||||
*/
|
||||
|
@ -636,12 +642,13 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
|
||||
|
||||
/**
|
||||
* Adapter implementation method; do not call.
|
||||
* Adapt a SAX1 ignorable whitespace event.
|
||||
*
|
||||
* @param ch An array of characters.
|
||||
* @param start The starting position in the array.
|
||||
* @param length The number of characters to use.
|
||||
* @exception org.xml.sax.SAXException The client may raise a
|
||||
* @exception SAXException The client may raise a
|
||||
* processing exception.
|
||||
* @see org.xml.sax.DocumentHandler#ignorableWhitespace
|
||||
*/
|
||||
|
@ -655,11 +662,12 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
|
||||
|
||||
/**
|
||||
* Adapter implementation method; do not call.
|
||||
* Adapt a SAX1 processing instruction event.
|
||||
*
|
||||
* @param target The processing instruction target.
|
||||
* @param data The remainder of the processing instruction
|
||||
* @exception org.xml.sax.SAXException The client may raise a
|
||||
* @exception SAXException The client may raise a
|
||||
* processing exception.
|
||||
* @see org.xml.sax.DocumentHandler#processingInstruction
|
||||
*/
|
||||
|
@ -709,18 +717,22 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
* @param qName The qualified (prefixed) name.
|
||||
* @param isAttribute true if this is an attribute name.
|
||||
* @return The name split into three parts.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* @exception SAXException The client may throw
|
||||
* an exception if there is an error callback.
|
||||
*/
|
||||
private String [] processName (String qName, boolean isAttribute)
|
||||
private String [] processName (String qName, boolean isAttribute,
|
||||
boolean useException)
|
||||
throws SAXException
|
||||
{
|
||||
String parts[] = nsSupport.processName(qName, nameParts,
|
||||
isAttribute);
|
||||
if (parts == null) {
|
||||
parts = new String[3];
|
||||
parts[2] = qName.intern();
|
||||
if (useException)
|
||||
throw makeException("Undeclared prefix: " + qName);
|
||||
reportError("Undeclared prefix: " + qName);
|
||||
parts = new String[3];
|
||||
parts[0] = parts[1] = "";
|
||||
parts[2] = qName.intern();
|
||||
}
|
||||
return parts;
|
||||
}
|
||||
|
@ -730,23 +742,29 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
* Report a non-fatal error.
|
||||
*
|
||||
* @param message The error message.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* @exception SAXException The client may throw
|
||||
* an exception.
|
||||
*/
|
||||
void reportError (String message)
|
||||
throws SAXException
|
||||
{
|
||||
if (errorHandler == null) {
|
||||
return;
|
||||
}
|
||||
if (errorHandler != null)
|
||||
errorHandler.error(makeException(message));
|
||||
}
|
||||
|
||||
SAXParseException e;
|
||||
|
||||
/**
|
||||
* Construct an exception for the current context.
|
||||
*
|
||||
* @param message The error message.
|
||||
*/
|
||||
private SAXParseException makeException (String message)
|
||||
{
|
||||
if (locator != null) {
|
||||
e = new SAXParseException(message, locator);
|
||||
return new SAXParseException(message, locator);
|
||||
} else {
|
||||
e = new SAXParseException(message, null, null, -1, -1);
|
||||
return new SAXParseException(message, null, null, -1, -1);
|
||||
}
|
||||
errorHandler.error(e);
|
||||
}
|
||||
|
||||
|
||||
|
@ -758,7 +776,7 @@ public class ParserAdapter implements XMLReader, DocumentHandler
|
|||
*
|
||||
* @param type The type of thing (feature or property).
|
||||
* @param name The feature or property name.
|
||||
* @exception org.xml.sax.SAXNotSupportedException If a
|
||||
* @exception SAXNotSupportedException If a
|
||||
* document is currently being parsed.
|
||||
*/
|
||||
private void checkNotParsing (String type, String name)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// SAX parser factory.
|
||||
// http://www.saxproject.org
|
||||
// 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;
|
||||
|
||||
|
@ -19,6 +20,8 @@ import org.xml.sax.Parser;
|
|||
* <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><strong>Note:</strong> This class is designed to work with the now-deprecated
|
||||
|
@ -40,11 +43,8 @@ import org.xml.sax.Parser;
|
|||
* {@link org.xml.sax.Parser Parser}
|
||||
* interface.
|
||||
* @since SAX 1.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @see org.xml.sax.Parser
|
||||
* @see java.lang.Class
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
*/
|
||||
public class ParserFactory {
|
||||
|
||||
|
@ -121,9 +121,9 @@ public class ParserFactory {
|
|||
InstantiationException,
|
||||
ClassCastException
|
||||
{
|
||||
return (Parser)(Class.forName(className).newInstance());
|
||||
return (Parser) NewInstance.newInstance (
|
||||
NewInstance.getClassLoader (), className);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// end of ParserFactory.java
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// XMLFilterImpl.java - base SAX2 filter implementation.
|
||||
// Written by David Megginson, sax@megginson.com
|
||||
// http://www.saxproject.org
|
||||
// Written by David Megginson
|
||||
// NO WARRANTY! This class is in the Public Domain.
|
||||
|
||||
// $Id: XMLFilterImpl.java,v 1.1 2000/10/02 02:43:20 sboag Exp $
|
||||
// $Id: XMLFilterImpl.java,v 1.3.2.7 2002/01/29 21:34:14 dbrownell Exp $
|
||||
|
||||
package org.xml.sax.helpers;
|
||||
|
||||
|
@ -29,6 +30,8 @@ import org.xml.sax.SAXNotRecognizedException;
|
|||
* <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 is designed to sit between an {@link org.xml.sax.XMLReader
|
||||
|
@ -39,9 +42,8 @@ import org.xml.sax.SAXNotRecognizedException;
|
|||
* requests as they pass through.</p>
|
||||
*
|
||||
* @since SAX 2.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.XMLFilter
|
||||
* @see org.xml.sax.XMLReader
|
||||
* @see org.xml.sax.EntityResolver
|
||||
|
@ -64,10 +66,12 @@ public class XMLFilterImpl
|
|||
*
|
||||
* <p>This filter will have no parent: you must assign a parent
|
||||
* before you start a parse or do any configuration with
|
||||
* setFeature or setProperty.</p>
|
||||
* setFeature or setProperty, unless you use this as a pure event
|
||||
* consumer rather than as an {@link XMLReader}.</p>
|
||||
*
|
||||
* @see org.xml.sax.XMLReader#setFeature
|
||||
* @see org.xml.sax.XMLReader#setProperty
|
||||
* @see #setParent
|
||||
*/
|
||||
public XMLFilterImpl ()
|
||||
{
|
||||
|
@ -105,14 +109,10 @@ public class XMLFilterImpl
|
|||
* or to set or get a feature or property will fail.</p>
|
||||
*
|
||||
* @param parent The parent XML reader.
|
||||
* @exception java.lang.NullPointerException If the parent is null.
|
||||
* @see #getParent
|
||||
*/
|
||||
public void setParent (XMLReader parent)
|
||||
{
|
||||
if (parent == null) {
|
||||
throw new NullPointerException("Null parent");
|
||||
}
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
@ -136,24 +136,23 @@ public class XMLFilterImpl
|
|||
|
||||
|
||||
/**
|
||||
* Set the state of a feature.
|
||||
* Set the value of a feature.
|
||||
*
|
||||
* <p>This will always fail if the parent is null.</p>
|
||||
*
|
||||
* @param name The feature name.
|
||||
* @param state The requested feature state.
|
||||
* @exception org.xml.sax.SAXNotRecognizedException When the
|
||||
* XMLReader does not recognize the feature name.
|
||||
* @param value The requested feature value.
|
||||
* @exception org.xml.sax.SAXNotRecognizedException If the feature
|
||||
* value can't be assigned or retrieved from the parent.
|
||||
* @exception org.xml.sax.SAXNotSupportedException When the
|
||||
* XMLReader recognizes the feature name but
|
||||
* parent recognizes the feature name but
|
||||
* cannot set the requested value.
|
||||
* @see org.xml.sax.XMLReader#setFeature
|
||||
*/
|
||||
public void setFeature (String name, boolean state)
|
||||
public void setFeature (String name, boolean value)
|
||||
throws SAXNotRecognizedException, SAXNotSupportedException
|
||||
{
|
||||
if (parent != null) {
|
||||
parent.setFeature(name, state);
|
||||
parent.setFeature(name, value);
|
||||
} else {
|
||||
throw new SAXNotRecognizedException("Feature: " + name);
|
||||
}
|
||||
|
@ -161,18 +160,17 @@ public class XMLFilterImpl
|
|||
|
||||
|
||||
/**
|
||||
* Look up the state of a feature.
|
||||
* Look up the value of a feature.
|
||||
*
|
||||
* <p>This will always fail if the parent is null.</p>
|
||||
*
|
||||
* @param name The feature name.
|
||||
* @return The current state of the feature.
|
||||
* @exception org.xml.sax.SAXNotRecognizedException When the
|
||||
* XMLReader does not recognize the feature name.
|
||||
* @return The current value of the feature.
|
||||
* @exception org.xml.sax.SAXNotRecognizedException If the feature
|
||||
* value can't be assigned or retrieved from the parent.
|
||||
* @exception org.xml.sax.SAXNotSupportedException When the
|
||||
* XMLReader recognizes the feature name but
|
||||
* cannot determine its state at this time.
|
||||
* @see org.xml.sax.XMLReader#getFeature
|
||||
* parent recognizes the feature name but
|
||||
* cannot determine its value at this time.
|
||||
*/
|
||||
public boolean getFeature (String name)
|
||||
throws SAXNotRecognizedException, SAXNotSupportedException
|
||||
|
@ -191,13 +189,12 @@ public class XMLFilterImpl
|
|||
* <p>This will always fail if the parent is null.</p>
|
||||
*
|
||||
* @param name The property name.
|
||||
* @param state The requested property value.
|
||||
* @exception org.xml.sax.SAXNotRecognizedException When the
|
||||
* XMLReader does not recognize the property name.
|
||||
* @param value The requested property value.
|
||||
* @exception org.xml.sax.SAXNotRecognizedException If the property
|
||||
* value can't be assigned or retrieved from the parent.
|
||||
* @exception org.xml.sax.SAXNotSupportedException When the
|
||||
* XMLReader recognizes the property name but
|
||||
* parent recognizes the property name but
|
||||
* cannot set the requested value.
|
||||
* @see org.xml.sax.XMLReader#setProperty
|
||||
*/
|
||||
public void setProperty (String name, Object value)
|
||||
throws SAXNotRecognizedException, SAXNotSupportedException
|
||||
|
@ -215,12 +212,11 @@ public class XMLFilterImpl
|
|||
*
|
||||
* @param name The property name.
|
||||
* @return The current value of the property.
|
||||
* @exception org.xml.sax.SAXNotRecognizedException When the
|
||||
* XMLReader does not recognize the feature name.
|
||||
* @exception org.xml.sax.SAXNotRecognizedException If the property
|
||||
* value can't be assigned or retrieved from the parent.
|
||||
* @exception org.xml.sax.SAXNotSupportedException When the
|
||||
* XMLReader recognizes the property name but
|
||||
* parent recognizes the property name but
|
||||
* cannot determine its value at this time.
|
||||
* @see org.xml.sax.XMLReader#setFeature
|
||||
*/
|
||||
public Object getProperty (String name)
|
||||
throws SAXNotRecognizedException, SAXNotSupportedException
|
||||
|
@ -237,17 +233,10 @@ public class XMLFilterImpl
|
|||
* Set the entity resolver.
|
||||
*
|
||||
* @param resolver The new entity resolver.
|
||||
* @exception java.lang.NullPointerException If the resolver
|
||||
* is null.
|
||||
* @see org.xml.sax.XMLReader#setEntityResolver
|
||||
*/
|
||||
public void setEntityResolver (EntityResolver resolver)
|
||||
{
|
||||
if (resolver == null) {
|
||||
throw new NullPointerException("Null entity resolver");
|
||||
} else {
|
||||
entityResolver = resolver;
|
||||
}
|
||||
entityResolver = resolver;
|
||||
}
|
||||
|
||||
|
||||
|
@ -255,7 +244,6 @@ public class XMLFilterImpl
|
|||
* Get the current entity resolver.
|
||||
*
|
||||
* @return The current entity resolver, or null if none was set.
|
||||
* @see org.xml.sax.XMLReader#getEntityResolver
|
||||
*/
|
||||
public EntityResolver getEntityResolver ()
|
||||
{
|
||||
|
@ -267,17 +255,10 @@ public class XMLFilterImpl
|
|||
* Set the DTD event handler.
|
||||
*
|
||||
* @param resolver The new DTD handler.
|
||||
* @exception java.lang.NullPointerException If the handler
|
||||
* is null.
|
||||
* @see org.xml.sax.XMLReader#setDTDHandler
|
||||
*/
|
||||
public void setDTDHandler (DTDHandler handler)
|
||||
{
|
||||
if (handler == null) {
|
||||
throw new NullPointerException("Null DTD handler");
|
||||
} else {
|
||||
dtdHandler = handler;
|
||||
}
|
||||
dtdHandler = handler;
|
||||
}
|
||||
|
||||
|
||||
|
@ -285,7 +266,6 @@ public class XMLFilterImpl
|
|||
* Get the current DTD event handler.
|
||||
*
|
||||
* @return The current DTD handler, or null if none was set.
|
||||
* @see org.xml.sax.XMLReader#getDTDHandler
|
||||
*/
|
||||
public DTDHandler getDTDHandler ()
|
||||
{
|
||||
|
@ -297,17 +277,10 @@ public class XMLFilterImpl
|
|||
* Set the content event handler.
|
||||
*
|
||||
* @param resolver The new content handler.
|
||||
* @exception java.lang.NullPointerException If the handler
|
||||
* is null.
|
||||
* @see org.xml.sax.XMLReader#setContentHandler
|
||||
*/
|
||||
public void setContentHandler (ContentHandler handler)
|
||||
{
|
||||
if (handler == null) {
|
||||
throw new NullPointerException("Null content handler");
|
||||
} else {
|
||||
contentHandler = handler;
|
||||
}
|
||||
contentHandler = handler;
|
||||
}
|
||||
|
||||
|
||||
|
@ -315,7 +288,6 @@ public class XMLFilterImpl
|
|||
* Get the content event handler.
|
||||
*
|
||||
* @return The current content handler, or null if none was set.
|
||||
* @see org.xml.sax.XMLReader#getContentHandler
|
||||
*/
|
||||
public ContentHandler getContentHandler ()
|
||||
{
|
||||
|
@ -327,17 +299,10 @@ public class XMLFilterImpl
|
|||
* Set the error event handler.
|
||||
*
|
||||
* @param handle The new error handler.
|
||||
* @exception java.lang.NullPointerException If the handler
|
||||
* is null.
|
||||
* @see org.xml.sax.XMLReader#setErrorHandler
|
||||
*/
|
||||
public void setErrorHandler (ErrorHandler handler)
|
||||
{
|
||||
if (handler == null) {
|
||||
throw new NullPointerException("Null error handler");
|
||||
} else {
|
||||
errorHandler = handler;
|
||||
}
|
||||
errorHandler = handler;
|
||||
}
|
||||
|
||||
|
||||
|
@ -345,7 +310,6 @@ public class XMLFilterImpl
|
|||
* Get the current error event handler.
|
||||
*
|
||||
* @return The current error handler, or null if none was set.
|
||||
* @see org.xml.sax.XMLReader#getErrorHandler
|
||||
*/
|
||||
public ErrorHandler getErrorHandler ()
|
||||
{
|
||||
|
@ -362,7 +326,6 @@ public class XMLFilterImpl
|
|||
* @exception java.io.IOException An IO exception from the parser,
|
||||
* possibly from a byte stream or character stream
|
||||
* supplied by the application.
|
||||
* @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource)
|
||||
*/
|
||||
public void parse (InputSource input)
|
||||
throws SAXException, IOException
|
||||
|
@ -381,7 +344,6 @@ public class XMLFilterImpl
|
|||
* @exception java.io.IOException An IO exception from the parser,
|
||||
* possibly from a byte stream or character stream
|
||||
* supplied by the application.
|
||||
* @see org.xml.sax.XMLReader#parse(java.lang.String)
|
||||
*/
|
||||
public void parse (String systemId)
|
||||
throws SAXException, IOException
|
||||
|
@ -407,7 +369,6 @@ public class XMLFilterImpl
|
|||
* @exception java.io.IOException The client may throw an
|
||||
* I/O-related exception while obtaining the
|
||||
* new InputSource.
|
||||
* @see org.xml.sax.EntityResolver#resolveEntity
|
||||
*/
|
||||
public InputSource resolveEntity (String publicId, String systemId)
|
||||
throws SAXException, IOException
|
||||
|
@ -434,7 +395,6 @@ public class XMLFilterImpl
|
|||
* @param systemId The notation's system identifier, or null.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
* @see org.xml.sax.DTDHandler#notationDecl
|
||||
*/
|
||||
public void notationDecl (String name, String publicId, String systemId)
|
||||
throws SAXException
|
||||
|
@ -454,7 +414,6 @@ public class XMLFilterImpl
|
|||
* @param notationName The name of the associated notation.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
* @see org.xml.sax.DTDHandler#unparsedEntityDecl
|
||||
*/
|
||||
public void unparsedEntityDecl (String name, String publicId,
|
||||
String systemId, String notationName)
|
||||
|
@ -477,7 +436,6 @@ public class XMLFilterImpl
|
|||
* Filter a new document locator event.
|
||||
*
|
||||
* @param locator The document locator.
|
||||
* @see org.xml.sax.ContentHandler#setDocumentLocator
|
||||
*/
|
||||
public void setDocumentLocator (Locator locator)
|
||||
{
|
||||
|
@ -493,7 +451,6 @@ public class XMLFilterImpl
|
|||
*
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
* @see org.xml.sax.ContentHandler#startDocument
|
||||
*/
|
||||
public void startDocument ()
|
||||
throws SAXException
|
||||
|
@ -509,7 +466,6 @@ public class XMLFilterImpl
|
|||
*
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
* @see org.xml.sax.ContentHandler#endDocument
|
||||
*/
|
||||
public void endDocument ()
|
||||
throws SAXException
|
||||
|
@ -527,7 +483,6 @@ public class XMLFilterImpl
|
|||
* @param uri The Namespace URI.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
* @see org.xml.sax.ContentHandler#startPrefixMapping
|
||||
*/
|
||||
public void startPrefixMapping (String prefix, String uri)
|
||||
throws SAXException
|
||||
|
@ -544,7 +499,6 @@ public class XMLFilterImpl
|
|||
* @param prefix The Namespace prefix.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
* @see org.xml.sax.ContentHandler#endPrefixMapping
|
||||
*/
|
||||
public void endPrefixMapping (String prefix)
|
||||
throws SAXException
|
||||
|
@ -565,7 +519,6 @@ public class XMLFilterImpl
|
|||
* @param atts The element's attributes.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
* @see org.xml.sax.ContentHandler#startElement
|
||||
*/
|
||||
public void startElement (String uri, String localName, String qName,
|
||||
Attributes atts)
|
||||
|
@ -586,7 +539,6 @@ public class XMLFilterImpl
|
|||
* string.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
* @see org.xml.sax.ContentHandler#endElement
|
||||
*/
|
||||
public void endElement (String uri, String localName, String qName)
|
||||
throws SAXException
|
||||
|
@ -605,7 +557,6 @@ public class XMLFilterImpl
|
|||
* @param length The number of characters to use from the array.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
* @see org.xml.sax.ContentHandler#characters
|
||||
*/
|
||||
public void characters (char ch[], int start, int length)
|
||||
throws SAXException
|
||||
|
@ -624,7 +575,6 @@ public class XMLFilterImpl
|
|||
* @param length The number of characters to use from the array.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
* @see org.xml.sax.ContentHandler#ignorableWhitespace
|
||||
*/
|
||||
public void ignorableWhitespace (char ch[], int start, int length)
|
||||
throws SAXException
|
||||
|
@ -642,7 +592,6 @@ public class XMLFilterImpl
|
|||
* @param data The text following the target.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
* @see org.xml.sax.ContentHandler#processingInstruction
|
||||
*/
|
||||
public void processingInstruction (String target, String data)
|
||||
throws SAXException
|
||||
|
@ -659,7 +608,6 @@ public class XMLFilterImpl
|
|||
* @param name The name of the skipped entity.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
* @see org.xml.sax.ContentHandler#skippedEntity
|
||||
*/
|
||||
public void skippedEntity (String name)
|
||||
throws SAXException
|
||||
|
@ -679,10 +627,9 @@ public class XMLFilterImpl
|
|||
/**
|
||||
* Filter a warning event.
|
||||
*
|
||||
* @param e The nwarning as an exception.
|
||||
* @param e The warning as an exception.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
* @see org.xml.sax.ErrorHandler#warning
|
||||
*/
|
||||
public void warning (SAXParseException e)
|
||||
throws SAXException
|
||||
|
@ -699,7 +646,6 @@ public class XMLFilterImpl
|
|||
* @param e The error as an exception.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
* @see org.xml.sax.ErrorHandler#error
|
||||
*/
|
||||
public void error (SAXParseException e)
|
||||
throws SAXException
|
||||
|
@ -716,7 +662,6 @@ public class XMLFilterImpl
|
|||
* @param e The error as an exception.
|
||||
* @exception org.xml.sax.SAXException The client may throw
|
||||
* an exception during processing.
|
||||
* @see org.xml.sax.ErrorHandler#fatalError
|
||||
*/
|
||||
public void fatalError (SAXParseException e)
|
||||
throws SAXException
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
// 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.
|
||||
|
||||
// $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;
|
||||
|
||||
|
@ -31,6 +32,8 @@ import org.xml.sax.SAXNotSupportedException;
|
|||
* <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 wraps a SAX2 {@link org.xml.sax.XMLReader XMLReader}
|
||||
|
@ -42,9 +45,8 @@ import org.xml.sax.SAXNotSupportedException;
|
|||
* property, that will also be used to improve efficiency.</p>
|
||||
*
|
||||
* @since SAX 2.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @author David Megginson
|
||||
* @version 2.0.1 (sax2r2)
|
||||
* @see org.xml.sax.Parser
|
||||
* @see org.xml.sax.XMLReader
|
||||
*/
|
||||
|
@ -120,6 +122,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler
|
|||
*
|
||||
* @param The locale for error reporting.
|
||||
* @see org.xml.sax.Parser#setLocale
|
||||
* @exception org.xml.sax.SAXException Thrown unless overridden.
|
||||
*/
|
||||
public void setLocale (Locale locale)
|
||||
throws SAXException
|
||||
|
@ -255,7 +258,8 @@ public class XMLReaderAdapter implements Parser, ContentHandler
|
|||
*/
|
||||
public void setDocumentLocator (Locator locator)
|
||||
{
|
||||
documentHandler.setDocumentLocator(locator);
|
||||
if (documentHandler != null)
|
||||
documentHandler.setDocumentLocator(locator);
|
||||
}
|
||||
|
||||
|
||||
|
@ -269,7 +273,8 @@ public class XMLReaderAdapter implements Parser, ContentHandler
|
|||
public void startDocument ()
|
||||
throws SAXException
|
||||
{
|
||||
documentHandler.startDocument();
|
||||
if (documentHandler != null)
|
||||
documentHandler.startDocument();
|
||||
}
|
||||
|
||||
|
||||
|
@ -283,7 +288,8 @@ public class XMLReaderAdapter implements Parser, ContentHandler
|
|||
public void endDocument ()
|
||||
throws SAXException
|
||||
{
|
||||
documentHandler.endDocument();
|
||||
if (documentHandler != null)
|
||||
documentHandler.endDocument();
|
||||
}
|
||||
|
||||
|
||||
|
@ -325,8 +331,10 @@ public class XMLReaderAdapter implements Parser, ContentHandler
|
|||
String qName, Attributes atts)
|
||||
throws SAXException
|
||||
{
|
||||
qAtts.setAttributes(atts);
|
||||
documentHandler.startElement(qName, qAtts);
|
||||
if (documentHandler != null) {
|
||||
qAtts.setAttributes(atts);
|
||||
documentHandler.startElement(qName, qAtts);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -344,7 +352,8 @@ public class XMLReaderAdapter implements Parser, ContentHandler
|
|||
String qName)
|
||||
throws SAXException
|
||||
{
|
||||
documentHandler.endElement(qName);
|
||||
if (documentHandler != null)
|
||||
documentHandler.endElement(qName);
|
||||
}
|
||||
|
||||
|
||||
|
@ -361,7 +370,8 @@ public class XMLReaderAdapter implements Parser, ContentHandler
|
|||
public void characters (char ch[], int start, int length)
|
||||
throws SAXException
|
||||
{
|
||||
documentHandler.characters(ch, start, length);
|
||||
if (documentHandler != null)
|
||||
documentHandler.characters(ch, start, length);
|
||||
}
|
||||
|
||||
|
||||
|
@ -378,7 +388,8 @@ public class XMLReaderAdapter implements Parser, ContentHandler
|
|||
public void ignorableWhitespace (char ch[], int start, int length)
|
||||
throws SAXException
|
||||
{
|
||||
documentHandler.ignorableWhitespace(ch, start, length);
|
||||
if (documentHandler != null)
|
||||
documentHandler.ignorableWhitespace(ch, start, length);
|
||||
}
|
||||
|
||||
|
||||
|
@ -394,7 +405,8 @@ public class XMLReaderAdapter implements Parser, ContentHandler
|
|||
public void processingInstruction (String target, String data)
|
||||
throws SAXException
|
||||
{
|
||||
documentHandler.processingInstruction(target, data);
|
||||
if (documentHandler != null)
|
||||
documentHandler.processingInstruction(target, data);
|
||||
}
|
||||
|
||||
|
||||
|
@ -403,6 +415,7 @@ public class XMLReaderAdapter implements Parser, ContentHandler
|
|||
*
|
||||
* @param name The name of the skipped entity.
|
||||
* @see org.xml.sax.ContentHandler#skippedEntity
|
||||
* @exception org.xml.sax.SAXException Throwable by subclasses.
|
||||
*/
|
||||
public void skippedEntity (String name)
|
||||
throws SAXException
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
// 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.
|
||||
|
||||
// $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;
|
||||
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.SAXException;
|
||||
|
||||
|
@ -16,12 +20,12 @@ import org.xml.sax.SAXException;
|
|||
* <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 static methods for creating an XML reader
|
||||
* from an explicit class name, or for creating an XML reader based
|
||||
* on the value of the <code>org.xml.sax.driver</code> system
|
||||
* property:</p>
|
||||
* from an explicit class name, or based on runtime defaults:</p>
|
||||
*
|
||||
* <pre>
|
||||
* try {
|
||||
|
@ -31,23 +35,20 @@ import org.xml.sax.SAXException;
|
|||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>Note that these methods will not be usable in environments where
|
||||
* system properties are not accessible or where the application or
|
||||
* applet is not permitted to load classes dynamically.</p>
|
||||
*
|
||||
* <p><strong>Note to implementors:</strong> SAX implementations in specialized
|
||||
* environments may replace this class with a different one optimized for the
|
||||
* environment, as long as its method signatures remain the same.</p>
|
||||
* <p><strong>Note to Distributions bundled with parsers:</strong>
|
||||
* You should modify the implementation of the no-arguments
|
||||
* <em>createXMLReader</em> to handle cases where the external
|
||||
* configuration mechanisms aren't set up. That method should do its
|
||||
* best to return a parser when one is in the class path, even when
|
||||
* nothing bound its class name to <code>org.xml.sax.driver</code> so
|
||||
* those configuration mechanisms would see it.</p>
|
||||
*
|
||||
* @since SAX 2.0
|
||||
* @author David Megginson,
|
||||
* <a href="mailto:sax@megginson.com">sax@megginson.com</a>
|
||||
* @version 2.0
|
||||
* @see org.xml.sax.XMLReader
|
||||
* @author David Megginson, David Brownell
|
||||
* @version 2.0.1 (sax2r2)
|
||||
*/
|
||||
final public class XMLReaderFactory
|
||||
{
|
||||
|
||||
/**
|
||||
* Private constructor.
|
||||
*
|
||||
|
@ -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>
|
||||
*
|
||||
* <p>This method uses the value of the system property
|
||||
* "org.xml.sax.driver" as the full name of a Java class
|
||||
* and tries to instantiate that class as a SAX2
|
||||
* XMLReader.</p>
|
||||
* <li>If the system property <code>org.xml.sax.driver</code>
|
||||
* has a value, that is used as an XMLReader class name. </li>
|
||||
*
|
||||
* <p>Note that many Java interpreters allow system properties
|
||||
* to be specified on the command line.</p>
|
||||
* <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>
|
||||
*
|
||||
* <li> SAX parser distributions are strongly encouraged to provide
|
||||
* a default XMLReader class name that will take effect only when
|
||||
* previous options (on this list) are not successful.</li>
|
||||
*
|
||||
* <li>Finally, if {@link ParserFactory#makeParser()} can
|
||||
* 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.
|
||||
* @exception org.xml.sax.SAXException If the value of the
|
||||
* "org.xml.sax.driver" system property is null,
|
||||
* or if the class cannot be loaded and instantiated.
|
||||
* @exception org.xml.sax.SAXException If no default XMLReader class
|
||||
* can be identified and instantiated.
|
||||
* @see #createXMLReader(java.lang.String)
|
||||
*/
|
||||
public static XMLReader createXMLReader ()
|
||||
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) {
|
||||
Parser parser;
|
||||
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) {
|
||||
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
|
|||
* <p>Given a class name, this method attempts to load
|
||||
* 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.
|
||||
* @exception org.xml.sax.SAXException If the class cannot be
|
||||
* loaded, instantiated, and cast to XMLReader.
|
||||
|
@ -111,9 +176,15 @@ final public class XMLReaderFactory
|
|||
*/
|
||||
public static XMLReader createXMLReader (String className)
|
||||
throws SAXException
|
||||
{
|
||||
return loadClass (NewInstance.getClassLoader (), className);
|
||||
}
|
||||
|
||||
private static XMLReader loadClass (ClassLoader loader, String className)
|
||||
throws SAXException
|
||||
{
|
||||
try {
|
||||
return (XMLReader)(Class.forName(className).newInstance());
|
||||
return (XMLReader) NewInstance.newInstance (loader, className);
|
||||
} catch (ClassNotFoundException e1) {
|
||||
throw new SAXException("SAX2 driver class " + className +
|
||||
" not found", e1);
|
||||
|
@ -122,15 +193,11 @@ final public class XMLReaderFactory
|
|||
" found but cannot be loaded", e2);
|
||||
} catch (InstantiationException e3) {
|
||||
throw new SAXException("SAX2 driver class " + className +
|
||||
" loaded but cannot be instantiated (no empty public constructor?)",
|
||||
" loaded but cannot be instantiated (no empty public constructor?)",
|
||||
e3);
|
||||
} catch (ClassCastException e4) {
|
||||
throw new SAXException("SAX2 driver class " + className +
|
||||
" does not implement XMLReader", e4);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// end of XMLReaderFactory.java
|
||||
|
|
13
libjava/org/xml/sax/helpers/package.html
Normal file
13
libjava/org/xml/sax/helpers/package.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<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>
|
164
libjava/org/xml/sax/package.html
Normal file
164
libjava/org/xml/sax/package.html
Normal file
|
@ -0,0 +1,164 @@
|
|||
<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>
|
Loading…
Add table
Add a link
Reference in a new issue