Back to index

lightning-sunbird  0.9+nobinonly
txXMLEventHandler.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is TransforMiiX XSLT processor code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Keith Visco.
00019  * Portions created by the Initial Developer are Copyright (C) 1999
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Keith Visco <kvisco@ziplink.net>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #ifndef TRANSFRMX_XML_EVENT_HANDLER_H
00040 #define TRANSFRMX_XML_EVENT_HANDLER_H
00041 
00042 #include "txCore.h"
00043 
00044 class txOutputFormat;
00045 
00046 #ifdef TX_EXE
00047 #include <iostream.h>
00048 #else
00049 #define kTXNameSpaceURI "http://www.mozilla.org/TransforMiix"
00050 #define kTXWrapper "transformiix:result"
00051 
00052 class nsIDOMDocument;
00053 #endif
00054 
00060 class txAXMLEventHandler
00061 {
00062 public:
00063     virtual ~txAXMLEventHandler() {};
00064 
00072     virtual void attribute(const nsAString& aName,
00073                            const PRInt32 aNsID,
00074                            const nsAString& aValue) = 0;
00075 
00082     virtual void characters(const nsAString& aData, PRBool aDOE) = 0;
00083 
00089     virtual void comment(const nsAString& aData) = 0;
00090 
00095     virtual void endDocument(nsresult aResult) = 0;
00096 
00103     virtual void endElement(const nsAString& aName,
00104                             const PRInt32 aNsID) = 0;
00105 
00112     virtual void processingInstruction(const nsAString& aTarget, 
00113                                        const nsAString& aData) = 0;
00114 
00118     virtual void startDocument() = 0;
00119 
00126     virtual void startElement(const nsAString& aName,
00127                               const PRInt32 aNsID) = 0;
00128 };
00129 
00130 #define TX_DECL_TXAXMLEVENTHANDLER                                          \
00131     virtual void attribute(const nsAString& aName, const PRInt32 aNsID,     \
00132                            const nsAString& aValue);                        \
00133     virtual void characters(const nsAString& aData, PRBool aDOE);           \
00134     virtual void comment(const nsAString& aData);                           \
00135     virtual void endDocument(nsresult aResult = NS_OK);                     \
00136     virtual void endElement(const nsAString& aName, const PRInt32 aNsID);   \
00137     virtual void processingInstruction(const nsAString& aTarget,            \
00138                                        const nsAString& aData);             \
00139     virtual void startDocument();                                           \
00140     virtual void startElement(const nsAString& aName, const PRInt32 aNsID);
00141 
00142 
00143 #ifdef TX_EXE
00144 typedef txAXMLEventHandler txAOutputXMLEventHandler;
00145 #define TX_DECL_TXAOUTPUTXMLEVENTHANDLER
00146 #else
00147 class txAOutputXMLEventHandler : public txAXMLEventHandler
00148 {
00149 public:
00155     virtual void getOutputDocument(nsIDOMDocument** aDocument) = 0;
00156 };
00157 
00158 #define TX_DECL_TXAOUTPUTXMLEVENTHANDLER                        \
00159     virtual void getOutputDocument(nsIDOMDocument** aDocument);
00160 #endif
00161 
00165 class txAOutputHandlerFactory
00166 {
00167 public:
00168     virtual ~txAOutputHandlerFactory() {};
00169 
00175     virtual nsresult
00176     createHandlerWith(txOutputFormat* aFormat,
00177                       txAXMLEventHandler** aHandler) = 0;
00178 
00187     virtual nsresult
00188     createHandlerWith(txOutputFormat* aFormat,
00189                       const nsAString& aName,
00190                       PRInt32 aNsID,
00191                       txAXMLEventHandler** aHandler) = 0;
00192 };
00193 
00194 #define TX_DECL_TXAOUTPUTHANDLERFACTORY                        \
00195     nsresult createHandlerWith(txOutputFormat* aFormat,        \
00196                                txAXMLEventHandler** aHandler); \
00197     nsresult createHandlerWith(txOutputFormat* aFormat,        \
00198                                const nsAString& aName,         \
00199                                PRInt32 aNsID,                  \
00200                                txAXMLEventHandler** aHandler);
00201 
00202 #endif