зеркало из https://github.com/mozilla/pjs.git
Fix for bug 157142 (link transformiix standalone to XPCOM). Better txStack and remove use of NamedMap for documents. r=sicking, sr=jst.
This commit is contained in:
Родитель
99731a1216
Коммит
80ed9721a4
|
@ -58,7 +58,6 @@ LOBJS = ../source/base/Double.$(OBJ_SUFFIX) \
|
||||||
../source/base/Map.$(OBJ_SUFFIX) \
|
../source/base/Map.$(OBJ_SUFFIX) \
|
||||||
../source/base/NamedMap.$(OBJ_SUFFIX) \
|
../source/base/NamedMap.$(OBJ_SUFFIX) \
|
||||||
../source/base/SimpleErrorObserver.$(OBJ_SUFFIX) \
|
../source/base/SimpleErrorObserver.$(OBJ_SUFFIX) \
|
||||||
../source/base/Stack.$(OBJ_SUFFIX) \
|
|
||||||
../source/base/txAtoms.$(OBJ_SUFFIX) \
|
../source/base/txAtoms.$(OBJ_SUFFIX) \
|
||||||
../source/base/txExpandedNameMap.$(OBJ_SUFFIX) \
|
../source/base/txExpandedNameMap.$(OBJ_SUFFIX) \
|
||||||
../source/base/txURIUtils.$(OBJ_SUFFIX) \
|
../source/base/txURIUtils.$(OBJ_SUFFIX) \
|
||||||
|
|
|
@ -1090,13 +1090,6 @@
|
||||||
<FILEKIND>Text</FILEKIND>
|
<FILEKIND>Text</FILEKIND>
|
||||||
<FILEFLAGS></FILEFLAGS>
|
<FILEFLAGS></FILEFLAGS>
|
||||||
</FILE>
|
</FILE>
|
||||||
<FILE>
|
|
||||||
<PATHTYPE>Name</PATHTYPE>
|
|
||||||
<PATH>Stack.cpp</PATH>
|
|
||||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
|
||||||
<FILEKIND>Text</FILEKIND>
|
|
||||||
<FILEFLAGS></FILEFLAGS>
|
|
||||||
</FILE>
|
|
||||||
<FILE>
|
<FILE>
|
||||||
<PATHTYPE>Name</PATHTYPE>
|
<PATHTYPE>Name</PATHTYPE>
|
||||||
<PATH>XMLUtils.cpp</PATH>
|
<PATH>XMLUtils.cpp</PATH>
|
||||||
|
@ -1632,11 +1625,6 @@
|
||||||
<PATH>ExprLexer.cpp</PATH>
|
<PATH>ExprLexer.cpp</PATH>
|
||||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||||
</FILEREF>
|
</FILEREF>
|
||||||
<FILEREF>
|
|
||||||
<PATHTYPE>Name</PATHTYPE>
|
|
||||||
<PATH>Stack.cpp</PATH>
|
|
||||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
|
||||||
</FILEREF>
|
|
||||||
<FILEREF>
|
<FILEREF>
|
||||||
<PATHTYPE>Name</PATHTYPE>
|
<PATHTYPE>Name</PATHTYPE>
|
||||||
<PATH>XMLUtils.cpp</PATH>
|
<PATH>XMLUtils.cpp</PATH>
|
||||||
|
@ -2950,13 +2938,6 @@
|
||||||
<FILEKIND>Text</FILEKIND>
|
<FILEKIND>Text</FILEKIND>
|
||||||
<FILEFLAGS></FILEFLAGS>
|
<FILEFLAGS></FILEFLAGS>
|
||||||
</FILE>
|
</FILE>
|
||||||
<FILE>
|
|
||||||
<PATHTYPE>Name</PATHTYPE>
|
|
||||||
<PATH>Stack.cpp</PATH>
|
|
||||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
|
||||||
<FILEKIND>Text</FILEKIND>
|
|
||||||
<FILEFLAGS></FILEFLAGS>
|
|
||||||
</FILE>
|
|
||||||
<FILE>
|
<FILE>
|
||||||
<PATHTYPE>Name</PATHTYPE>
|
<PATHTYPE>Name</PATHTYPE>
|
||||||
<PATH>XMLUtils.cpp</PATH>
|
<PATH>XMLUtils.cpp</PATH>
|
||||||
|
@ -3508,11 +3489,6 @@
|
||||||
<PATH>ExprLexer.cpp</PATH>
|
<PATH>ExprLexer.cpp</PATH>
|
||||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||||
</FILEREF>
|
</FILEREF>
|
||||||
<FILEREF>
|
|
||||||
<PATHTYPE>Name</PATHTYPE>
|
|
||||||
<PATH>Stack.cpp</PATH>
|
|
||||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
|
||||||
</FILEREF>
|
|
||||||
<FILEREF>
|
<FILEREF>
|
||||||
<PATHTYPE>Name</PATHTYPE>
|
<PATHTYPE>Name</PATHTYPE>
|
||||||
<PATH>XMLUtils.cpp</PATH>
|
<PATH>XMLUtils.cpp</PATH>
|
||||||
|
@ -3925,12 +3901,6 @@
|
||||||
<PATH>SimpleErrorObserver.cpp</PATH>
|
<PATH>SimpleErrorObserver.cpp</PATH>
|
||||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||||
</FILEREF>
|
</FILEREF>
|
||||||
<FILEREF>
|
|
||||||
<TARGETNAME>transformiixDebug.shlb</TARGETNAME>
|
|
||||||
<PATHTYPE>Name</PATHTYPE>
|
|
||||||
<PATH>Stack.cpp</PATH>
|
|
||||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
|
||||||
</FILEREF>
|
|
||||||
<FILEREF>
|
<FILEREF>
|
||||||
<TARGETNAME>transformiixDebug.shlb</TARGETNAME>
|
<TARGETNAME>transformiixDebug.shlb</TARGETNAME>
|
||||||
<PATHTYPE>Name</PATHTYPE>
|
<PATHTYPE>Name</PATHTYPE>
|
||||||
|
|
|
@ -47,7 +47,6 @@ CPPSRCS = Double.cpp \
|
||||||
Map.cpp \
|
Map.cpp \
|
||||||
NamedMap.cpp \
|
NamedMap.cpp \
|
||||||
SimpleErrorObserver.cpp \
|
SimpleErrorObserver.cpp \
|
||||||
Stack.cpp \
|
|
||||||
txAtoms.cpp \
|
txAtoms.cpp \
|
||||||
txExpandedNameMap.cpp \
|
txExpandedNameMap.cpp \
|
||||||
txURIUtils.cpp
|
txURIUtils.cpp
|
||||||
|
|
|
@ -0,0 +1,154 @@
|
||||||
|
//* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/* ***** BEGIN LICENSE BLOCK *****
|
||||||
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is mozilla.org code.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Netscape Communications Corporation.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Peter Van der Beken <peterv@netscape.com> (original author)
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||||
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||||
|
* of those above. If you wish to allow use of your version of this file only
|
||||||
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||||
|
* use your version of this file under the terms of the MPL, indicate your
|
||||||
|
* decision by deleting the provisions above and replace them with the notice
|
||||||
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||||
|
* the provisions above, a recipient may use your version of this file under
|
||||||
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||||
|
*
|
||||||
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
#ifndef txStack_h___
|
||||||
|
#define txStack_h___
|
||||||
|
|
||||||
|
#include "nsVoidArray.h"
|
||||||
|
|
||||||
|
class txStack : private nsVoidArray
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Returns the specified object from the top of this stack,
|
||||||
|
* without removing it from the stack.
|
||||||
|
*
|
||||||
|
* @return a pointer to the object that is the top of this stack.
|
||||||
|
*/
|
||||||
|
void* peek()
|
||||||
|
{
|
||||||
|
PRInt32 count = Count() - 1;
|
||||||
|
NS_ENSURE_TRUE(count >= 0, nsnull);
|
||||||
|
|
||||||
|
return ElementAt(count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the specified object to the top of this stack.
|
||||||
|
*
|
||||||
|
* @param obj a pointer to the object that is to be added to the
|
||||||
|
* top of this stack.
|
||||||
|
*/
|
||||||
|
nsresult push(void* aObject)
|
||||||
|
{
|
||||||
|
return AppendElement(aObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes and returns the specified object from the top of this
|
||||||
|
* stack.
|
||||||
|
*
|
||||||
|
* @return a pointer to the object that was the top of this stack.
|
||||||
|
*/
|
||||||
|
void* pop()
|
||||||
|
{
|
||||||
|
PRInt32 count = Count() - 1;
|
||||||
|
NS_ENSURE_TRUE(count >= 0, nsnull);
|
||||||
|
|
||||||
|
void* object = ElementAt(count);
|
||||||
|
RemoveElementAt(count);
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if there are no objects in the stack.
|
||||||
|
*
|
||||||
|
* @return true if there are no objects in the stack.
|
||||||
|
*/
|
||||||
|
PRBool isEmpty()
|
||||||
|
{
|
||||||
|
return (Count() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of elements in the Stack.
|
||||||
|
*
|
||||||
|
* @return the number of elements in the Stack.
|
||||||
|
*/
|
||||||
|
PRInt32 size()
|
||||||
|
{
|
||||||
|
return Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class txStackIterator;
|
||||||
|
};
|
||||||
|
|
||||||
|
class txStackIterator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Creates an iterator for the given stack.
|
||||||
|
*
|
||||||
|
* @param aStack the stack to create an iterator for.
|
||||||
|
*/
|
||||||
|
txStackIterator(txStack* aStack) : mStack(aStack),
|
||||||
|
mPosition(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if there is more objects on the stack.
|
||||||
|
*
|
||||||
|
* @return .
|
||||||
|
*/
|
||||||
|
PRBool hasNext()
|
||||||
|
{
|
||||||
|
return (mPosition < mStack->Count());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the next object pointer from the stack.
|
||||||
|
*
|
||||||
|
* @return .
|
||||||
|
*/
|
||||||
|
void* next()
|
||||||
|
{
|
||||||
|
if (mPosition == mStack->Count()) {
|
||||||
|
return nsnull;
|
||||||
|
}
|
||||||
|
return mStack->ElementAt(mPosition++);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
txStack* mStack;
|
||||||
|
PRUint32 mPosition;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* txStack_h___ */
|
|
@ -39,7 +39,6 @@ OBJS = ../base/Double.$(OBJ_SUFFIX) \
|
||||||
../base/Map.$(OBJ_SUFFIX) \
|
../base/Map.$(OBJ_SUFFIX) \
|
||||||
../base/NamedMap.$(OBJ_SUFFIX) \
|
../base/NamedMap.$(OBJ_SUFFIX) \
|
||||||
../base/SimpleErrorObserver.$(OBJ_SUFFIX) \
|
../base/SimpleErrorObserver.$(OBJ_SUFFIX) \
|
||||||
../base/Stack.$(OBJ_SUFFIX) \
|
|
||||||
../base/txAtoms.$(OBJ_SUFFIX) \
|
../base/txAtoms.$(OBJ_SUFFIX) \
|
||||||
../base/txExpandedNameMap.$(OBJ_SUFFIX) \
|
../base/txExpandedNameMap.$(OBJ_SUFFIX) \
|
||||||
../base/txStringUtils.$(OBJ_SUFFIX) \
|
../base/txStringUtils.$(OBJ_SUFFIX) \
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#include "ExprParser.h"
|
#include "ExprParser.h"
|
||||||
#include "ExprLexer.h"
|
#include "ExprLexer.h"
|
||||||
#include "FunctionLib.h"
|
#include "FunctionLib.h"
|
||||||
#include "Stack.h"
|
#include "txStack.h"
|
||||||
#include "txAtoms.h"
|
#include "txAtoms.h"
|
||||||
#include "txIXPathContext.h"
|
#include "txIXPathContext.h"
|
||||||
#include "txStringUtils.h"
|
#include "txStringUtils.h"
|
||||||
|
@ -235,8 +235,8 @@ Expr* ExprParser::createExpr(ExprLexer& lexer, txIParseContext* aContext)
|
||||||
|
|
||||||
Expr* expr = 0;
|
Expr* expr = 0;
|
||||||
|
|
||||||
Stack exprs;
|
txStack exprs;
|
||||||
Stack ops;
|
txStack ops;
|
||||||
|
|
||||||
while (!done) {
|
while (!done) {
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ Expr* ExprParser::createExpr(ExprLexer& lexer, txIParseContext* aContext)
|
||||||
case Token::MULTIPLY_OP:
|
case Token::MULTIPLY_OP:
|
||||||
case Token::SUBTRACTION_OP:
|
case Token::SUBTRACTION_OP:
|
||||||
{
|
{
|
||||||
while (!exprs.empty() &&
|
while (!exprs.isEmpty() &&
|
||||||
precedenceLevel(tok->type)
|
precedenceLevel(tok->type)
|
||||||
<= precedenceLevel(((Token*)ops.peek())->type)) {
|
<= precedenceLevel(((Token*)ops.peek())->type)) {
|
||||||
expr = createBinaryExpr((Expr*)exprs.pop(),
|
expr = createBinaryExpr((Expr*)exprs.pop(),
|
||||||
|
@ -300,13 +300,13 @@ Expr* ExprParser::createExpr(ExprLexer& lexer, txIParseContext* aContext)
|
||||||
|
|
||||||
// make sure expr != 0
|
// make sure expr != 0
|
||||||
if (!expr) {
|
if (!expr) {
|
||||||
while (!exprs.empty()) {
|
while (!exprs.isEmpty()) {
|
||||||
delete (Expr*)exprs.pop();
|
delete (Expr*)exprs.pop();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!exprs.empty()) {
|
while (!exprs.isEmpty()) {
|
||||||
expr = createBinaryExpr((Expr*)exprs.pop(), expr, (Token*)ops.pop());
|
expr = createBinaryExpr((Expr*)exprs.pop(), expr, (Token*)ops.pop());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,78 @@
|
||||||
#include "txVariableMap.h"
|
#include "txVariableMap.h"
|
||||||
#include "XSLTProcessor.h"
|
#include "XSLTProcessor.h"
|
||||||
|
|
||||||
|
|
||||||
|
DHASH_WRAPPER(txLoadedDocumentsBase, txLoadedDocumentEntry, nsAString&)
|
||||||
|
|
||||||
|
txLoadedDocumentsHash::txLoadedDocumentsHash(Document* aSourceDocument,
|
||||||
|
Document* aStyleDocument)
|
||||||
|
: mSourceDocument(aSourceDocument),
|
||||||
|
mStyleDocument(aStyleDocument)
|
||||||
|
{
|
||||||
|
if (NS_FAILED(Init(8))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mSourceDocument) {
|
||||||
|
Add(mSourceDocument);
|
||||||
|
}
|
||||||
|
if (mStyleDocument) {
|
||||||
|
Add(mStyleDocument);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
txLoadedDocumentsHash::~txLoadedDocumentsHash()
|
||||||
|
{
|
||||||
|
if (!mHashTable.ops) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsAutoString baseURI;
|
||||||
|
if (mSourceDocument) {
|
||||||
|
mSourceDocument->getBaseURI(baseURI);
|
||||||
|
txLoadedDocumentEntry* entry = GetEntry(baseURI);
|
||||||
|
if (entry) {
|
||||||
|
entry->mDocument = nsnull;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mStyleDocument) {
|
||||||
|
mStyleDocument->getBaseURI(baseURI);
|
||||||
|
txLoadedDocumentEntry* entry = GetEntry(baseURI);
|
||||||
|
if (entry) {
|
||||||
|
entry->mDocument = nsnull;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void txLoadedDocumentsHash::Add(Document* aDocument)
|
||||||
|
{
|
||||||
|
if (!mHashTable.ops) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsAutoString baseURI;
|
||||||
|
mSourceDocument->getBaseURI(baseURI);
|
||||||
|
txLoadedDocumentEntry* entry = AddEntry(baseURI);
|
||||||
|
if (entry) {
|
||||||
|
entry->mDocument = aDocument;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Document* txLoadedDocumentsHash::Get(const nsAString& aURI)
|
||||||
|
{
|
||||||
|
if (!mHashTable.ops) {
|
||||||
|
return nsnull;
|
||||||
|
}
|
||||||
|
|
||||||
|
txLoadedDocumentEntry* entry = GetEntry(aURI);
|
||||||
|
if (entry) {
|
||||||
|
return entry->mDocument;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nsnull;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ProcessorState for the given XSL document
|
* Creates a new ProcessorState for the given XSL document
|
||||||
**/
|
**/
|
||||||
|
@ -55,13 +127,12 @@ ProcessorState::ProcessorState(Document* aSourceDocument,
|
||||||
: mOutputHandler(0),
|
: mOutputHandler(0),
|
||||||
mResultHandler(0),
|
mResultHandler(0),
|
||||||
mOutputHandlerFactory(0),
|
mOutputHandlerFactory(0),
|
||||||
|
mLoadedDocuments(aSourceDocument, aXslDocument),
|
||||||
mXslKeys(MB_TRUE),
|
mXslKeys(MB_TRUE),
|
||||||
mDecimalFormats(MB_TRUE),
|
mDecimalFormats(MB_TRUE),
|
||||||
mEvalContext(0),
|
mEvalContext(0),
|
||||||
mLocalVariables(0),
|
mLocalVariables(0),
|
||||||
mGlobalVariableValues(MB_TRUE),
|
mGlobalVariableValues(MB_TRUE),
|
||||||
mSourceDocument(aSourceDocument),
|
|
||||||
xslDocument(aXslDocument),
|
|
||||||
mRTFDocument(0)
|
mRTFDocument(0)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(aSourceDocument, "missing source document");
|
NS_ASSERTION(aSourceDocument, "missing source document");
|
||||||
|
@ -73,21 +144,6 @@ ProcessorState::ProcessorState(Document* aSourceDocument,
|
||||||
mExprHashes[ValueAttr].setOwnership(Map::eOwnsItems);
|
mExprHashes[ValueAttr].setOwnership(Map::eOwnsItems);
|
||||||
mPatternHashes[CountAttr].setOwnership(Map::eOwnsItems);
|
mPatternHashes[CountAttr].setOwnership(Map::eOwnsItems);
|
||||||
mPatternHashes[FromAttr].setOwnership(Map::eOwnsItems);
|
mPatternHashes[FromAttr].setOwnership(Map::eOwnsItems);
|
||||||
|
|
||||||
// determine xslt properties
|
|
||||||
if (mSourceDocument) {
|
|
||||||
nsAutoString baseURI;
|
|
||||||
mSourceDocument->getBaseURI(baseURI);
|
|
||||||
loadedDocuments.put(baseURI, mSourceDocument);
|
|
||||||
}
|
|
||||||
if (xslDocument) {
|
|
||||||
nsAutoString baseURI;
|
|
||||||
xslDocument->getBaseURI(baseURI);
|
|
||||||
loadedDocuments.put(baseURI, xslDocument);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure all loaded documents get deleted
|
|
||||||
loadedDocuments.setObjectDeletion(MB_TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,19 +156,6 @@ ProcessorState::~ProcessorState()
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
delete (ImportFrame*)iter.next();
|
delete (ImportFrame*)iter.next();
|
||||||
|
|
||||||
// Make sure that xslDocument and mSourceDocument aren't deleted along with
|
|
||||||
// the rest of the documents in the loadedDocuments hash
|
|
||||||
if (xslDocument) {
|
|
||||||
nsAutoString baseURI;
|
|
||||||
xslDocument->getBaseURI(baseURI);
|
|
||||||
loadedDocuments.remove(baseURI);
|
|
||||||
}
|
|
||||||
if (mSourceDocument) {
|
|
||||||
nsAutoString baseURI;
|
|
||||||
mSourceDocument->getBaseURI(baseURI);
|
|
||||||
loadedDocuments.remove(baseURI);
|
|
||||||
}
|
|
||||||
|
|
||||||
// in module the outputhandler is refcounted
|
// in module the outputhandler is refcounted
|
||||||
#ifdef TX_EXE
|
#ifdef TX_EXE
|
||||||
delete mOutputHandler;
|
delete mOutputHandler;
|
||||||
|
@ -385,14 +428,16 @@ Node* ProcessorState::retrieveDocument(const nsAString& uri,
|
||||||
NS_LossyConvertUCS2toASCII(frag).get()));
|
NS_LossyConvertUCS2toASCII(frag).get()));
|
||||||
|
|
||||||
// try to get already loaded document
|
// try to get already loaded document
|
||||||
Document* xmlDoc = (Document*)loadedDocuments.get(docUrl);
|
Document* xmlDoc = mLoadedDocuments.Get(docUrl);
|
||||||
|
|
||||||
if (!xmlDoc) {
|
if (!xmlDoc) {
|
||||||
// open URI
|
// open URI
|
||||||
nsAutoString errMsg;
|
nsAutoString errMsg;
|
||||||
XMLParser xmlParser;
|
XMLParser xmlParser;
|
||||||
|
|
||||||
xmlDoc = xmlParser.getDocumentFromURI(docUrl, xslDocument, errMsg);
|
xmlDoc = xmlParser.getDocumentFromURI(docUrl,
|
||||||
|
mLoadedDocuments.mStyleDocument,
|
||||||
|
errMsg);
|
||||||
|
|
||||||
if (!xmlDoc) {
|
if (!xmlDoc) {
|
||||||
receiveError(NS_LITERAL_STRING("Couldn't load document '") +
|
receiveError(NS_LITERAL_STRING("Couldn't load document '") +
|
||||||
|
@ -401,7 +446,7 @@ Node* ProcessorState::retrieveDocument(const nsAString& uri,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
// add to list of documents
|
// add to list of documents
|
||||||
loadedDocuments.put(docUrl, xmlDoc);
|
mLoadedDocuments.Add(xmlDoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return element with supplied id if supplied
|
// return element with supplied id if supplied
|
||||||
|
@ -667,8 +712,9 @@ void ProcessorState::setRTFDocument(Document* aDoc)
|
||||||
|
|
||||||
Document* ProcessorState::getStylesheetDocument()
|
Document* ProcessorState::getStylesheetDocument()
|
||||||
{
|
{
|
||||||
NS_ASSERTION(xslDocument, "missing stylesheet document");
|
NS_ASSERTION(mLoadedDocuments.mStyleDocument,
|
||||||
return xslDocument;
|
"missing stylesheet document");
|
||||||
|
return mLoadedDocuments.mStyleDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1022,7 +1068,7 @@ nsresult ProcessorState::getVariable(PRInt32 aNamespace, nsIAtom* aLName,
|
||||||
// Set up the state we have at the beginning of the transformation
|
// Set up the state we have at the beginning of the transformation
|
||||||
txVariableMap *oldVars = mLocalVariables;
|
txVariableMap *oldVars = mLocalVariables;
|
||||||
mLocalVariables = 0;
|
mLocalVariables = 0;
|
||||||
txSingleNodeContext evalContext(mSourceDocument, this);
|
txSingleNodeContext evalContext(mLoadedDocuments.mSourceDocument, this);
|
||||||
txIEvalContext* priorEC = setEvalContext(&evalContext);
|
txIEvalContext* priorEC = setEvalContext(&evalContext);
|
||||||
// Compute the variable value
|
// Compute the variable value
|
||||||
globVar->mFlags = GlobalVariableValue::evaluating;
|
globVar->mFlags = GlobalVariableValue::evaluating;
|
||||||
|
|
|
@ -29,9 +29,7 @@
|
||||||
#define TRANSFRMX_PROCESSORSTATE_H
|
#define TRANSFRMX_PROCESSORSTATE_H
|
||||||
|
|
||||||
#include "NodeSet.h"
|
#include "NodeSet.h"
|
||||||
#include "Stack.h"
|
|
||||||
#include "ErrorObserver.h"
|
#include "ErrorObserver.h"
|
||||||
#include "NamedMap.h"
|
|
||||||
#include "txPatternParser.h"
|
#include "txPatternParser.h"
|
||||||
#include "Expr.h"
|
#include "Expr.h"
|
||||||
#include "txOutputFormat.h"
|
#include "txOutputFormat.h"
|
||||||
|
@ -42,10 +40,39 @@
|
||||||
#include "XSLTFunctions.h"
|
#include "XSLTFunctions.h"
|
||||||
#include "txError.h"
|
#include "txError.h"
|
||||||
#include "nsVoidArray.h"
|
#include "nsVoidArray.h"
|
||||||
|
#include "nsDoubleHashtable.h"
|
||||||
|
|
||||||
class txVariableMap;
|
class txVariableMap;
|
||||||
class txXSLKey;
|
class txXSLKey;
|
||||||
|
|
||||||
|
class txLoadedDocumentEntry : public PLDHashStringEntry {
|
||||||
|
public:
|
||||||
|
txLoadedDocumentEntry(const void* aKey) : PLDHashStringEntry(aKey)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
~txLoadedDocumentEntry()
|
||||||
|
{
|
||||||
|
delete mDocument;
|
||||||
|
}
|
||||||
|
Document* mDocument;
|
||||||
|
};
|
||||||
|
|
||||||
|
DECL_DHASH_WRAPPER(txLoadedDocumentsBase, txLoadedDocumentEntry, nsAString&)
|
||||||
|
|
||||||
|
class txLoadedDocumentsHash : public txLoadedDocumentsBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
txLoadedDocumentsHash(Document* aSourceDocument, Document* aStyleDocument);
|
||||||
|
~txLoadedDocumentsHash();
|
||||||
|
void Add(Document* aDocument);
|
||||||
|
Document* Get(const nsAString& aURI);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class ProcessorState;
|
||||||
|
Document* mSourceDocument;
|
||||||
|
Document* mStyleDocument;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class used for keeping the current state of the XSL Processor
|
* Class used for keeping the current state of the XSL Processor
|
||||||
*/
|
*/
|
||||||
|
@ -418,7 +445,7 @@ private:
|
||||||
* The set of loaded documents. This includes both document() loaded
|
* The set of loaded documents. This includes both document() loaded
|
||||||
* documents and xsl:include/xsl:import'ed documents.
|
* documents and xsl:include/xsl:import'ed documents.
|
||||||
*/
|
*/
|
||||||
NamedMap loadedDocuments;
|
txLoadedDocumentsHash mLoadedDocuments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The set of all available keys
|
* The set of all available keys
|
||||||
|
@ -467,9 +494,6 @@ private:
|
||||||
*/
|
*/
|
||||||
txExpandedNameMap mGlobalVariableValues;
|
txExpandedNameMap mGlobalVariableValues;
|
||||||
|
|
||||||
Document* mSourceDocument;
|
|
||||||
Document* xslDocument;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document used to create RTFs
|
* Document used to create RTFs
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "txNodeSetContext.h"
|
#include "txNodeSetContext.h"
|
||||||
#include "txNodeSorter.h"
|
#include "txNodeSorter.h"
|
||||||
#include "txRtfHandler.h"
|
#include "txRtfHandler.h"
|
||||||
|
#include "txStack.h"
|
||||||
#include "txStringUtils.h"
|
#include "txStringUtils.h"
|
||||||
#include "txTextHandler.h"
|
#include "txTextHandler.h"
|
||||||
#include "txTokenizer.h"
|
#include "txTokenizer.h"
|
||||||
|
@ -866,7 +867,7 @@ txXSLTProcessor::processAction(Node* aAction,
|
||||||
void
|
void
|
||||||
txXSLTProcessor::processAttributeSets(Element* aElement,
|
txXSLTProcessor::processAttributeSets(Element* aElement,
|
||||||
ProcessorState* aPs,
|
ProcessorState* aPs,
|
||||||
Stack* aRecursionStack)
|
txStack* aRecursionStack)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
nsAutoString names;
|
nsAutoString names;
|
||||||
|
@ -913,7 +914,7 @@ txXSLTProcessor::processAttributeSets(Element* aElement,
|
||||||
aRecursionStack->pop();
|
aRecursionStack->pop();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Stack recursionStack;
|
txStack recursionStack;
|
||||||
recursionStack.push(&name);
|
recursionStack.push(&name);
|
||||||
processAttributeSets(parent, aPs, &recursionStack);
|
processAttributeSets(parent, aPs, &recursionStack);
|
||||||
recursionStack.pop();
|
recursionStack.pop();
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
|
|
||||||
#include "ProcessorState.h"
|
#include "ProcessorState.h"
|
||||||
|
|
||||||
|
class txStack;
|
||||||
|
|
||||||
class txIGlobalParameter : public TxObject
|
class txIGlobalParameter : public TxObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -123,7 +125,7 @@ private:
|
||||||
* including themselves, even indirectly
|
* including themselves, even indirectly
|
||||||
*/
|
*/
|
||||||
static void processAttributeSets(Element* aElement, ProcessorState* aPs,
|
static void processAttributeSets(Element* aElement, ProcessorState* aPs,
|
||||||
Stack* aRecursionStack = 0);
|
txStack* aRecursionStack = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes the children of the specified element using the given
|
* Processes the children of the specified element using the given
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ProcessorState.h"
|
#include "ProcessorState.h"
|
||||||
|
#include "NamedMap.h"
|
||||||
#include "txAtoms.h"
|
#include "txAtoms.h"
|
||||||
#include "txSingleNodeContext.h"
|
#include "txSingleNodeContext.h"
|
||||||
#include "XMLDOMUtils.h"
|
#include "XMLDOMUtils.h"
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#define TRANSFRMX_HTML_OUTPUT_H
|
#define TRANSFRMX_HTML_OUTPUT_H
|
||||||
|
|
||||||
#include "txXMLOutput.h"
|
#include "txXMLOutput.h"
|
||||||
#include "Stack.h"
|
#include "txStack.h"
|
||||||
|
|
||||||
class txHTMLOutput : public txXMLOutput
|
class txHTMLOutput : public txXMLOutput
|
||||||
{
|
{
|
||||||
|
@ -109,7 +109,7 @@ private:
|
||||||
MBool isShorthandElement(const nsAString& aName);
|
MBool isShorthandElement(const nsAString& aName);
|
||||||
MBool isShorthandAttribute(const nsAString& aLocalName);
|
MBool isShorthandAttribute(const nsAString& aLocalName);
|
||||||
|
|
||||||
Stack mCurrentElements;
|
txStack mCurrentElements;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include "txXMLEventHandler.h"
|
#include "txXMLEventHandler.h"
|
||||||
#include "dom.h"
|
#include "dom.h"
|
||||||
#include "List.h"
|
#include "List.h"
|
||||||
#include "Stack.h"
|
#include "txStack.h"
|
||||||
#include "txOutputFormat.h"
|
#include "txOutputFormat.h"
|
||||||
#include "XMLUtils.h"
|
#include "XMLUtils.h"
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ protected:
|
||||||
MBool mInCDATASection;
|
MBool mInCDATASection;
|
||||||
PRUint32 mIndentLevel;
|
PRUint32 mIndentLevel;
|
||||||
txList mAttributes;
|
txList mAttributes;
|
||||||
Stack mCDATASections;
|
txStack mCDATASections;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PRUnichar mBuffer[4];
|
PRUnichar mBuffer[4];
|
||||||
|
|
Загрузка…
Ссылка в новой задаче