Removing SAX docs. David Megginson removed them [1] from SAX CVS
citing that they have fallen out of sync. They were not distributed with SAX 2.0.2. http://cvs.sourceforge.net/viewcvs.py/sax/sax2/docs/?hideattic=0#dirlist git-svn-id: https://svn.apache.org/repos/asf/xml/commons/trunk@226241 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eca25067ad
commit
db0802b6ce
297
java/external/xdocs/sax/changes.html
vendored
297
java/external/xdocs/sax/changes.html
vendored
@ -1,297 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>SAX2: Changes</title>
|
||||
<link rel="stylesheet" type="text/css" href="sax-style.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>SAX2: Changes</h1>
|
||||
|
||||
<blockquote>
|
||||
<p class="copyright">This document is in the Public Domain.</p>
|
||||
</blockquote>
|
||||
|
||||
|
||||
<div>
|
||||
<h2>Changes from SAX 2.0 to SAX 2.0 r2 prerelease</h2>
|
||||
|
||||
<p>(See the ChangeLog in the distribution for more details.)</p>
|
||||
|
||||
<ul>
|
||||
<li>Added simple test program src/SAXTest.java</li>
|
||||
<li>Synchronized static methods in XMLReaderFactory for thread
|
||||
safety.</li>
|
||||
<li>Fixed bug in ParserAdapter that reported an incorrect error when
|
||||
an attribute using a Namespace prefix appeared before the Namespace
|
||||
declaration.</li>
|
||||
<li>Fixed bugs in AttributesImpl that caused infinite loops or
|
||||
prevented removing attributes.</li>
|
||||
<li>Specified that InputSource.getSystemId should return null (not an
|
||||
empty string) when no system ID is available.</li>
|
||||
<li>Modified DefaultHandler.resolveEntity to throw IOException, as in
|
||||
the interface specification.</li>
|
||||
<li>Added default constructors to SAXException,
|
||||
SAXNotRecognizedException, and SAXNotSupportedException.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<h2>Changes from SAX 2.0prerelease to SAX 2.0</h2>
|
||||
|
||||
<ul>
|
||||
<li>Documented the fact that parse() and event handlers are
|
||||
synchronous.</li>
|
||||
<li>Documented the fact that xml: prefix never has
|
||||
start/endPrefixMapping events.</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<h2>Changes from SAX 2.0beta2 to SAX 2.0prerelease</h2>
|
||||
|
||||
<p>(See the <code>ChangeLog</code> included in the distribution for
|
||||
more detailed information.)</p>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>If the <code>org.xml.sax.driver property</code> is not specified
|
||||
but the SAX <code>org.xml.sax.parser</code> property is specified, <a
|
||||
href="javadoc/org/xml/sax/helpers/XMLReaderFactory.html#createXMLReader()"
|
||||
>XMLReaderFactory.createXMLReader()</a> will
|
||||
attempt to create an XML1 <a
|
||||
href="javadoc/org/xml/sax/Parser.html">Parser</a> and then wrap it in
|
||||
a <a
|
||||
href="javadoc/org/xml/sax/helpers/ParserAdapter.html">ParserAdapter</a>.</li>
|
||||
|
||||
<li><a
|
||||
href="javadoc/org/xml/sax/helpers/DefaultHandler.html">DefaultHandler</a>
|
||||
now throws a <a
|
||||
href="javadoc/org/xml/sax/SAXException.html">SAXException</a> for its
|
||||
<var>notationDecl</var> and <var>unparsedEntityDecl</var> methods, so
|
||||
that they can be subclassed properly.</li>
|
||||
|
||||
<li>Bug fixed in <a
|
||||
href="javadoc/org/xml/sax/helpers/AttributesImpl.html"
|
||||
>AttributesImpl</a>; last attribute can now be removed.</li>
|
||||
|
||||
<li>Added <var>setAttributes</var> method <a
|
||||
href="javadoc/org/xml/sax/helpers/AttributesImpl.html">AttributesImpl</a>
|
||||
to simplify reusing an object.</li>
|
||||
|
||||
<li><a
|
||||
href="javadoc/org/xml/sax/SAXParseException.html">SAXParseException</a>
|
||||
now allows a null <var>locator</var> argument in its
|
||||
constructors.</li>
|
||||
|
||||
<li>Specified that the <a
|
||||
href="javadoc/org/xml/sax/ContentHandler.html">ContentHandler</a>
|
||||
<var>skippedEntity</var> method will have an entity name of "[dtd]"
|
||||
for the external DTD subset.</li>
|
||||
|
||||
<li>Specified that the <a
|
||||
href="javadoc/org/xml/sax/ContentHandler.html">ContentHandler</a>
|
||||
<var>processingInstruction</var> method will exclude whitespace
|
||||
between the target and data.</li>
|
||||
|
||||
<li>In <a
|
||||
href="javadoc/org/xml/sax/helpers/NamespaceSupport.html">NamespaceSupport</a>,
|
||||
setting the "" prefix to "" removes any default mapping, and changed
|
||||
<var>getPrefix</var>, <var>getPrefixes</var> so that they will not
|
||||
return the default prefix.</li>
|
||||
|
||||
<li>In <a href="javadoc/org/xml/sax/Attributes.html">Attributes</a>,
|
||||
renamed <var>getRawName</var> to <var>getQName</var>. Likewise, in <a
|
||||
href="javadoc/org/xml/sax/helpers/AttributesImpl.html">AttributesImpl</a>,
|
||||
renamed <var>setRawName</var> to <var>setQName</var>.</li>
|
||||
|
||||
<li>Removed the <code>org.xml.sax.ext</code> package into a separate
|
||||
distribution, SAX2-ext. The <var>DeclHandler</var> and
|
||||
<var>LexicalHandler</var> classes are no longer part of the core SAX2
|
||||
distribution.</li>
|
||||
|
||||
<li>Added docs/quick-start.html</li>
|
||||
|
||||
<li>Modified <a
|
||||
href="javadoc/org/xml/sax/helpers/XMLReaderAdapter.html">XMLReaderAdapter</a>,
|
||||
<a
|
||||
href="javadoc/org/xml/sax/helpers/ParserAdapter.html">ParserAdapter</a>,
|
||||
and <a
|
||||
href="javadoc/org/xml/sax/helpers/XMLFilterImpl.html">XMLFilterImpl</a>
|
||||
so that <var>parse(String)</var> actually invokes
|
||||
<var>parse(InputSource)</var>: this way, only
|
||||
<var>parse(InputSource)</var> needs to be overridden in
|
||||
subclasses.</li>
|
||||
|
||||
<li>Added <var>getPrefix(String)</var> and
|
||||
<var>getPrefixes(String)</var> methods to <a
|
||||
href="javadoc/org/xml/sax/helpers/NamespaceSupport.html">NamespaceSupport</a>
|
||||
to look up currently-mapped prefixes.</li>
|
||||
|
||||
</ul>
|
||||
|
||||
<!-- end of "Changes from SAX2.0beta2 to SAX2.0prerelease" -->
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<h2>Changes from SAX 2.0beta to SAX 2.0beta2</h2>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>Corrected "raw-names" to "namespace-prefixes" throughout.</li>
|
||||
|
||||
<li>Removed a JDK 1.2 dependency in <a
|
||||
href="javadoc/org/xml/sax/helpers/NamespaceSupport.html"
|
||||
>org.xml.sax.helpers.NamespaceSupport</a>.</li>
|
||||
|
||||
<li>Fixed <a href="javadoc/org/xml/sax/helpers/ParserAdapter.html"
|
||||
>org.xml.sax.helpers.ParserAdapter</a> so that the object can be
|
||||
reused after a previous parse has thrown an exception.</li>
|
||||
|
||||
<li>Added <a href="javadoc/org/xml/sax/helpers/XMLReaderFactory.html"
|
||||
>org.xml.sax.helpers.XMLReaderFactory</a>.</li>
|
||||
|
||||
<li>Documented limitations of start/endEntity in
|
||||
<var>org.xml.sax.ext.LexicalHandler</var>, and added documentation
|
||||
that LexicalHandler applies to the whole document and that all events
|
||||
must appear between start/endDocument (including start/endDTD).</li>
|
||||
|
||||
<li><a href="javadoc/org/xml/sax/helpers/ParserAdapter.html"
|
||||
>org.xml.sax.helpers.ParserAdapter</a> and
|
||||
<a href="javadoc/org/xml/sax/helpers/XMLReaderAdapter.html"
|
||||
>org.xml.sax.helpers.XMLReaderAdapter</a> now have a default
|
||||
constructors that use the "org.xml.sax.parser" and
|
||||
"org.xml.sax.driver" properties to locate the embedded SAX1 and
|
||||
SAX2 drivers respectively.</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<h2>Changes from SAX 1.0 to SAX 2.0beta</h2>
|
||||
|
||||
<p>The following interfaces and classes have been deprecated, and will
|
||||
be removed from a future version of SAX; they should be used only for
|
||||
interaction with SAX1 drivers or applications:</p>
|
||||
|
||||
<ul>
|
||||
<li><a
|
||||
href="javadoc/org/xml/sax/Parser.html">org.xml.sax.Parser</a></li>
|
||||
<li><a href="javadoc/org/xml/sax/DocumentHandler.html"
|
||||
>org.xml.sax.DocumentHandler</a></li>
|
||||
<li><a href="javadoc/org/xml/sax/AttributeList.html"
|
||||
>org.xml.sax.AttributeList</a></li>
|
||||
<li><a href="javadoc/org/xml/sax/HandlerBase.html"
|
||||
>org.xml.sax.HandlerBase</a></li>
|
||||
<li><a href="javadoc/org/xml/sax/helpers/ParserFactory.html"
|
||||
>org.xml.sax.helpers.ParserFactory</a></li>
|
||||
<li><a href="javadoc/org/xml/sax/helpers/AttributeListImpl.html"
|
||||
>org.xml.sax.helpers.AttributeListImpl</a></li>
|
||||
</ul>
|
||||
|
||||
<p>The following interfaces and classes have been added to SAX2:</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="javadoc/org/xml/sax/XMLReader.html"
|
||||
>org.xml.sax.XMLReader</a> (replaces <a
|
||||
href="javadoc/org/xml/sax/Parser.html">Parser</a>)</li>
|
||||
<li><a href="javadoc/org/xml/sax/XMLFilter.html"
|
||||
>org.xml.sax.XMLFilter</a></li>
|
||||
<li><a href="javadoc/org/xml/sax/ContentHandler.html">org.xml.sax.ContentHandler</a> (replaces <a
|
||||
href="javadoc/org/xml/sax/DocumentHandler.html"
|
||||
>DocumentHandler</a>)</li>
|
||||
<li><a href="javadoc/org/xml/sax/Attributes.html"
|
||||
>org.xml.sax.Attributes</a> (replaces <a
|
||||
href="javadoc/org/xml/sax/AttributeList.html">AttributeList</a>)</li>
|
||||
<li><a href="javadoc/org/xml/sax/SAXNotSupportedException.html"
|
||||
>org.xml.sax.SAXNotSupportedException</a></li>
|
||||
<li><a href="javadoc/org/xml/sax/SAXNotRecognizedException.html"
|
||||
>org.xml.sax.SAXNotRecognizedException</a></li>
|
||||
<li><a href="javadoc/org/xml/sax/helpers/AttributesImpl.html"
|
||||
>org.xml.sax.helpers.AttributesImpl</a> (replaces
|
||||
AttributeListImpl)</li>
|
||||
<li><a href="javadoc/org/xml/sax/helpers/NamespaceSupport.html"
|
||||
>org.xml.sax.helpers.NamespaceSupport</a></li>
|
||||
<li><a href="javadoc/org/xml/sax/helpers/XMLFilterImpl.html"
|
||||
>org.xml.sax.helpers.XMLFilterImpl</a></li>
|
||||
<li><a href="javadoc/org/xml/sax/helpers/ParserAdapter.html"
|
||||
>org.xml.sax.helpers.ParserAdapter</a></li>
|
||||
<li><a href="javadoc/org/xml/sax/helpers/XMLReaderAdapter.html"
|
||||
>org.xml.sax.helpers.XMLReaderAdapter</a></li>
|
||||
<li><a href="javadoc/org/xml/sax/helpers/DefaultHandler.html"
|
||||
>org.xml.sax.helpers.DefaultHandler</a> (replaces <a
|
||||
href="javadoc/org/xml/sax/HandlerBase.html">HandlerBase</a>)</li>
|
||||
<li><var>org.xml.sax.ext.LexicalHandler</var> (since removed)</li>
|
||||
<li><var>org.xml.sax.ext.DeclHandler</var> (since removed)</li>
|
||||
</ul>
|
||||
|
||||
<p>SAX2 contains complete Namespace support, which is available by
|
||||
default from any <a
|
||||
href="javadoc/org/xml/sax/XMLReader.html">XMLReader</a>. An XML
|
||||
reader can also optionally supply raw XML 1.0 names. See <a
|
||||
href="namespaces.html">SAX2: Namespaces</a> for more details.</p>
|
||||
|
||||
<p>An XML reader is fully configurable: it is possible to attempt to
|
||||
query or change the current value of any feature or property.
|
||||
Features and properties are identified by fully-qualified URIs, and
|
||||
parties are free to invent their own names for new extensions. See <a
|
||||
href="features.html">SAX2: Features and Properties</a> for more
|
||||
details.</p>
|
||||
|
||||
<p>The <a href="javadoc/org/xml/sax/ContentHandler.html"
|
||||
shape="rect">ContentHandler</a> and <a
|
||||
href="javadoc/org/xml/sax/Attributes.html">Attributes</a> interfaces
|
||||
are similar to the deprecated <a
|
||||
href="javadoc/org/xml/sax/DocumentHandler.html">DocumentHandler</a>
|
||||
and <a href="javadoc/org/xml/sax/AttributeList.html">AttributeList</a>
|
||||
interfaces, but they add support for Namespace-related information.
|
||||
ContentHandler also adds a callback for skipped entities, and
|
||||
Attributes adds the ability to look up an attribute's index by
|
||||
name.</p>
|
||||
|
||||
<p>The <a
|
||||
href="javadoc/org/xml/sax/helpers/ParserAdapter.html">ParserAdapter</a>
|
||||
class makes a SAX1 <a
|
||||
href="javadoc/org/xml/sax/Parser.html">Parser</a> behave as a SAX2 <a
|
||||
href="javadoc/org/xml/sax/XMLReader.html">XMLReader</a>. The <a
|
||||
href="javadoc/org/xml/sax/helpers/XMLReaderAdapter.html">XMLReaderAdapter</a>
|
||||
class makes a SAX2 XML reader behave as a SAX1 parser. These two
|
||||
classes should ease the transition from SAX1 to SAX2 by allowing SAX1
|
||||
drivers and clients to co-exist with SAX2 drivers and clients in the
|
||||
same application.</p>
|
||||
|
||||
|
||||
<div>
|
||||
<h3>SAX1 Bugs Fixed</h3>
|
||||
|
||||
<dl>
|
||||
<dt><a href="javadoc/org/xml/sax/SAXException.html">SAXException</a></dt>
|
||||
<dd>Overrode java.lang.Object.toString so that an embedded exception
|
||||
will give a proper String representation for debugging.</dd>
|
||||
|
||||
<dt><a href="javadoc/org/xml/sax/helpers/ParserFactory.html"
|
||||
>ParserFactory</a></dt>
|
||||
<dd>Added missing closing comment so that private constructor is not
|
||||
commented out.</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<address>$Id$</address>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
177
java/external/xdocs/sax/features.html
vendored
177
java/external/xdocs/sax/features.html
vendored
@ -1,177 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>SAX2: Features and Properties</title>
|
||||
<link rel="stylesheet" type="text/css" href="sax-style.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>SAX2: Features and Properties</h1>
|
||||
|
||||
<blockquote>
|
||||
<p class="copyright">This document is in the Public Domain.</p>
|
||||
</blockquote>
|
||||
|
||||
<p>SAX2 adds standard methods to query and set features and properties
|
||||
in an <a href="javadoc/org/xml/sax/XMLReader.html">XMLReader</a>. It
|
||||
is now possible to request an XML reader to validate (or not to
|
||||
validate) a document, or to internalize (or not to internalize) all
|
||||
names, using the <var>getFeature</var>, <var>setFeature</var>,
|
||||
<var>getProperty</var>, and <var>setProperty</var> methods:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
try {
|
||||
if (xmlReader.getFeature("http://xml.org/sax/features/validation")) {
|
||||
System.out.println("Parser is validating.");
|
||||
} else {
|
||||
System.out.println("Parser is not validating.");
|
||||
}
|
||||
} catch (SAXException e) {
|
||||
System.out.println("Parser may or may not be validating.");
|
||||
}
|
||||
</pre></blockquote>
|
||||
|
||||
<p>There is no fixed set of features or properties available for SAX2:
|
||||
implementors are free to define new features and properties as needed.
|
||||
All feature and property names are fully-qualified URIs (often URLs),
|
||||
such as "http://www.acme.com/features/foo"; as with Namespace URIs,
|
||||
people should always define feature and property names based on URIs
|
||||
that they control.</p>
|
||||
|
||||
<p>If an application attempts to query or set a feature that the XML
|
||||
reader does not recognize, the XML reader throws a <a
|
||||
href="javadoc/org/xml/sax/SAXNotRecognizedException.html"
|
||||
>SAXNotRecognizedException</a>; if the application attempts to set a
|
||||
feature state or property value that the XML reader cannot support at
|
||||
that time, or attempts to modify a feature or property when it is
|
||||
read-only, the XML reader throws a <a
|
||||
href="javadoc/org/xml/sax/SAXNotSupportedException.html"
|
||||
>SAXNotSupportedException</a>.</p>
|
||||
|
||||
<p>One important application for properties is getting and setting
|
||||
extension event handlers, for event types not supported by the four
|
||||
core SAX2 handlers, <a
|
||||
href="javadoc/org/xml/sax/EntityResolver.html">EntityResolver</a>, <a
|
||||
href="javadoc/org/xml/sax/DTDHandler.html">DTDHandler</a>, <a
|
||||
href="javadoc/org/xml/sax/ContentHandler.html">ContentHandler</a>, and
|
||||
<a href="javadoc/org/xml/sax/ErrorHandler.html">ErrorHandler</a>.
|
||||
Outside parties are free to define handlers for any kinds of events,
|
||||
and to create properties for setting and querying them.</p>
|
||||
|
||||
<p>All XML readers are required to recognize the
|
||||
"http://xml.org/sax/features/namespaces" and the
|
||||
"http://xml.org/sax/features/namespace-prefixes" features (see below),
|
||||
and to support a <var>true</var> value for the namespaces property and
|
||||
a false value for the <var>namespace-prefixes</var> property: these
|
||||
requirements ensure that all SAX2 XML readers can provide the minimal
|
||||
required Namespace support for higher-level specs such as RDF, XSL,
|
||||
XML Schemas, and XLink. XML readers are not required to recognize or
|
||||
support any other features or any properties, even the core ones
|
||||
listed below.</p>
|
||||
|
||||
|
||||
<div>
|
||||
<h2>Core Features</h2>
|
||||
|
||||
<p>While anyone is free to define new SAX2 features, there is a core
|
||||
reference set of features that are application to a wide range of
|
||||
applications, and that many SAX2 XML readers may choose to support.
|
||||
Note that features may be read-only or read/write, and that they may
|
||||
be modifiable only when parsing, or only when not parsing.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>http://xml.org/sax/features/namespaces</code></dt>
|
||||
<dd><strong>true:</strong> Perform Namespace processing.</dd>
|
||||
<dd><strong>false:</strong> Optionally do not perform Namespace processing (implies
|
||||
<var>namespace-prefixes</var>). See <a href="namespaces.html">SAX2:
|
||||
Namespaces</a> for further information.</dd>
|
||||
<dd><strong>access:</strong> (parsing) read-only; (not parsing)
|
||||
read/write</dd>
|
||||
|
||||
<dt><code>http://xml.org/sax/features/namespace-prefixes</code></dt>
|
||||
<dd><strong>true:</strong> Report the original prefixed names and
|
||||
attributes used for Namespace declarations.</dd>
|
||||
<dd><strong>false:</strong> Do not report attributes used for
|
||||
Namespace declarations, and optionally do not report original prefixed
|
||||
names.</dd>
|
||||
<dd><strong>access:</strong> (parsing) read-only; (not parsing)
|
||||
read/write</dd>
|
||||
|
||||
<dt><code>http://xml.org/sax/features/string-interning</code></dt>
|
||||
<dd><strong>true:</strong> All element names, prefixes, attribute
|
||||
names, Namespace URIs, and local names are internalized using
|
||||
java.lang.String.intern.</dd>
|
||||
<dd><strong>false:</strong> Names are not necessarily
|
||||
internalized.</dd>
|
||||
<dd><strong>access:</strong> (parsing) read-only; (not parsing)
|
||||
read/write</dd>
|
||||
|
||||
<dt><code>http://xml.org/sax/features/validation</code></dt>
|
||||
<dd><strong>true:</strong> Report all validation errors (implies
|
||||
<var>external-general-entities</var> and
|
||||
<var>external-parameter-entities</var>).</dd>
|
||||
<dd><strong>false:</strong> Do not report validation errors.</dd>
|
||||
<dd><strong>access:</strong> (parsing) read-only; (not parsing)
|
||||
read/write</dd>
|
||||
|
||||
<dt><code>http://xml.org/sax/features/external-general-entities</code></dt>
|
||||
<dd><strong>true:</strong> Include all external general (text)
|
||||
entities.</dd>
|
||||
<dd><strong>false:</strong> Do not include external general
|
||||
entities.</dd>
|
||||
<dd><strong>access:</strong> (parsing) read-only; (not parsing)
|
||||
read/write</dd>
|
||||
|
||||
<dt><code>http://xml.org/sax/features/external-parameter-entities</code></dt>
|
||||
<dd><strong>true:</strong> Include all external parameter entities,
|
||||
including the external DTD subset.</dd>
|
||||
<dd><strong>false:</strong> Do not include any external parameter
|
||||
entities, even the external DTD subset.</dd>
|
||||
<dd><strong>access:</strong> (parsing) read-only; (not parsing)
|
||||
read/write</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<!-- end of "Core Features" -->
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<h2>Core Properties</h2>
|
||||
|
||||
<p>While anyone is free to define new SAX2 properties, there is a core
|
||||
reference set of properties that are application to a wide range of
|
||||
applications, and that many SAX2 XML readers may choose to support.
|
||||
Note that properties may be read-only or read/write, and that they may
|
||||
be modifiable only when parsing, or only when not parsing.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt><code>http://xml.org/sax/properties/dom-node</code></dt>
|
||||
<dd><strong>data type:</strong> <code>org.w3c.dom.Node</code></dd>
|
||||
<dd><strong>description:</strong> When parsing, the current DOM node
|
||||
being visited if this is a DOM iterator; when not parsing, the root
|
||||
DOM node for iteration.</dd>
|
||||
<dd><strong>access:</strong> (parsing) read-only; (not parsing)
|
||||
read/write</dd>
|
||||
|
||||
<dt><code>http://xml.org/sax/properties/xml-string</code></dt>
|
||||
<dd><strong>data type:</strong> <code>java.lang.String</code></dd>
|
||||
<dd><strong>description:</strong> The literal string of characters
|
||||
that was the source for the current event.</dd>
|
||||
<dd><strong>access:</strong> read-only</dd>
|
||||
|
||||
</dl>
|
||||
|
||||
<!-- end of "Core Properties" -->
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<address>$Id$</address>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
135
java/external/xdocs/sax/filters.html
vendored
135
java/external/xdocs/sax/filters.html
vendored
@ -1,135 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>SAX2: Filters</title>
|
||||
<link rel="stylesheet" type="text/css" href="sax-style.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>SAX2: Filters</h1>
|
||||
|
||||
<blockquote>
|
||||
<p class="copyright">This document is in the Public Domain.</p>
|
||||
</blockquote>
|
||||
|
||||
<p>The SAX interface assumes two basic streams:</p>
|
||||
|
||||
<ol>
|
||||
<li>a stream of requests flowing from the application to the SAX
|
||||
driver; and</li>
|
||||
<li>a stream of events (and other information) flowing from the SAX
|
||||
driver to the application.</li>
|
||||
</ol>
|
||||
|
||||
<p>With SAX1, programmers quickly realized that it was possible to
|
||||
extend this model to support a processing chain, where requests could
|
||||
flow through several different components, or filters, before arriving
|
||||
at the original SAX driver, and events could flow through the same
|
||||
filters before arriving at the application. Each filter can make
|
||||
changes to the stream of events as it passes through, but the whole
|
||||
chain of filters still appears to be a single SAX driver to the
|
||||
application.</p>
|
||||
|
||||
<p>SAX2 formalizes this design technique by adding a new interface, <a
|
||||
href="javadoc/org/xml/sax/XMLFilter.html">org.xml.sax.XMLFilter</a>,
|
||||
and a new helper class, <a
|
||||
href="javadoc/org/xml/sax/helpers/XMLFilterImpl.html"
|
||||
>org.xml.sax.XMLFilterImpl</a>.</p>
|
||||
|
||||
<p>The <var>XMLFilter</var> interface itself is very simple, extending
|
||||
the basic <var>XMLReader</var> interface with two additional
|
||||
methods:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
public interface XMLFilter extends XMLReader
|
||||
{
|
||||
public abstract void setParent (XMLReader parent);
|
||||
public abstract XMLReader getParent ();
|
||||
}
|
||||
</pre></blockquote>
|
||||
|
||||
<p>In other words, a SAX2 filter is simply an XMLReader that has
|
||||
another XMLReader as its parent.</p>
|
||||
|
||||
<p>In normal use, a filter will implement not only the
|
||||
<var>XMLFilter</var> interface but also one or all of the various
|
||||
resolver and handler interfaces (<var>EntityResolver</var>,
|
||||
<var>DTDHandler</var>, <var>ContentHandler</var>, and
|
||||
<var>ErrorHandler</var>). To the parent XML reader, the filter is the
|
||||
client application receiving the events; to the client application,
|
||||
the filter is the SAX driver producing the events.</p>
|
||||
|
||||
<p>The <var>XMLFilterImpl</var> helper class provides a convenient
|
||||
base for deriving SAX2 filters. This class implements the
|
||||
<var>XMLFilter</var>, <var>EntityResolver</var>,
|
||||
<var>DTDHandler</var>, <var>ContentHandler</var>, and
|
||||
<var>ErrorHandler</var> interfaces. By default, it passes all events
|
||||
on unmodified, but the derived filter can override specific
|
||||
methods.</p>
|
||||
|
||||
<p>Here's an example of a very simple filter that changes the
|
||||
Namespace URI <code>http://www.foo.com/ns/</code> to
|
||||
<code>http://www.bar.com/</code> wherever it appears in an element
|
||||
name (but not an attribute name):</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
public class FooFilter extends XMLFilterImpl
|
||||
{
|
||||
public FooFilter ()
|
||||
{
|
||||
}
|
||||
|
||||
public FooFilter (XMLReader parent)
|
||||
{
|
||||
super(parent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filter the Namespace URI for start-element events.
|
||||
*/
|
||||
public void startElement (String uri, String localName,
|
||||
String qName, Attributes atts)
|
||||
throws SAXException
|
||||
{
|
||||
if (uri.equals("http://www.foo.com/ns/")) {
|
||||
uri = "http://www.bar.com/ns/";
|
||||
}
|
||||
super.startElement(uri, localName, qName, atts);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filter the Namespace URI for end-element events.
|
||||
*/
|
||||
public void endElement (String uri, String localName, String qName)
|
||||
throws SAXException
|
||||
{
|
||||
if (uri.equals("http://www.foo.com/ns/")) {
|
||||
uri = "http://www.bar.com/ns/";
|
||||
}
|
||||
super.endElement(uri, localName, qName);
|
||||
}
|
||||
|
||||
}
|
||||
</pre></blockquote>
|
||||
|
||||
<p>Note the use of <var>super.startElement</var> and
|
||||
<var>super.endElement</var> to send the event on to the client. In a
|
||||
real filter, it would be good to override the
|
||||
<var>ContentHandler.startPrefixMapping</var> and
|
||||
<var>ContentHandler.endPrefixMapping</var> methods as well.</p>
|
||||
|
||||
<p>Long filter chains are not always the best approach, but you will
|
||||
find that it is sometimes easier to build complex XML applications if
|
||||
you can break them down into a collection of simple SAX filters, each
|
||||
one reading the events from its parent.</p>
|
||||
|
||||
<hr />
|
||||
|
||||
<address>$Id$</address>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
293
java/external/xdocs/sax/namespaces.html
vendored
293
java/external/xdocs/sax/namespaces.html
vendored
@ -1,293 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>SAX2 Namespace Support</title>
|
||||
<link rel="stylesheet" type="text/css" href="sax-style.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>SAX2 Namespace Support</h1>
|
||||
|
||||
<blockquote>
|
||||
<p class="copyright">This document is in the Public Domain.</p>
|
||||
</blockquote>
|
||||
|
||||
<p>SAX2 adds <a href="[FIXME]">XML Namespace</a> support, which is
|
||||
required for higher-level standards like <a href="[FIXME]">XSL</a>, <a
|
||||
href="[FIXME]">XML Schemas</a>, <a
|
||||
href="http://www.w3.org/TR/REC-rdf-syntax">RDF</a>, and <a
|
||||
href="[FIXME]">XLink</a>. Every implementation of the SAX2 <a
|
||||
href="javadoc/org/xml/sax/XMLReader.html" >XMLReader</a> interface is
|
||||
required to support Namespace processing as its default state; some
|
||||
XML readers may also allow Namespace processing to be disabled or
|
||||
modified (note to SAX driver writers: there is a helper class, <a
|
||||
href="javadoc/org/xml/sax/helpers/NamespaceSupport.html">NamespaceSupport</a>,
|
||||
that can do most of the work of Namespace processing for you).</p>
|
||||
|
||||
<p>Namespace processing affects only element and attribute names.
|
||||
Without Namespace processing, each XML element and attribute has a
|
||||
single, local name (called the <em>qName</em>), which may contain a
|
||||
colon; with Namespace processing, each element and attribute has a
|
||||
two-part name, consisting of an optional URI (equivalent to a Java or
|
||||
Perl package name) followed by a local name which may not contain a
|
||||
colon.</p>
|
||||
|
||||
<p>SAX is capable of supporting either of these views or both
|
||||
simultaneously, though XML readers are required to support only the
|
||||
Namespaces view, and most applications will not need anything
|
||||
further.</p>
|
||||
|
||||
<div>
|
||||
<h2>1. Namespaces in SAX Events</h2>
|
||||
|
||||
<p>Namespace support affects the <a
|
||||
href="javadoc/org/xml/sax/ContentHandler.html" >ContentHandler</a> and
|
||||
<a href="javadoc/org/xml/sax/Attributes.html" >Attributes</a>
|
||||
interfaces.</p>
|
||||
|
||||
|
||||
<div>
|
||||
<h3>1.1. Element names</h3>
|
||||
|
||||
<p>In SAX2, the <a
|
||||
href="javadoc/org/xml/sax/ContentHandler.html#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)"
|
||||
>startElement</a> and <a
|
||||
href="javadoc/org/xml/sax/ContentHandler.html#endElement(java.lang.String, java.lang.String, java.lang.String)"
|
||||
>endElement</a> callbacks in a content handler look like this:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
public void startElement (String uri, String localName,
|
||||
String qName, Attributes atts)
|
||||
throws SAXException;
|
||||
|
||||
public void endElement (String uri, String localName, String qName)
|
||||
throws SAXException;
|
||||
</pre></blockquote>
|
||||
|
||||
<p>By default, an XML reader will report a Namespace URI and a local
|
||||
name for every element, in both the start and end handler. Consider
|
||||
the following example:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
<html:hr xmlns:html="http://www.w3.org/1999/xhtml"/>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>With the default SAX2 Namespace processing, the XML reader would
|
||||
report a start and end element event with the Namespace URI
|
||||
"http://www.w3.org/1999/xhtml" and the local name "hr". The XML
|
||||
reader might also report the original qName "html:hr", but that
|
||||
parameter might simply be an empty string.</p>
|
||||
|
||||
<!-- end of "Element Names" -->
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<h3>1.2. Attribute Names</h3>
|
||||
|
||||
<p>For attributes, you can look up the value of a named attribute
|
||||
using the <a
|
||||
href="javadoc/org/xml/sax/Attributes.html#getValue(java.lang.String, java.lang.String"
|
||||
>getValue</a> method, and you can look up the Namespace URI or local
|
||||
name of an attribute by its index using the <a href="javadoc/org/xml/sax/Attributes.html#getURI(int)">getURI</a> and
|
||||
<a href="javadoc/org/xml/sax/Attributes.html#getLocalName(int)"
|
||||
>getLocalName</a> methods (usually when you're iterating
|
||||
through the entire attribute list):</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
String rdfns = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
|
||||
String resource = atts.getValue(rdfns, "resource");
|
||||
|
||||
for (int i = 0; i < atts.getLength(); i++) {
|
||||
String uri = atts.getURI(i);
|
||||
String localName = atts.getLocalName(i);
|
||||
String value = atts.getValue(i);
|
||||
/* ... */
|
||||
}
|
||||
</pre></blockquote>
|
||||
|
||||
<!-- end of "Attribute Names" -->
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<h3>1.3. Prefix Mappings</h3>
|
||||
|
||||
<p>In addition to those events, SAX2 reports the scope of Namespace
|
||||
declarations using the <a
|
||||
href="javadoc/org/xml/sax/ContentHandler.html#startPrefixMapping(java.lang.String, java.lang.String)"
|
||||
>startPrefixMapping</a> and <a
|
||||
href="javadoc/org/xml/sax/ContentHandler.html#endPrefixMapping(java.lang.String)"
|
||||
>endPrefixMapping</a> methods, so that applications can resolve
|
||||
prefixes in attribute values or character data if necessary. The
|
||||
callbacks look like this:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
public void startPrefixMapping (String prefix, String uri)
|
||||
throws SAXException;
|
||||
public void endPrefixMapping (String prefix)
|
||||
throws SAXException;
|
||||
</pre></blockquote>
|
||||
|
||||
<p>For the above example, the XML reader would make the following
|
||||
callback <em>before</em> the start-element event:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
startPrefixMapping("html", "http://www.w3.org/1999/xhtml")
|
||||
</pre></blockquote>
|
||||
|
||||
<p>The XML reader would make the following callback <em>after</em> the
|
||||
end-element event:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
endPrefixMapping("html")
|
||||
</pre></blockquote>
|
||||
|
||||
<p>The rest of this document applies only to SAX2 applications with
|
||||
special requirements, such as text editors.</p>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2>2. Configuration</h3>
|
||||
|
||||
<div>
|
||||
<h3>2.1. Configuring Namespace Support</h3>
|
||||
|
||||
<p>The "http://xml.org/features/namespaces" feature controls general
|
||||
Namespace processing: when this feature is true (the default),
|
||||
Namespace URIs and local names must be available through the
|
||||
<var>startElement</var> and <var>endElement</var> callbacks in the <a
|
||||
href="javadoc/org/xml/sax/ContentHandler.html">ContentHandler</a>
|
||||
interface, and through the various methods in the <a
|
||||
href="javadoc/org/xml/sax/Attributes.html">Attributes</a> interface,
|
||||
and start/endPrefixMapping events must be reported.</p>
|
||||
|
||||
<p>The "http://xml.org/features/namespace-prefixes" feature controls
|
||||
the reporting of qNames and Namespace declarations (xmlns*
|
||||
attributes): when this feature is false (the default), qNames may
|
||||
optionally be reported, and xmlns* attributes must not be
|
||||
reported.</p>
|
||||
|
||||
<p>The following table summarizes the interaction of these two
|
||||
features (for general information on using features, see <a
|
||||
href="features.html">SAX2: Features and Properties</a>):</p>
|
||||
|
||||
<table border="3">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>namespaces</th>
|
||||
<th>namespace-prefixes</th>
|
||||
<th>Namespace names</th>
|
||||
<th>start/endPrefixMapping</th>
|
||||
<th>qNames</th>
|
||||
<th>xmlns* attributes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td>true</td>
|
||||
<td>false</td>
|
||||
<td>YES</td>
|
||||
<td>YES</td>
|
||||
<td>unknown</td>
|
||||
<td>NO</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>true</td>
|
||||
<td>true</td>
|
||||
<td>YES</td>
|
||||
<td>YES</td>
|
||||
<td>YES</td>
|
||||
<td>YES</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>false</td>
|
||||
<td>false</td>
|
||||
<td colspan="4" align="center">(ILLEGAL COMBINATION)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>false</td>
|
||||
<td>true</td>
|
||||
<td>unknown</td>
|
||||
<td>unknown</td>
|
||||
<td>YES</td>
|
||||
<td>YES</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p>Note <var>xmlns*</var> attributes will <strong>not</strong> be
|
||||
reported unless the <var>namespace-prefixes</var> feature is true (it
|
||||
is false by default).</p>
|
||||
|
||||
<!-- end of "Configuring Namespace Support" -->
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3>2.2. Configuration Example</h3>
|
||||
|
||||
<p>Consider the following simple sample document:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<h:hello xmlns:h="http://www.greeting.com/ns/" id="a1" h:person="David"/>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>If <var>namespaces</var> is true and <var>namespace-prefixes</var>
|
||||
is false (the default), then a SAX2 XML reader will report the
|
||||
following:</p>
|
||||
|
||||
<ul>
|
||||
<li>an element with the Namespace URI "http://www.greeting.com/ns/" and
|
||||
the local name "hello";</li>
|
||||
<li>an attribute with no Namespace URI (empty string) and the local
|
||||
name "id"; and</li>
|
||||
<li>an attribute with the Namespace URI "http://www.greeting.com/ns/"
|
||||
and the local name "person".</li>
|
||||
</ul>
|
||||
|
||||
<p>If <var>namespaces</var> is true and <var>namespace-prefixes</var>
|
||||
is true, then a SAX2 XML reader will report the following:</p>
|
||||
|
||||
<ul>
|
||||
<li>an element with the Namespace URI "http://www.greeting.com/ns/",
|
||||
the local name "hello", and the qName "h:hello";</li>
|
||||
<li>an attribute with no Namespace URI (empty string), no local name
|
||||
(empty string), and the qName "xmlns:h";</li>
|
||||
<li>an attribute with no Namespace URI (empty string), the local
|
||||
name "id", and the qName "id"; and</li>
|
||||
<li>an attribute with the Namespace URI "http://www.greeting.com/ns/",
|
||||
the local name "person", and the qName "h:person".</li>
|
||||
</ul>
|
||||
|
||||
<p>If <var>namespaces</var> is false and <var>namespace-prefixes</var>
|
||||
is true, then a SAX2 XML reader will report the following:</p>
|
||||
|
||||
<ul>
|
||||
<li>an element with the qName "h:hello";</li>
|
||||
<li>an attribute with the qName "xmlns:h";</li>
|
||||
<li>an attribute with the qName "id"; and</li>
|
||||
<li>an attribute with the qName "h:person".</li>
|
||||
</ul>
|
||||
|
||||
<!-- end of "Configuration Example" -->
|
||||
</div>
|
||||
|
||||
<!-- end of "Configuration" -->
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<address>$Id$</address>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
502
java/external/xdocs/sax/quick-start.html
vendored
502
java/external/xdocs/sax/quick-start.html
vendored
@ -1,502 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>SAX2: Quick Start</title>
|
||||
<link rel="stylesheet" type="text/css" href="sax-style.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>SAX2: Quick Start</h1>
|
||||
|
||||
<blockquote>
|
||||
<p class="copyright">This document is in the Public Domain.</p>
|
||||
</blockquote>
|
||||
|
||||
<p>This document provides a quick-start tutorial for Java programmers
|
||||
who wish to use SAX2 in their programs.</p>
|
||||
|
||||
|
||||
<div>
|
||||
<h2>Requirements</h2>
|
||||
|
||||
<p>SAX is not an XML parser.</p>
|
||||
|
||||
<p>SAX is a common interface implemented for many different XML
|
||||
parsers (and things that pose as XML parsers), just as the JDBC is a
|
||||
common interface implemented for many different relational databases
|
||||
(and things that pose as relational databases). If you want to use
|
||||
SAX, you'll need all of the following:</p>
|
||||
|
||||
<ul>
|
||||
|
||||
<li><p>Java 1.1 or higher.</p></li>
|
||||
|
||||
<li><p>The SAX2 distribution installed on your Java
|
||||
classpath.</p></li>
|
||||
|
||||
<li><p>A SAX2-compatible XML parser installed on your Java
|
||||
classpath.</p></li>
|
||||
|
||||
<li><p>The name of the SAX2 driver class in your XML parser (read the
|
||||
documentation that came with the parser, and <em>write down the class
|
||||
name</em>).</p></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<!-- end of "Requirements" -->
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<h2>Parsing a document</h2>
|
||||
|
||||
<p>Start by creating a class that extends <a
|
||||
href="javadoc/org/xml/sax/helpers/DefaultHandler.html"
|
||||
>DefaultHandler</a>:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
public class MySAXApp extends DefaultHandler
|
||||
{
|
||||
|
||||
public MySAXApp ()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
||||
</pre></blockquote>
|
||||
|
||||
<p>Now, let's assume that the SAX driver for your XML parser is named
|
||||
"com.acme.xml.SAXDriver" (this does not really exist: you
|
||||
<em>must</em> find out the name of the real driver for your parser).
|
||||
Since this is a Java application, we'll create a static
|
||||
<var>main</var> method that creates a new instance of this driver
|
||||
(note the "throws Exception" wimp-out):</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
public static void main (String args[])
|
||||
throws Exception
|
||||
{
|
||||
XMLReader xr = new com.acme.xml.SAXDriver();
|
||||
}
|
||||
</pre></blockquote>
|
||||
|
||||
<p>Alternatively, if you don't want to tie your application to a
|
||||
specific SAX driver, you can use the <a
|
||||
href="javadoc/org/xml/sax/helpers/XMLReaderFactory.html#createXMLReader()">createXMLReader</a>
|
||||
method from the <a
|
||||
href="javadoc/org/xml/sax/helpers/XMLReaderFactory.html"
|
||||
>XMLReaderFactory</a> class to choose a SAX driver dynamically:</p>
|
||||
|
||||
<blockquote><pre>
|
||||
public static void main (String args[])
|
||||
throws Exception
|
||||
{
|
||||
XMLReader xr = XMLReaderFactory.createXMLReader();
|
||||
}
|
||||
</pre></blockquote>
|
||||
|
||||
<p>In this case, it will be necessary at runtime to set the
|
||||
org.xml.sax.driver Java system property to the full classname of the
|
||||
SAX driver, as in</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
java -Dorg.xml.sax.driver=com.acme.xml.SAXDriver MySAXApp sample.xml
|
||||
</pre></blockquote>
|
||||
|
||||
<p>We can use this object to parse XML documents, but first, we have
|
||||
to register event handlers that the parser can use for reporting
|
||||
information, using the <a
|
||||
href="javadoc/org/xml/sax/XMLReader.html#setContentHandler(org.xml.sax.ContentHandler)"
|
||||
>setContentHandler</a> and <a
|
||||
href="javadoc/org/xml/sax/XMLReader.html#setErrorHandler(org.xml.sax.ErrorHandler)"
|
||||
>setErrorHandler</a> methods from the <a
|
||||
href="javadoc/org/xml/sax/XMLReader.html">XMLReader</a> interface. In
|
||||
a real-world application, the handlers will usually be separate
|
||||
objects, but for this simple demo, we've bundled the handlers into the
|
||||
top-level class, so we just have to instantiate the class and register
|
||||
it with the XML reader:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
public static void main (String args[])
|
||||
throws Exception
|
||||
{
|
||||
XMLReader xr = XMLReaderFactory.createXMLReader();
|
||||
MySAXApp handler = new MySAXApp();
|
||||
xr.setContentHandler(handler);
|
||||
xr.setErrorHandler(handler);
|
||||
}
|
||||
</pre></blockquote>
|
||||
|
||||
<p>This code creates an instance of MySAXApp to receive XML parsing
|
||||
events, and registers it with the XML reader for regular content
|
||||
events and error events (there are other kinds, but they're rarely
|
||||
used). Now, let's assume that all of the command-line args are file
|
||||
names, and we'll try to parse them one-by-one using the <a
|
||||
href="javadoc/org/xml/sax/XMLReader.html#parse(org.xml.sax.InputSource)"
|
||||
>parse</a> method from the <a
|
||||
href="javadoc/org/xml/sax/XMLReader.html"
|
||||
>XMLReader</a> interface:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
public static void main (String args[])
|
||||
throws Exception
|
||||
{
|
||||
XMLReader xr = XMLReaderFactory.createXMLReader();
|
||||
MySAXApp handler = new MySAXApp();
|
||||
xr.setContentHandler(handler);
|
||||
xr.setErrorHandler(handler);
|
||||
|
||||
// Parse each file provided on the
|
||||
// command line.
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
FileReader r = new FileReader(args[i]);
|
||||
xr.parse(new InputSource(r));
|
||||
}
|
||||
}
|
||||
</pre></blockquote>
|
||||
|
||||
<p>Note that each reader must be wrapped in an <a
|
||||
href="javadoc/org/xml/sax/InputSource.html"
|
||||
>InputSource</a> object to be parsed. Here's the whole demo class
|
||||
together (so far):</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
import java.io.FileReader;
|
||||
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.helpers.XMLReaderFactory;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
|
||||
public class MySAXApp extends DefaultHandler
|
||||
{
|
||||
|
||||
public static void main (String args[])
|
||||
throws Exception
|
||||
{
|
||||
XMLReader xr = XMLReaderFactory.createXMLReader();
|
||||
MySAXApp handler = new MySAXApp();
|
||||
xr.setContentHandler(handler);
|
||||
xr.setErrorHandler(handler);
|
||||
|
||||
// Parse each file provided on the
|
||||
// command line.
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
FileReader r = new FileReader(args[i]);
|
||||
xr.parse(new InputSource(r));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public MySAXApp ()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
</pre></blockquote>
|
||||
|
||||
<p>You can compile this code and run it (make sure you specify the SAX
|
||||
driver class in the org.xml.sax.driver property), but nothing much
|
||||
will happen unless the document contains malformed XML, because you
|
||||
have not yet set up your application to handle SAX events.</p>
|
||||
|
||||
<!-- end of "Parsing a document" -->
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<h2>Handling events</h2>
|
||||
|
||||
<p>Things get interesting when you start implementing methods to
|
||||
respond to XML parsing events (remember that we registered our class
|
||||
to receive XML parsing events in the previous section). The most
|
||||
important events are the start and end of the document, the start and
|
||||
end of elements, and character data.</p>
|
||||
|
||||
<p>To find out about the start and end of the document, the client
|
||||
application implements the <a
|
||||
href="javadoc/org/xml/sax/ContentHandler.html#startDocument()"
|
||||
>startDocument</a> and <a
|
||||
href="javadoc/org/xml/sax/ContentHandler.html#endDocument()"
|
||||
>endDocument</a> methods:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
public void startDocument ()
|
||||
{
|
||||
System.out.println("Start document");
|
||||
}
|
||||
|
||||
public void endDocument ()
|
||||
{
|
||||
System.out.println("End document");
|
||||
}
|
||||
</pre></blockquote>
|
||||
|
||||
<p>The start/endDocument event handlers take no arguments. When the
|
||||
SAX driver finds the beginning of the document, it will invoke the
|
||||
<var>startDocument</var> method once; when it finds the end, it will
|
||||
invoke the <var>endDocument</var> method once (if there have been
|
||||
errors, endDocument may not be invoked).</p>
|
||||
|
||||
<p>These examples simply print a message to standard output, but your
|
||||
application can contain any arbitrary code in these handlers: most
|
||||
commonly, the code will build some kind of an in-memory tree, produce
|
||||
output, populate a database, or extract information from the XML
|
||||
stream.</p>
|
||||
|
||||
<p>The SAX driver will signal the start and end of elements in much
|
||||
the same way, except that it will also pass some parameters to the <a
|
||||
href="javadoc/org/xml/sax/ContentHandler.html#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)">startElement</a> and <a
|
||||
href="javadoc/org/xml/sax/ContentHandler.html#endElement(java.lang.String, java.lang.String, java.lang.String)">endElement</a> methods:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
public void startElement (String uri, String name,
|
||||
String qName, Attributes atts)
|
||||
{
|
||||
System.out.println("Start element: {" + uri + "}" + name);
|
||||
}
|
||||
|
||||
public void endElement (String uri, String name, String qName)
|
||||
{
|
||||
System.out.println("End element: {" + uri + "}" + name);
|
||||
}
|
||||
</pre></blockquote>
|
||||
|
||||
<p>These methods print a message every time an element starts or ends,
|
||||
with the Namespace URI in braces before the element's local name. The
|
||||
<var>qName</var> contains the raw XML 1.0 name, and since not all
|
||||
SAX drivers will report it, it is best to ignore that parameter for
|
||||
now.</p>
|
||||
|
||||
<p>Finally, SAX2 reports regular character data through the <a
|
||||
href="javadoc/org/xml/sax/ContentHandler.html#characters(char[], int, int)"
|
||||
>characters</a> method; the following implementation will print all
|
||||
character data to the screen; it is a little longer because it
|
||||
pretty-prints the output by escaping special characters:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
public void characters (char ch[], int start, int length)
|
||||
{
|
||||
System.out.print("Characters: \"");
|
||||
for (int i = start; i < start + length; i++) {
|
||||
switch (ch[i]) {
|
||||
case '\\':
|
||||
System.out.print("\\\\");
|
||||
break;
|
||||
case '"':
|
||||
System.out.print("\\\"");
|
||||
break;
|
||||
case '\n':
|
||||
System.out.print("\\n");
|
||||
break;
|
||||
case '\r':
|
||||
System.out.print("\\r");
|
||||
break;
|
||||
case '\t':
|
||||
System.out.print("\\t");
|
||||
break;
|
||||
default:
|
||||
System.out.print(ch[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
System.out.print("\"\n");
|
||||
}
|
||||
</pre></blockquote>
|
||||
|
||||
<p>Note that a SAX driver is free to chunk the character data any way
|
||||
it wants, so you cannot count on all of the character data content of
|
||||
an element arriving in a single <var>characters</var> event.</p>
|
||||
|
||||
<!-- end of "Handling events" -->
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<h2>Sample SAX2 application</h2>
|
||||
|
||||
<p>Here is the complete sample application (again, in a serious app
|
||||
the event handlers would probably be implemented in a separate
|
||||
class):</p>
|
||||
|
||||
<blockquote><pre>
|
||||
import java.io.FileReader;
|
||||
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.helpers.XMLReaderFactory;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
|
||||
public class MySAXApp extends DefaultHandler
|
||||
{
|
||||
|
||||
public static void main (String args[])
|
||||
throws Exception
|
||||
{
|
||||
XMLReader xr = XMLReaderFactory.createXMLReader();
|
||||
MySAXApp handler = new MySAXApp();
|
||||
xr.setContentHandler(handler);
|
||||
xr.setErrorHandler(handler);
|
||||
|
||||
// Parse each file provided on the
|
||||
// command line.
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
FileReader r = new FileReader(args[i]);
|
||||
xr.parse(new InputSource(r));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public MySAXApp ()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Event handlers.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public void startDocument ()
|
||||
{
|
||||
System.out.println("Start document");
|
||||
}
|
||||
|
||||
|
||||
public void endDocument ()
|
||||
{
|
||||
System.out.println("End document");
|
||||
}
|
||||
|
||||
|
||||
public void startElement (String uri, String name,
|
||||
String qName, Attributes atts)
|
||||
{
|
||||
System.out.println("Start element: {" + uri + "}" + name);
|
||||
}
|
||||
|
||||
|
||||
public void endElement (String uri, String name, String qName)
|
||||
{
|
||||
System.out.println("End element: {" + uri + "}" + name);
|
||||
}
|
||||
|
||||
|
||||
public void characters (char ch[], int start, int length)
|
||||
{
|
||||
System.out.print("Characters: \"");
|
||||
for (int i = start; i < start + length; i++) {
|
||||
switch (ch[i]) {
|
||||
case '\\':
|
||||
System.out.print("\\\\");
|
||||
break;
|
||||
case '"':
|
||||
System.out.print("\\\"");
|
||||
break;
|
||||
case '\n':
|
||||
System.out.print("\\n");
|
||||
break;
|
||||
case '\r':
|
||||
System.out.print("\\r");
|
||||
break;
|
||||
case '\t':
|
||||
System.out.print("\\t");
|
||||
break;
|
||||
default:
|
||||
System.out.print(ch[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
System.out.print("\"\n");
|
||||
}
|
||||
|
||||
}
|
||||
</pre></blockquote>
|
||||
|
||||
<!-- end of "Sample SAX2 application" -->
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<h2>Sample Output</h2>
|
||||
|
||||
<p>Consider the following XML document:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<poem xmlns="http://www.megginson.com/ns/exp/poetry">
|
||||
<title>Roses are Red</title>
|
||||
<l>Roses are red,</l>
|
||||
<l>Violets are blue;</l>
|
||||
<l>Sugar is sweet,</l>
|
||||
<l>And I love you.</l>
|
||||
</poem>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>If this document is named <code>roses.xml</code> and there is a
|
||||
SAX2 driver on your classpath named
|
||||
<code>com.acme.xml.SAXDriver</code> (this driver does not actually
|
||||
exist), you can invoke the sample application like this:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
java -Dcom.acme.xml.SAXDriver MySAXApp roses.xml
|
||||
</pre></blockquote>
|
||||
|
||||
<p>When you run this, you'll get output something like this:</p>
|
||||
|
||||
<blockquote><pre xml:space="preserve">
|
||||
Start document
|
||||
Start element: {http://www.megginson.com/ns/exp/poetry}poem
|
||||
Characters: "\n"
|
||||
Start element: {http://www.megginson.com/ns/exp/poetry}title
|
||||
Characters: "Roses are Red"
|
||||
End element: {http://www.megginson.com/ns/exp/poetry}title
|
||||
Characters: "\n"
|
||||
Start element: {http://www.megginson.com/ns/exp/poetry}l
|
||||
Characters: "Roses are red,"
|
||||
End element: {http://www.megginson.com/ns/exp/poetry}l
|
||||
Characters: "\n"
|
||||
Start element: {http://www.megginson.com/ns/exp/poetry}l
|
||||
Characters: "Violets are blue;"
|
||||
End element: {http://www.megginson.com/ns/exp/poetry}l
|
||||
Characters: "\n"
|
||||
Start element: {http://www.megginson.com/ns/exp/poetry}l
|
||||
Characters: "Sugar is sweet,"
|
||||
End element: {http://www.megginson.com/ns/exp/poetry}l
|
||||
Characters: "\n"
|
||||
Start element: {http://www.megginson.com/ns/exp/poetry}l
|
||||
Characters: "And I love you."
|
||||
End element: {http://www.megginson.com/ns/exp/poetry}l
|
||||
Characters: "\n"
|
||||
End element: {http://www.megginson.com/ns/exp/poetry}poem
|
||||
End document
|
||||
</pre></blockquote>
|
||||
|
||||
<p>Note that even a short document generates (at least) 25 events: one
|
||||
for the start and end of each of the six elements used (or, if you
|
||||
prefer, one for each start tag and one for each end tag), one of each
|
||||
of the eleven chunks of character data (including whitespace between
|
||||
elements), one for the start of the document, and one for the end.</p>
|
||||
|
||||
<!-- end of "Sample Output" -->
|
||||
</div>
|
||||
|
||||
|
||||
<hr />
|
||||
|
||||
<address>$Id$</address>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
25
java/external/xdocs/sax/sax-style.css
vendored
25
java/external/xdocs/sax/sax-style.css
vendored
@ -1,25 +0,0 @@
|
||||
body {
|
||||
background: white;
|
||||
}
|
||||
|
||||
h1, h2, h3 {
|
||||
font-family: arial, sans-serif;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 207%;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 173%;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 144%;
|
||||
}
|
||||
|
||||
p.copyright {
|
||||
color: green;
|
||||
font-style: italic;
|
||||
}
|
||||
39
java/external/xdocs/sax/sax.html
vendored
39
java/external/xdocs/sax/sax.html
vendored
@ -1,39 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>SAX 2.0/Java</title>
|
||||
<link rel="stylesheet" type="text/css" href="sax-style.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>SAX 2.0/Java</h1>
|
||||
|
||||
<blockquote>
|
||||
<p class="copyright">This document is in the Public Domain.</p>
|
||||
</blockquote>
|
||||
|
||||
<p>SAX2 is a new Java-based release of SAX, the <cite>Simple API for
|
||||
XML</cite>. A C++ version (at least) is planned as well. SAX2
|
||||
introduces configurable features and properties and adds support for
|
||||
XML Namespaces; it includes adapters so that SAX1 parsers and
|
||||
applications can interoperate with SAX2.</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="quick-start.html">Quick start</a></li>
|
||||
<li><a href="changes.html">Changes from SAX 1.0</a></li>
|
||||
<li><a href="features.html">Features and Properties</a></li>
|
||||
<li><a href="namespaces.html">Namespaces</a></li>
|
||||
<li><a href="filters.html">Filters</a></li>
|
||||
<li><a href="javadoc/index.html">API Documentation</a></li>
|
||||
<li><a href="http://www.megginson.com/SAX/Java/sax2.zip"
|
||||
>Download SAX 2.0 final release for Java</a></li>
|
||||
</ul>
|
||||
|
||||
<hr />
|
||||
|
||||
<address>$Id$</address>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user