You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by jp...@locus.apache.org on 2000/08/02 20:02:35 UTC
cvs commit: xml-xerces/c/src/sax2 Attributes.hpp ContentHandler.hpp DefaultHandler.hpp Makefile.in sax2Dummy.cpp SAX2XMLReader.hpp XMLReaderFactory.hpp
jpolast 00/08/02 11:02:35
Added: c/src/sax2 Attributes.hpp ContentHandler.hpp
DefaultHandler.hpp Makefile.in sax2Dummy.cpp
SAX2XMLReader.hpp XMLReaderFactory.hpp
Log:
initial checkin of sax2 implementation
submitted by Simon Fell (simon@fell.com)
and Joe Polastre (jpolast@apache.org)
Revision Changes Path
1.1 xml-xerces/c/src/sax2/Attributes.hpp
Index: Attributes.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: Attributes.hpp,v $
* Revision 1.1 2000/08/02 18:02:34 jpolast
* initial checkin of sax2 implementation
* submitted by Simon Fell (simon@fell.com)
* and Joe Polastre (jpolast@apache.org)
*
*
*/
#ifndef ATTRIBUTES_HPP
#define ATTRIBUTES_HPP
#include <util/XercesDefs.hpp>
/**
* Interface for an element's attribute specifications.
*
* The SAX2 parser implements this interface and passes an instance
* to the SAX2 application as the last argument of each startElement
* event.
*
* The instance provided will return valid results only during the
* scope of the startElement invocation (to save it for future
* use, the application must make a copy: the AttributesImpl
* helper class provides a convenient constructor for doing so).
*
* An Attributes includes only attributes that have been
* specified or defaulted: #IMPLIED attributes will not be included.
*
* There are two ways for the SAX application to obtain information
* from the Attributes. First, it can iterate through the entire
* list:
*
* <pre>
* public void startElement (String uri, String localpart, String QName, Attributes atts) {
* for (int i = 0; i < atts.getLength(); i++) {
* String Qname = atts.getQName(i);
* String URI = atts.getURI(i)
* String local = atts.GetLocalName(i)
* String type = atts.getType(i);
* String value = atts.getValue(i);
* [...]
* }
* }
* </pre>
*
* (Note that the result of getLength() will be zero if there
* are no attributes.)
*
* As an alternative, the application can request the value or
* type of specific attributes:
*
* <pre>
* public void startElement (String uri, String localpart, String QName, Attributes atts) {
* String identifier = atts.getValue("id");
* String label = atts.getValue("label");
* [...]
* }
* </pre>
*
* The AttributesImpl helper class provides a convenience
* implementation for use by parser or application writers.
*
* @see Sax2DocumentHandler#startElement
* @see AttributesImpl#AttributesImpl
*/
class SAX_EXPORT Attributes
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
/** Default constructor */
Attributes()
{
}
/** Destructor */
virtual ~Attributes()
{
}
//@}
/** @name The virtual attribute list interface */
//@{
/**
* Return the number of attributes in this list.
*
* The SAX parser may provide attributes in any
* arbitrary order, regardless of the order in which they were
* declared or specified. The number of attributes may be
* zero.
*
* @return The number of attributes in the list.
*/
virtual unsigned int getLength() const = 0;
/**
* Return the namespace URI of an attribute in this list (by position).
*
* The QNames must be unique: the SAX parser shall not include the
* same attribute twice. Attributes without values (those declared
* #IMPLIED without a value specified in the start tag) will be
* omitted from the list.
*
* @param index The index of the attribute in the list (starting at 0).
* @return The URI of the indexed attribute, or null
* if the index is out of range.
* @see #getLength
*/
virtual const XMLCh* getURI(const unsigned int index) = 0;
/**
* Return the local name of an attribute in this list (by position).
*
* The QNames must be unique: the SAX parser shall not include the
* same attribute twice. Attributes without values (those declared
* #IMPLIED without a value specified in the start tag) will be
* omitted from the list.
*
* @param index The index of the attribute in the list (starting at 0).
* @return The local name of the indexed attribute, or null
* if the index is out of range.
* @see #getLength
*/
virtual const XMLCh* getLocalName(const unsigned int index) const = 0;
/**
* Return the QName of an attribute in this list (by position).
*
* The QNames must be unique: the SAX parser shall not include the
* same attribute twice. Attributes without values (those declared
* #IMPLIED without a value specified in the start tag) will be
* omitted from the list.
*
* @param index The index of the attribute in the list (starting at 0).
* @return The QName of the indexed attribute, or null
* if the index is out of range.
* @see #getLength
*/
virtual const XMLCh* getQName(const unsigned int index) const = 0;
/**
* Return the type of an attribute in the list (by position).
*
* The attribute type is one of the strings "CDATA", "ID",
* "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",
* or "NOTATION" (always in upper case).
*
* If the parser has not read a declaration for the attribute,
* or if the parser does not report attribute types, then it must
* return the value "CDATA" as stated in the XML 1.0 Recommentation
* (clause 3.3.3, "Attribute-Value Normalization").
*
* For an enumerated attribute that is not a notation, the
* parser will report the type as "NMTOKEN".
*
* @param index The index of the attribute in the list (starting at 0).
* @return The attribute type as a string, or
* null if the index is out of range.
* @see #getLength
* @see #getType(String)
*/
virtual const XMLCh* getType(const unsigned int index) const = 0;
/**
* Return the value of an attribute in the list (by position).
*
* If the attribute value is a list of tokens (IDREFS,
* ENTITIES, or NMTOKENS), the tokens will be concatenated
* into a single string separated by whitespace.
*
* @param index The index of the attribute in the list (starting at 0).
* @return The attribute value as a string, or
* null if the index is out of range.
* @see #getLength
* @see #getValue(XMLCh*)
*/
virtual const XMLCh* getValue(const unsigned int index) const = 0;
////////////////////////////////////////////////////////////////////
// Name-based query.
////////////////////////////////////////////////////////////////////
/**
* Look up the index of an attribute by Namespace name.
*
* @param uri The Namespace URI, or the empty string if
* the name has no Namespace URI.
* @param localName The attribute's local name.
* @return The index of the attribute, or -1 if it does not
* appear in the list.
*/
virtual int getIndex(const XMLCh* const uri, const XMLCh* const localPart ) const = 0 ;
/**
* Look up the index of an attribute by XML 1.0 qualified name.
*
* @param qName The qualified (prefixed) name.
* @return The index of the attribute, or -1 if it does not
* appear in the list.
*/
virtual int getIndex(const XMLCh* const QName ) const = 0 ;
/**
* Look up an attribute's type by Namespace name.
*
* <p>See #getType for a description of the possible types.</p>
*
* @param uri The Namespace URI, or the empty String if the
* name has no Namespace URI.
* @param localName The local name of the attribute.
* @return The attribute type as a string, or null if the
* attribute is not in the list or if Namespace
* processing is not being performed.
*/
virtual const XMLCh* getType(const XMLCh* const uri, const XMLCh* const localPart ) const = 0 ;
/**
* Look up an attribute's type by XML 1.0 qualified name.
*
* <p>See #getType for a description of the possible types.</p>
*
* @param qName The XML 1.0 qualified name.
* @return The attribute type as a string, or null if the
* attribute is not in the list or if qualified names
* are not available.
*/
virtual const XMLCh* getType(const XMLCh* const QName) const = 0;
/**
* Look up an attribute's value by Namespace name.
*
* <p>See #getValue for a description of the possible values.</p>
*
* @param uri The Namespace URI, or the empty String if the
* name has no Namespace URI.
* @param localPart The local name of the attribute.
* @return The attribute value as a string, or null if the
* attribute is not in the list.
*/
virtual const XMLCh* getValue(const XMLCh* const uri, const XMLCh* const localPart ) const = 0 ;
/**
* Look up an attribute's value by XML 1.0 qualified name.
*
* <p>See #getValue for a description of the possible values.</p>
*
* @param qName The XML 1.0 qualified name.
* @return The attribute value as a string, or null if the
* attribute is not in the list or if qualified names
* are not available.
*/
virtual const XMLCh* getValue(const XMLCh* const QName) const = 0;
//@}
private :
/* Constructors and operators */
/* Copy constructor */
Attributes(const Attributes&);
/* Assignment operator */
void operator=(const Attributes&);
};
#endif
1.1 xml-xerces/c/src/sax2/ContentHandler.hpp
Index: ContentHandler.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: ContentHandler.hpp,v $
* Revision 1.1 2000/08/02 18:02:34 jpolast
* initial checkin of sax2 implementation
* submitted by Simon Fell (simon@fell.com)
* and Joe Polastre (jpolast@apache.org)
*
*
*/
#ifndef CONTENTHANDLER_HPP
#define CONTENTHANDLER_HPP
#include <util/XercesDefs.hpp>
class Attributes;
class Locator;
/**
* Receive notification of general document events.
*
* <p>This is the main interface that most SAX2 applications
* implement: if the application needs to be informed of basic parsing
* events, it implements this interface and registers an instance with
* the SAX2 parser using the setDocumentHandler method. The parser
* uses the instance to report basic document-related events like
* the start and end of elements and character data.</p>
*
* <p>The order of events in this interface is very important, and
* mirrors the order of information in the document itself. For
* example, all of an element's content (character data, processing
* instructions, and/or subelements) will appear, in order, between
* the startElement event and the corresponding endElement event.</p>
*
* <p>Application writers who do not want to implement the entire
* interface while can derive a class from Sax2HandlerBase, which implements
* the default functionality; parser writers can instantiate
* Sax2HandlerBase to obtain a default handler. The application can find
* the location of any document event using the Locator interface
* supplied by the Parser through the setDocumentLocator method.</p>
*
* @see Parser#setDocumentHandler
* @see Locator#Locator
* @see Sax2HandlerBase#Sax2HandlerBase
*/
class SAX_EXPORT ContentHandler
{
public:
/** @name Constructors and Destructor */
//@{
/** Default constructor */
ContentHandler()
{
}
/** Destructor */
virtual ~ContentHandler()
{
}
//@}
/** @name The virtual document handler interface */
//@{
/**
* Receive notification of character data.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param chars The characters from the XML document.
* @param length The number of characters to read from the array.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see Locator#Locator
*/
virtual void characters
(
const XMLCh* const chars
, const unsigned int length
) = 0;
/**
* Receive notification of the end of a document.
*
* <p>The SAX parser will invoke this method only once, and it will
* be the last method invoked during the parse. The parser shall
* not invoke this method until it has either abandoned parsing
* (because of an unrecoverable error) or reached the end of
* input.</p>
*
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void endDocument () = 0;
/**
* Receive notification of the end of an element.
*
* <p>The SAX parser will invoke this method at the end of every
* element in the XML document; there will be a corresponding
* startElement() event for every endElement() event (even when the
* element is empty).</p>
*
* @param uri The URI of the asscioated namespace for this element
* @param localname The local part of the element name
* @param qname The QName of this element
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void endElement
(
const XMLCh* const uri,
const XMLCh* const localname,
const XMLCh* const qname
) = 0;
/**
* Receive notification of ignorable whitespace in element content.
*
* <p>Validating Parsers must use this method to report each chunk
* of ignorable whitespace (see the W3C XML 1.0 recommendation,
* section 2.10): non-validating parsers may also use this method
* if they are capable of parsing and using content models.</p>
*
* <p>SAX parsers may return all contiguous whitespace in a single
* chunk, or they may split it into several chunks; however, all of
* the characters in any single event must come from the same
* external entity, so that the Locator provides useful
* information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* @param chars The characters from the XML document.
* @param length The number of characters to read from the array.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #characters
*/
virtual void ignorableWhitespace
(
const XMLCh* const chars
, const unsigned int length
) = 0;
/**
* Receive notification of a processing instruction.
*
* <p>The Parser will invoke this method once for each processing
* instruction found: note that processing instructions may occur
* before or after the main document element.</p>
*
* <p>A SAX parser should never report an XML declaration (XML 1.0,
* section 2.8) or a text declaration (XML 1.0, section 4.3.1)
* using this method.</p>
*
* @param target The processing instruction target.
* @param data The processing instruction data, or null if
* none was supplied.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void processingInstruction
(
const XMLCh* const target
, const XMLCh* const data
) = 0;
/**
* Reset the Docuemnt object on its reuse
*
* <p>This method helps in reseting the document implementational
* defaults each time the document is begun.</p>
*
*/
virtual void resetDocument() = 0;
/**
* Receive an object for locating the origin of SAX document events.
*
* SAX parsers are strongly encouraged (though not absolutely
* required) to supply a locator: if it does so, it must supply
* the locator to the application by invoking this method before
* invoking any of the other methods in the DocumentHandler
* interface.
*
* The locator allows the application to determine the end
* position of any document-related event, even if the parser is
* not reporting an error. Typically, the application will
* use this information for reporting its own errors (such as
* character content that does not match an application's
* business rules). The information returned by the locator
* is probably not sufficient for use with a search engine.
*
* Note that the locator will return correct information only
* during the invocation of the events in this interface. The
* application should not attempt to use it at any other time.
*
* @param locator An object that can return the location of
* any SAX document event. The object is only
* 'on loan' to the client code and they are not
* to attempt to delete or modify it in any way!
*
* @see Locator#Locator
*/
virtual void setDocumentLocator(const Locator* const locator) = 0;
/**
* Receive notification of the beginning of a document.
*
* <p>The SAX parser will invoke this method only once, before any
* other methods in this interface or in DTDHandler (except for
* setDocumentLocator).</p>
*
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void startDocument() = 0;
/**
* Receive notification of the beginning of an element.
*
* <p>The Parser will invoke this method at the beginning of every
* element in the XML document; there will be a corresponding
* endElement() event for every startElement() event (even when the
* element is empty). All of the element's content will be
* reported, in order, before the corresponding endElement()
* event.</p>
*
* <p>Note that the attribute list provided will
* contain only attributes with explicit values (specified or
* defaulted): #IMPLIED attributes will be omitted.</p>
*
* @param uri The URI of the asscioated namespace for this element
* @param localname The local part of the element name
* @param qname The QName of this element
* @param attrs The attributes attached to the element, if any.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #endElement
* @see Attributes#Attributes
*/
virtual void startElement
(
const XMLCh* const uri,
const XMLCh* const localname,
const XMLCh* const qname
, Attributes& attrs
) = 0;
/**
* Receive notification of the start of an namespace prefix mapping.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the start of
* each namespace prefix mapping.</p>
*
* @param prefix The namespace prefix used
* @param uri The namespace URI used.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void startPrefixMapping
(
const XMLCh* const prefix,
const XMLCh* const uri
) = 0 ;
/**
* Receive notification of the end of an namespace prefix mapping.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the end of
* each namespace prefix mapping.</p>
*
* @param prefix The namespace prefix used
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void endPrefixMapping
(
const XMLCh* const prefix
) = 0 ;
//@}
/**
* Receive notification of a skipped entity
*
* <p>The parser will invoke this method once for each entity
* skipped. All processors may skip external entities,
* depending on the values of the features:<br>
* http://xml.org/sax/features/external-general-entities<br>
* http://xml.org/sax/features/external-parameter-entities</p>
*
* <p>Note: Xerces (specifically) never skips any entities, regardless
* of the above features. This function is never called in the
* Xerces implementation of SAX2.</p>
*
* <p>Introduced with SAX2</p>
*
* @param name The name of the skipped entity. If it is a parameter entity,
* the name will begin with %, and if it is the external DTD subset,
* it will be the string [dtd].
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void skippedEntity
(
const XMLCh* const name
) = 0 ;
//@}
private :
/* Unimplemented Constructors and operators */
/* Copy constructor */
ContentHandler(const ContentHandler&);
/** Assignment operator */
void operator=(const ContentHandler&);
};
#endif
1.1 xml-xerces/c/src/sax2/DefaultHandler.hpp
Index: DefaultHandler.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: DefaultHandler.hpp,v $
* Revision 1.1 2000/08/02 18:02:34 jpolast
* initial checkin of sax2 implementation
* submitted by Simon Fell (simon@fell.com)
* and Joe Polastre (jpolast@apache.org)
*
*
*/
#ifndef DEFAULTHANDLER_HPP
#define DEFAULTHANDLER_HPP
#include <sax2/ContentHandler.hpp>
#include <sax/DTDHandler.hpp>
#include <sax/EntityResolver.hpp>
#include <sax/ErrorHandler.hpp>
#include <sax/SAXParseException.hpp>
class Locator;
class Attributes;
/**
* Default base class for SAX2 handlers.
*
* <p>This class implements the default behaviour for four SAX2
* interfaces: EntityResolver, DTDHandler, Sax2DocumentHandler,
* and ErrorHandler.</p>
*
* <p>Application writers can extend this class when they need to
* implement only part of an interface; parser writers can
* instantiate this class to provide default handlers when the
* application has not supplied its own.</p>
*
* <p>Note that the use of this class is optional.</p>
*
* @see EntityResolver#EntityResolver
* @see DTDHandler#DTDHandler
* @see ContentHandler#ContentHandler
* @see ErrorHandler#ErrorHandler
*/
class SAX_EXPORT DefaultHandler :
public EntityResolver,
public DTDHandler,
public ContentHandler,
public ErrorHandler
{
public:
/** @name Default handlers for the DocumentHandler interface */
//@{
/**
* Receive notification of character data inside an element.
*
* <p>By default, do nothing. Application writers may override this
* method to take specific actions for each chunk of character data
* (such as adding the data to a node or buffer, or printing it to
* a file).</p>
*
* @param chars The characters.
* @param length The number of characters to use from the
* character array.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DocumentHandler#characters
*/
virtual void characters
(
const XMLCh* const chars
, const unsigned int length
);
/**
* Receive notification of the end of the document.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the beginning
* of a document (such as finalising a tree or closing an output
* file).</p>
*
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DocumentHandler#endDocument
*/
virtual void endDocument();
/**
* Receive notification of the end of an element.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the end of
* each element (such as finalising a tree node or writing
* output to a file).</p>
*
* @param uri The URI of the asscioated namespace for this element
* @param localname The local part of the element name
* @param qname The QName of this element
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DocumentHandler#endElement
*/
virtual void endElement
(
const XMLCh* const uri,
const XMLCh* const localname,
const XMLCh* const qname
);
/**
* Receive notification of ignorable whitespace in element content.
*
* <p>By default, do nothing. Application writers may override this
* method to take specific actions for each chunk of ignorable
* whitespace (such as adding data to a node or buffer, or printing
* it to a file).</p>
*
* @param chars The whitespace characters.
* @param length The number of characters to use from the
* character array.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DocumentHandler#ignorableWhitespace
*/
virtual void ignorableWhitespace
(
const XMLCh* const chars
, const unsigned int length
);
/**
* Receive notification of a processing instruction.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions for each
* processing instruction, such as setting status variables or
* invoking other methods.</p>
*
* @param target The processing instruction target.
* @param data The processing instruction data, or null if
* none is supplied.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DocumentHandler#processingInstruction
*/
virtual void processingInstruction
(
const XMLCh* const target
, const XMLCh* const data
);
/**
* Reset the Docuemnt object on its reuse
*
* @see DocumentHandler#resetDocument
*/
virtual void resetDocument();
//@}
/** @name Default implementation of DocumentHandler interface */
//@{
/**
* Receive a Locator object for document events.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass if they wish to store the locator for use
* with other document events.</p>
*
* @param locator A locator for all SAX document events.
* @see DocumentHandler#setDocumentLocator
* @see Locator
*/
virtual void setDocumentLocator(const Locator* const locator);
/**
* Receive notification of the beginning of the document.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the beginning
* of a document (such as allocating the root node of a tree or
* creating an output file).</p>
*
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DocumentHandler#startDocument
*/
virtual void startDocument();
/**
* Receive notification of the start of an element.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the start of
* each element (such as allocating a new tree node or writing
* output to a file).</p>
*
* @param uri The URI of the asscioated namespace for this element
* @param localname the local part of the element name
* @param qname the QName of this element
* @param attributes The specified or defaulted attributes.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DocumentHandler#startElement
*/
virtual void startElement
(
const XMLCh* const uri,
const XMLCh* const localname,
const XMLCh* const qname
, Attributes& attrs
);
/**
* Receive notification of the start of an namespace prefix mapping.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the start of
* each namespace prefix mapping.</p>
*
* NOTE : The current Implementation of SAX2Parser will _NEVER_ call this
*
* @param prefix The namespace prefix used
* @param uri The namespace URI used.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DocumentHandler#startPrefixMapping
*/
virtual void startPrefixMapping
(
const XMLCh* const prefix,
const XMLCh* const uri
) ;
/**
* Receive notification of the end of an namespace prefix mapping.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the end of
* each namespace prefix mapping.</p>
*
* NOTE : The current Implementation of SAX2Parser will _NEVER_ call this
*
* @param prefix The namespace prefix used
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DocumentHandler#endPrefixMapping
*/
virtual void endPrefixMapping
(
const XMLCh* const prefix
) ;
/**
* Receive notification of a skipped entity
*
* <p>The parser will invoke this method once for each entity
* skipped. All processors may skip external entities,
* depending on the values of the features:<br>
* http://xml.org/sax/features/external-general-entities<br>
* http://xml.org/sax/features/external-parameter-entities</p>
*
* <p>Introduced with SAX2</p>
*
* @param name The name of the skipped entity. If it is a parameter entity,
* the name will begin with %, and if it is the external DTD subset,
* it will be the string [dtd].
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void skippedEntity
(
const XMLCh* const name
) ;
//@}
/** @name Default implementation of the EntityResolver interface. */
//@{
/**
* Resolve an external entity.
*
* <p>Always return null, so that the parser will use the system
* identifier provided in the XML document. This method implements
* the SAX default behaviour: application writers can override it
* in a subclass to do special translations such as catalog lookups
* or URI redirection.</p>
*
* @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 SAXException Any SAX exception, possibly
* wrapping another exception.
* @see EntityResolver#resolveEntity
*/
virtual InputSource* resolveEntity
(
const XMLCh* const publicId
, const XMLCh* const systemId
);
//@}
/** @name Default implementation of the ErrorHandler interface */
//@{
/**
* Receive notification of a recoverable parser error.
*
* <p>The default implementation does nothing. Application writers
* may override this method in a subclass to take specific actions
* for each error, such as inserting the message in a log file or
* printing it to the console.</p>
*
* @param exception The warning information encoded as an exception.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see ErrorHandler#warning
* @see SAXParseException#SAXParseException
*/
virtual void error(const SAXParseException& exception);
/**
* Report a fatal XML parsing error.
*
* <p>The default implementation throws a SAXParseException.
* Application writers may override this method in a subclass if
* they need to take specific actions for each fatal error (such as
* collecting all of the errors into a single report): in any case,
* the application must stop all regular processing when this
* method is invoked, since the document is no longer reliable, and
* the parser may no longer report parsing events.</p>
*
* @param e The error information encoded as an exception.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see ErrorHandler#fatalError
* @see SAXParseException#SAXParseException
*/
virtual void fatalError(const SAXParseException& exception);
/**
* Receive notification of a parser warning.
*
* <p>The default implementation does nothing. Application writers
* may override this method in a subclass to take specific actions
* for each warning, such as inserting the message in a log file or
* printing it to the console.</p>
*
* @param e The warning information encoded as an exception.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see ErrorHandler#warning
* @see SAXParseException#SAXParseException
*/
virtual void warning(const SAXParseException& exception);
/**
* Reset the Error handler object on its reuse
*
* @see ErrorHandler#resetErrors
*/
virtual void resetErrors();
//@}
/** @name Default implementation of DTDHandler interface. */
//@{
/**
* Receive notification of a notation declaration.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass if they wish to keep track of the notations
* declared in a document.</p>
*
* @param name The notation name.
* @param publicId The notation public identifier, or null if not
* available.
* @param systemId The notation system identifier.
* @see DTDHandler#notationDecl
*/
virtual void notationDecl
(
const XMLCh* const name
, const XMLCh* const publicId
, const XMLCh* const systemId
);
/**
* Reset the DTD object on its reuse
*
* @see DTDHandler#resetDocType
*/
virtual void resetDocType();
/**
* Receive notification of an unparsed entity declaration.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to keep track of the unparsed entities
* declared in a document.</p>
*
* @param name The entity name.
* @param publicId The entity public identifier, or null if not
* available.
* @param systemId The entity system identifier.
* @param notationName The name of the associated notation.
* @see DTDHandler#unparsedEntityDecl
*/
virtual void unparsedEntityDecl
(
const XMLCh* const name
, const XMLCh* const publicId
, const XMLCh* const systemId
, const XMLCh* const notationName
);
//@}
};
// ---------------------------------------------------------------------------
// HandlerBase: Inline default implementations
// ---------------------------------------------------------------------------
inline void DefaultHandler::characters(const XMLCh* const chars
,const unsigned int length)
{
}
inline void DefaultHandler::endDocument()
{
}
inline void DefaultHandler::endElement(const XMLCh* const uri
, const XMLCh* const localname
, const XMLCh* const qname)
{
}
inline void DefaultHandler::error(const SAXParseException& exception)
{
}
inline void DefaultHandler::fatalError(const SAXParseException& exception)
{
throw exception;
}
inline void
DefaultHandler::ignorableWhitespace( const XMLCh* const chars
, const unsigned int length)
{
}
inline void DefaultHandler::notationDecl( const XMLCh* const name
, const XMLCh* const publicId
, const XMLCh* const systemId)
{
}
inline void
DefaultHandler::processingInstruction( const XMLCh* const target
, const XMLCh* const data)
{
}
inline void DefaultHandler::resetErrors()
{
}
inline void DefaultHandler::resetDocument()
{
}
inline void DefaultHandler::resetDocType()
{
}
inline InputSource*
DefaultHandler::resolveEntity( const XMLCh* const publicId
, const XMLCh* const systemId)
{
return 0;
}
inline void
DefaultHandler::unparsedEntityDecl(const XMLCh* const name
, const XMLCh* const publicId
, const XMLCh* const systemId
, const XMLCh* const notationName)
{
}
inline void DefaultHandler::setDocumentLocator(const Locator* const locator)
{
}
inline void DefaultHandler::startDocument()
{
}
inline void
DefaultHandler::startElement( const XMLCh* const uri
, const XMLCh* const localname
, const XMLCh* const qname
, Attributes& attrs
)
{
}
inline void DefaultHandler::warning(const SAXParseException& exception)
{
}
inline void DefaultHandler::startPrefixMapping ( const XMLCh* const prefix
,const XMLCh* const uri)
{
}
inline void DefaultHandler::endPrefixMapping ( const XMLCh* const prefix )
{
}
inline void DefaultHandler::skippedEntity ( const XMLCh* const name )
{
}
#endif // ! DEFAULTHANDLER_HPP
1.1 xml-xerces/c/src/sax2/Makefile.in
Index: Makefile.in
===================================================================
#
# The Apache Software License, Version 1.1
#
# Copyright (c) 1999-2000 The Apache Software Foundation. All rights
# reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# 3. The end-user documentation included with the redistribution,
# if any, must include the following acknowledgment:
# "This product includes software developed by the
# Apache Software Foundation (http://www.apache.org/)."
# Alternately, this acknowledgment may appear in the software itself,
# if and wherever such third-party acknowledgments normally appear.
#
# 4. The names "Xerces" and "Apache Software Foundation" must
# not be used to endorse or promote products derived from this
# software without prior written permission. For written
# permission, please contact apache\@apache.org.
#
# 5. Products derived from this software may not be called "Apache",
# nor may "Apache" appear in their name, without prior written
# permission of the Apache Software Foundation.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# ====================================================================
#
# This software consists of voluntary contributions made by many
# individuals on behalf of the Apache Software Foundation, and was
# originally based on software copyright (c) 1999, International
# Business Machines, Inc., http://www.ibm.com . For more information
# on the Apache Software Foundation, please see
# <http://www.apache.org/>.
#
#
# $Id: Makefile.in,v 1.1 2000/08/02 18:02:35 jpolast Exp $
#
PLATFORM = @platform@
CC = @cc@
CXX = @cxx@
CXXFLAGS = @cxxflags@
CFLAGS = @cflags@
PREFIX = @prefix@
LDFLAGS = @ldflags@
LIBS = @libs@
OSVER = @osver@
USELIBWWW = @uselibwww@
MESSAGELOADER = @messageloader@
TRANSCODER = @transcoder@
include ../Makefile.incl
MODULE = sax2
SAX2_CPP_PUBHEADERS = \
Attributes.hpp \
ContentHandler.hpp \
DefaultHandler.hpp \
SAX2XMLReader.hpp \
XMLReaderFactory.hpp
SAX2_CPP_PRIVHEADERS =
SAX2_C_FILES =
SAX2_CPP_OBJECTS = \
sax2Dummy.$(TO) \
all:: includes $(SAX2_CPP_OBJECTS)
includes:: pubheaders $(SAX2_C_FILES)
pubheaders::
-mkdir -p $(XML_INC_DIR)/$(MODULE)
$(CP) $(SAX2_CPP_PUBHEADERS) $(SAX2_C_FILES) $(XML_INC_DIR)/$(MODULE)
# this may generate unnecessary dependencies, but it makes life easier
depend:: includes
$(MAKE_DEPEND) $(XML_INCL) *.cpp > $(DEPFILE)
clean::
@echo "Making clean in $(MODULE) ..."
$(RM2) $(addprefix $(XML_OBJ_DIR)/,$(SAX2_CPP_OBJECTS))
distclean:: clean
$(RM) Makefile $(DEPFILE)
@echo "Removing all $(MODULE) header files ..."
$(RM2) $(addprefix $(XML_INC_DIR)/$(MODULE)/,$(SAX2_CPP_PUBHEADERS))
install::
-mkdir -p $(PREFIX)/$(MODULE)
$(CP) $(SAX2_CPP_PUBHEADERS) $(SAX2_C_FILES) $(PREFIX)/$(MODULE)
1.1 xml-xerces/c/src/sax2/sax2Dummy.cpp
Index: sax2Dummy.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: sax2Dummy.cpp,v $
* Revision 1.1 2000/08/02 18:02:35 jpolast
* initial checkin of sax2 implementation
* submitted by Simon Fell (simon@fell.com)
* and Joe Polastre (jpolast@apache.org)
*
*
*/
#include <sax2/SAX2XMLReader.hpp>
#include <sax2/XMLReaderFactory.hpp>
#include <sax2/ContentHandler.hpp>
#include <sax2/DefaultHandler.hpp>
#include <sax2/Attributes.hpp>
1.1 xml-xerces/c/src/sax2/SAX2XMLReader.hpp
Index: SAX2XMLReader.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: SAX2XMLReader.hpp,v $
* Revision 1.1 2000/08/02 18:02:35 jpolast
* initial checkin of sax2 implementation
* submitted by Simon Fell (simon@fell.com)
* and Joe Polastre (jpolast@apache.org)
*
*
*/
#ifndef SAX2XMLReader_HPP
#define SAX2XMLReader_HPP
#include <util/XercesDefs.hpp>
#include <util/XMLUniDefs.hpp>
class ContentHandler ;
class DTDHandler;
class EntityResolver;
class ErrorHandler;
class InputSource;
class SAX_EXPORT SAX2XMLReader
{
public:
/** @name Constructors and Destructor */
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
//@{
/** The default constructor */
SAX2XMLReader()
{
}
/** The destructor */
virtual ~SAX2XMLReader()
{
}
//@}
//-----------------------------------------------------------------------
// The XMLReader interface
//-----------------------------------------------------------------------
/** @name The XMLReader interfaces */
//@{
/**
* This method returns the installed content handler. Suitable
* for 'lvalue' usages.
*
* @return The pointer to the installed content handler object.
*/
virtual ContentHandler* getContentHandler() = 0 ;
/**
* This method returns the installed content handler. Suitable
* only for 'rvalue' usages.
*
* @return A const pointer to the installed content handler object.
*/
virtual const ContentHandler* getContentHandler() const = 0 ;
virtual DTDHandler* getDTDHandler() = 0;
virtual const DTDHandler* getDTDHandler() const = 0;
/**
* This method returns the installed entity resolver. Suitable
* for 'lvalue' usages.
*
* @return The pointer to the installed entity resolver object.
*/
virtual EntityResolver* getEntityResolver() = 0 ;
/**
* This method returns the installed entity resolver. Suitable
* for 'rvalue' usages.
*
* @return A const pointer to the installed entity resolver object.
*/
virtual const EntityResolver* getEntityResolver() const = 0 ;
/**
* This method returns the installed error handler. Suitable
* for 'lvalue' usages.
*
* @return The pointer to the installed error handler object.
*/
virtual ErrorHandler* getErrorHandler() = 0 ;
/**
* This method returns the installed error handler. Suitable
* for 'rvalue' usages.
*
* @return A const pointer to the installed error handler object.
*/
virtual const ErrorHandler* getErrorHandler() const = 0 ;
/**
* This method gets a Feature as per the SAX2 spec (such as
* do validation)
*
* @param name The name of the feature to be set
* @param value true if the feature should be enabled.
*/
virtual const bool getFeature(const XMLCh* const name) = 0 ;
/**
* Gets the value of a property.
*
* @param name The property name, which is any fully-qualified URI.
*/
virtual const void* const getProperty(const XMLCh* const name) = 0 ;
/**
* Parse an XML document.
*
* The application can use this method to instruct the SAX parser
* to begin parsing an XML document from any valid input
* source (a character stream, a byte stream, or a URI).
*
* Applications may not invoke this method while a parse is in
* progress (they should create a new Parser instead for each
* additional XML document). Once a parse is complete, an
* application may reuse the same Parser object, possibly with a
* different input source.
*
* @param source The input source for the top-level of the
* XML document.
* @param reuseValidator Indicates whether the validator should be
* reused, ignoring any external subset. If true, there
* cannot be any internal subset.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @exception XMLException An exception from the parser or client
* handler code.
* @see InputSource#InputSource
* @see #setEntityResolver
* @see #setDTDHandler
* @see #setDocumentHandler
* @see #setErrorHandler
*/
virtual void parse
(
const InputSource& source
, const bool reuseValidator = false
) = 0;
/**
* Parse an XML document from a system identifier (URI).
*
* This method is a shortcut for the common case of reading a
* document from a system identifier. It is the exact equivalent
* of the following:
*
* parse(new URLInputSource(systemId));
*
* If the system identifier is a URL, it must be fully resolved
* by the application before it is passed to the parser.
*
* @param systemId The system identifier (URI).
* @param reuseValidator Indicates whether the validator should be
* reused, ignoring any external subset. If true, there
* cannot be any internal subset.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @exception XMLException An exception from the parser or client
* handler code.
* @see #parse(InputSource)
*/
virtual void parse
(
const XMLCh* const systemId
, const bool reuseValidator = false
) = 0;
/**
* Parse an XML document from a system identifier (URI).
*
* This method is a shortcut for the common case of reading a
* document from a system identifier. It is the exact equivalent
* of the following:
*
* parse(new URLInputSource(systemId));
*
* If the system identifier is a URL, it must be fully resolved
* by the application before it is passed to the parser.
*
* @param systemId The system identifier (URI).
* @param reuseValidator Indicates whether the validator should be
* reused, ignoring any external subset. If true, there
* cannot be any internal subset.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @exception XMLException An exception from the parser or client
* handler code.
* @see #parse(InputSource)
*/
virtual void parse
(
const char* const systemId
, const bool reuseValidator = false
) = 0;
/**
* Allow an application to register a document event handler.
*
* If the application does not register a document handler, all
* document events reported by the SAX parser will be silently
* ignored (this is the default behaviour implemented by
* HandlerBase).
*
* Applications may register a new or different handler in the
* middle of a parse, and the SAX parser must begin using the new
* handler immediately.
*
* @param handler The document handler.
* @see DocumentHandler#DocumentHandler
* @see HandlerBase#HandlerBase
*/
virtual void setContentHandler(ContentHandler* const handler) = 0;
/**
* Allow an application to register a DTD event handler.
*
* If the application does not register a DTD handler, all DTD
* events reported by the SAX parser will be silently ignored (this
* is the default behaviour implemented by HandlerBase).
*
* Applications may register a new or different handler in the middle
* of a parse, and the SAX parser must begin using the new handler
* immediately.
*
* @param handler The DTD handler.
* @see DTDHandler#DTDHandler
* @see HandlerBase#HandlerBase
*/
virtual void setDTDHandler(DTDHandler* const handler) = 0;
/**
* Allow an application to register a custom entity resolver.
*
* If the application does not register an entity resolver, the
* SAX parser will resolve system identifiers and open connections
* to entities itself (this is the default behaviour implemented in
* DefaultHandler).
*
* Applications may register a new or different entity resolver
* in the middle of a parse, and the SAX parser must begin using
* the new resolver immediately.
*
* @param resolver The object for resolving entities.
* @see EntityResolver#EntityResolver
* @see DefaultHandler#DefaultHandler
*/
virtual void setEntityResolver(EntityResolver* const resolver) = 0;
/**
* Allow an application to register an error event handler.
*
* If the application does not register an error event handler,
* all error events reported by the SAX parser will be silently
* ignored, except for fatalError, which will throw a SAXException
* (this is the default behaviour implemented by HandlerBase).
*
* Applications may register a new or different handler in the
* middle of a parse, and the SAX parser must begin using the new
* handler immediately.
*
* @param handler The error handler.
* @see ErrorHandler#ErrorHandler
* @see SAXException#SAXException
* @see HandlerBase#HandlerBase
*/
virtual void setErrorHandler(ErrorHandler* const handler) = 0;
/**
* This method sets a Feature as per the SAX2 spec (such as
* do validation)
*
* @param name The name of the feature to be set
* @param value true if the feature should be enabled.
*/
virtual void setFeature(const XMLCh* const name, const bool value) = 0;
/**
* Set the value of a property.
*
* @param name The property name, which is any fully-qualified URI.
* @param value The requested value for the property.
*/
virtual void setProperty(const XMLCh* const name, const void* const value) = 0 ;
//@}
private :
/* The copy constructor, you cannot call this directly */
SAX2XMLReader(const SAX2XMLReader&);
/* The assignment operator, you cannot call this directly */
void operator=(const SAX2XMLReader&);
};
#endif
1.1 xml-xerces/c/src/sax2/XMLReaderFactory.hpp
Index: XMLReaderFactory.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache\@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation, and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com . For more information
* on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/*
* $Log: XMLReaderFactory.hpp,v $
* Revision 1.1 2000/08/02 18:02:35 jpolast
* initial checkin of sax2 implementation
* submitted by Simon Fell (simon@fell.com)
* and Joe Polastre (jpolast@apache.org)
*
*
*/
#ifndef XMLREADERFACTORY_HPP
#define XMLREADERFACTORY_HPP
#include <parsers/SAX2XMLReaderImpl.hpp>
#include <sax/SAXException.hpp>
class SAX_EXPORT XMLReaderFactory
{
private:
XMLReaderFactory() ;
~XMLReaderFactory() ;
public:
static SAX2XMLReader * createXMLReader() ;
static SAX2XMLReader * createXMLReader(const XMLCh* className) ;
};
inline SAX2XMLReader * XMLReaderFactory::createXMLReader()
{
return (SAX2XMLReader*)(new SAX2XMLReaderImpl());
}
inline SAX2XMLReader * XMLReaderFactory::createXMLReader(const XMLCh * className)
{
throw SAXNotSupportedException();
// unimplemented
return 0;
}
#endif