1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Mozilla Public License Version
6
* 1.1 (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/MPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is TransforMiiX XSLT processor.
17
* The Initial Developer of the Original Code is
19
* Portions created by the Initial Developer are Copyright (C) 2002
20
* Jonas Sicking. All Rights Reserved.
23
* Jonas Sicking <jonas@sicking.cc>
25
* Alternatively, the contents of this file may be used under the terms of
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
27
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
* in which case the provisions of the GPL or the LGPL are applicable instead
29
* of those above. If you wish to allow use of your version of this file only
30
* under the terms of either the GPL or the LGPL, and not to allow others to
31
* use your version of this file under the terms of the MPL, indicate your
32
* decision by deleting the provisions above and replace them with the notice
33
* and other provisions required by the GPL or the LGPL. If you do not delete
34
* the provisions above, a recipient may use your version of this file under
35
* the terms of any one of the MPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
39
#ifndef TRANSFRMX_TXEXECUTIONSTATE_H
40
#define TRANSFRMX_TXEXECUTIONSTATE_H
43
#include "baseutils.h"
44
#include "txXMLEventHandler.h"
47
#include "nsVoidArray.h"
48
#include "txIXPathContext.h"
49
#include "txVariableMap.h"
50
#include "nsTHashtable.h"
51
#include "nsHashKeys.h"
53
#include "txStylesheet.h"
56
class txIOutputHandlerFactory;
57
class txExpandedNameMap;
59
class txLoadedDocumentEntry : public nsStringHashKey
62
txLoadedDocumentEntry(KeyTypePointer aStr) : nsStringHashKey(aStr)
65
txLoadedDocumentEntry(const txLoadedDocumentEntry& aToCopy)
66
: nsStringHashKey(aToCopy)
68
NS_ERROR("We're horked.");
70
~txLoadedDocumentEntry()
73
txXPathNodeUtils::release(mDocument);
77
nsAutoPtr<txXPathNode> mDocument;
80
class txLoadedDocumentsHash : public nsTHashtable<txLoadedDocumentEntry>
83
~txLoadedDocumentsHash();
84
nsresult init(txXPathNode* aSourceDocument);
87
friend class txExecutionState;
88
txXPathNode* mSourceDocument;
92
class txExecutionState : public txIMatchContext
95
txExecutionState(txStylesheet* aStylesheet);
97
nsresult init(const txXPathNode& aNode, txExpandedNameMap* aGlobalParams);
100
TX_DECL_MATCH_CONTEXT;
103
* Struct holding information about a current template rule
105
struct TemplateRule {
106
txStylesheet::ImportFrame* mFrame;
108
nsIAtom* mModeLocalName;
109
txVariableMap* mParams;
113
nsresult pushEvalContext(txIEvalContext* aContext);
114
txIEvalContext* popEvalContext();
115
nsresult pushString(const nsAString& aStr);
116
void popString(nsAString& aStr);
117
nsresult pushInt(PRInt32 aInt);
119
nsresult pushResultHandler(txAXMLEventHandler* aHandler);
120
txAXMLEventHandler* popResultHandler();
121
nsresult pushTemplateRule(txStylesheet::ImportFrame* aFrame,
122
const txExpandedName& aMode,
123
txVariableMap* aParams);
124
void popTemplateRule();
125
nsresult pushParamMap(txVariableMap* aParams);
126
txVariableMap* popParamMap();
128
// state-getting functions
129
txIEvalContext* getEvalContext();
130
txExpandedNameMap* getParamMap();
131
const txXPathNode* retrieveDocument(const nsAString& aUri);
132
nsresult getKeyNodes(const txExpandedName& aKeyName,
133
const txXPathNode& aDocument,
134
const nsAString& aKeyValue, PRBool aIndexIfNotFound,
135
txNodeSet** aResult);
136
TemplateRule* getCurrentTemplateRule();
138
// state-modification functions
139
txInstruction* getNextInstruction();
140
nsresult runTemplate(txInstruction* aInstruction);
141
nsresult runTemplate(txInstruction* aInstruction,
142
txInstruction* aReturnTo);
143
void gotoInstruction(txInstruction* aNext);
144
void returnFromTemplate();
145
nsresult bindVariable(const txExpandedName& aName,
146
txAExprResult* aValue);
147
void removeVariable(const txExpandedName& aName);
149
txAXMLEventHandler* mOutputHandler;
150
txAXMLEventHandler* mResultHandler;
151
txAOutputHandlerFactory* mOutputHandlerFactory;
153
nsAutoPtr<txVariableMap> mTemplateParams;
155
nsRefPtr<txStylesheet> mStylesheet;
158
txStack mReturnStack;
159
txStack mLocalVarsStack;
160
txStack mEvalContextStack;
162
txStack mResultHandlerStack;
164
nsStringArray mStringStack;
165
txInstruction* mNextInstruction;
166
txVariableMap* mLocalVariables;
167
txVariableMap mGlobalVariableValues;
168
nsRefPtr<txAExprResult> mGlobalVarPlaceholderValue;
169
PRInt32 mRecursionDepth;
171
TemplateRule* mTemplateRules;
172
PRInt32 mTemplateRulesBufferSize;
173
PRInt32 mTemplateRuleCount;
175
txIEvalContext* mEvalContext;
176
txIEvalContext* mInitialEvalContext;
177
//Document* mRTFDocument;
178
txExpandedNameMap* mGlobalParams;
180
txLoadedDocumentsHash mLoadedDocuments;
182
nsRefPtr<txResultRecycler> mRecycler;
184
static const PRInt32 kMaxRecursionDepth;