Back to index

lightning-sunbird  0.9+nobinonly
txToplevelItems.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  * Jonas Sicking.
00019  * Portions created by the Initial Developer are Copyright (C) 2002
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Jonas Sicking <jonas@sicking.cc>
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_TXTOPLEVELITEMS_H
00040 #define TRANSFRMX_TXTOPLEVELITEMS_H
00041 
00042 #include "txError.h"
00043 #include "txOutputFormat.h"
00044 #include "XMLUtils.h"
00045 #include "txStylesheet.h"
00046 #include "txInstructions.h"
00047 
00048 class txPattern;
00049 class Expr;
00050 
00051 class txToplevelItem
00052 {
00053 public:
00054     virtual ~txToplevelItem()
00055     {
00056     }
00057 
00058     enum type {
00059         attributeSet,
00060         dummy,
00061         import,
00062         //namespaceAlias,
00063         output,
00064         stripSpace, //also used for preserve-space
00065         templ,
00066         variable
00067     };
00068 
00069     virtual type getType() = 0;
00070 };
00071 
00072 #define TX_DECL_TOPLEVELITEM virtual type getType();
00073 #define TX_IMPL_GETTYPE(_class, _type) \
00074 txToplevelItem::type \
00075 _class::getType() { return _type;}
00076 
00077 class txInstructionContainer : public txToplevelItem
00078 {
00079 public:
00080     nsAutoPtr<txInstruction> mFirstInstruction;
00081 };
00082 
00083 // xsl:attribute-set
00084 class txAttributeSetItem : public txInstructionContainer
00085 {
00086 public:
00087     txAttributeSetItem(const txExpandedName aName) : mName(aName)
00088     {
00089     }
00090 
00091     TX_DECL_TOPLEVELITEM
00092 
00093     txExpandedName mName;
00094 };
00095 
00096 // xsl:import
00097 class txImportItem : public txToplevelItem
00098 {
00099 public:
00100     TX_DECL_TOPLEVELITEM
00101 
00102     nsAutoPtr<txStylesheet::ImportFrame> mFrame;
00103 };
00104 
00105 // xsl:output
00106 class txOutputItem : public txToplevelItem
00107 {
00108 public:
00109     TX_DECL_TOPLEVELITEM
00110 
00111     txOutputFormat mFormat;
00112 };
00113 
00114 // insertionpoint for xsl:include
00115 class txDummyItem : public txToplevelItem
00116 {
00117 public:
00118     TX_DECL_TOPLEVELITEM
00119 };
00120 
00121 // xsl:strip-space and xsl:preserve-space
00122 class txStripSpaceItem : public txToplevelItem
00123 {
00124 public:
00125     virtual ~txStripSpaceItem();
00126 
00127     TX_DECL_TOPLEVELITEM
00128 
00129     nsresult addStripSpaceTest(txStripSpaceTest* aStripSpaceTest);
00130 
00131     nsVoidArray mStripSpaceTests;
00132 };
00133 
00134 // xsl:template
00135 class txTemplateItem : public txInstructionContainer
00136 {
00137 public:
00138     txTemplateItem(nsAutoPtr<txPattern> aMatch, const txExpandedName& aName,
00139                    const txExpandedName& aMode, double aPrio);
00140 
00141     TX_DECL_TOPLEVELITEM
00142 
00143     nsAutoPtr<txPattern> mMatch;
00144     txExpandedName mName;
00145     txExpandedName mMode;
00146     double mPrio;
00147 };
00148 
00149 // xsl:variable at top level
00150 class txVariableItem : public txInstructionContainer
00151 {
00152 public:
00153     txVariableItem(const txExpandedName& aName, nsAutoPtr<Expr> aValue,
00154                    PRBool aIsParam);
00155     
00156     TX_DECL_TOPLEVELITEM
00157 
00158     txExpandedName mName;
00159     nsAutoPtr<Expr> mValue;
00160     PRBool mIsParam;
00161 };
00162 
00163 #endif //TRANSFRMX_TXTOPLEVELITEMS_H