Fix for bug 105808 (We need atomtables for all xslt elements and attributes). r=Pike, sicking, sr=jst.

This commit is contained in:
peterv%netscape.com 2001-10-30 23:48:37 +00:00
parent cfd3dcd521
commit 00857e7e6a
33 changed files with 621 additions and 141 deletions

View File

@ -60,6 +60,7 @@ LOBJS =../source/base/ArrayList.$(OBJ_SUFFIX) \
../source/base/Stack.$(OBJ_SUFFIX) \
../source/base/StringList.$(OBJ_SUFFIX) \
../source/base/Tokenizer.$(OBJ_SUFFIX) \
../source/base/txAtoms.$(OBJ_SUFFIX) \
../source/base/MozillaString.$(OBJ_SUFFIX) \
../source/net/URIUtils.$(OBJ_SUFFIX) \
../source/xml/dom/mozImpl/MozillaObjectWrapper.$(OBJ_SUFFIX) \

View File

@ -27,11 +27,11 @@
#include "nsICategoryManager.h"
#include "nsIServiceManager.h"
#include "nsIScriptNameSpaceManager.h"
#include "nsSyncLoader.h"
#include "nsXPIDLString.h"
#include "txAtoms.h"
#include "XSLTProcessor.h"
#include "XPathProcessor.h"
#include "nsSyncLoader.h"
// Factory Constructor
NS_GENERIC_FACTORY_CONSTRUCTOR(XSLTProcessor)
@ -68,11 +68,11 @@ RegisterTransformiix(nsIComponentManager *aCompMgr,
return rv;
}
// Perform our one-time intialization for this module
static PRBool gInitialized = PR_FALSE;
// Perform our one-time intialization for this module
PR_STATIC_CALLBACK(nsresult)
Initialize(nsIModule* self)
Initialize(nsIModule* aSelf)
{
NS_PRECONDITION(!gInitialized, "module already initialized");
if (gInitialized)
@ -80,30 +80,34 @@ Initialize(nsIModule* self)
gInitialized = PR_TRUE;
txXMLAtoms::XMLPrefix = NS_NewAtom("xml");
NS_ENSURE_TRUE(txXMLAtoms::XMLPrefix, NS_ERROR_OUT_OF_MEMORY);
txXMLAtoms::XMLNSPrefix = NS_NewAtom("xmlns");
NS_ENSURE_TRUE(txXMLAtoms::XMLNSPrefix, NS_ERROR_OUT_OF_MEMORY);
if (!txXMLAtoms::init())
return NS_ERROR_OUT_OF_MEMORY;
if (!txXPathAtoms::init())
return NS_ERROR_OUT_OF_MEMORY;
if (!txXSLTAtoms::init())
return NS_ERROR_OUT_OF_MEMORY;
if (!txHTMLAtoms::init())
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
// Shutdown this module, releasing all of the module resources
PR_STATIC_CALLBACK(void)
Shutdown(nsIModule* self)
Shutdown(nsIModule* aSelf)
{
NS_PRECONDITION(gInitialized, "module not initialized");
if (! gInitialized)
return;
gInitialized = PR_FALSE;
NS_IF_RELEASE(txXMLAtoms::XMLPrefix);
NS_IF_RELEASE(txXMLAtoms::XMLNSPrefix);
txXMLAtoms::shutdown();
txXPathAtoms::shutdown();
txXSLTAtoms::shutdown();
txHTMLAtoms::shutdown();
}
// Component Table
static nsModuleComponentInfo components[] = {
static nsModuleComponentInfo gComponents[] = {
{ "Transformiix XSLT Processor",
TRANSFORMIIX_XSLT_PROCESSOR_CID,
TRANSFORMIIX_XSLT_PROCESSOR_CONTRACTID,
@ -119,5 +123,5 @@ static nsModuleComponentInfo components[] = {
nsSyncLoaderConstructor }
};
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(TransformiixModule, components,
Initialize, Shutdown)
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(TransformiixModule, gComponents,
Initialize, Shutdown)

View File

@ -51,6 +51,7 @@ CPP_OBJS= \
..\source\base\$(OBJDIR)\Stack.obj \
..\source\base\$(OBJDIR)\StringList.obj \
..\source\base\$(OBJDIR)\Tokenizer.obj \
..\source\base\$(OBJDIR)\txAtoms.obj \
..\source\base\$(OBJDIR)\MozillaString.obj \
..\source\net\$(OBJDIR)\URIUtils.obj \
..\source\xml\dom\mozImpl\$(OBJDIR)\MozillaObjectWrapper.obj \
@ -138,7 +139,7 @@ LCFLAGS = \
$(DEFINES) \
$(NULL)
LINCS= -I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I..\source\xslt\functions \
LINCS= -I$(PUBLIC)\xpcom -I..\source\xslt\functions \
-I..\source\xml\dom -I..\source\xml\dom\mozImpl -I..\source\xml\util \
-I..\source\xpath -I..\source\xslt\util -I..\source\xml -I..\source\xslt \
-I..\source\base -I..\source\net -I..\source\xml\parser
@ -146,15 +147,8 @@ LINCS= -I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I..\source\xslt\functions \
# These are the libraries we need to link with to create the dll
LLIBS=$(LLIBS) $(LIBNSPR) \
$(DIST)\lib\xpcom.lib \
!ifndef NECKO
$(DIST)\lib\netlib.lib \
!endif
$(DIST)\lib\js3250.lib \
$(DIST)\lib\expat.lib
WIN_LIBS = \
shell32.lib \
$(NULL)
include <$(DEPTH)\config\rules.mak>

View File

@ -43,7 +43,8 @@ CPPSRCS = ArrayList.cpp \
SimpleErrorObserver.cpp \
Stack.cpp \
StringList.cpp \
Tokenizer.cpp
Tokenizer.cpp \
txAtoms.cpp
ifdef TX_EXE
CPPSRCS += CommandLineUtils.cpp \
@ -51,6 +52,9 @@ ifdef TX_EXE
else
CPPSRCS += MozillaString.cpp
endif
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(srcdir)/../xpath -I$(srcdir)/../xslt
install:: $(OBJS)

View File

@ -41,7 +41,8 @@ CPPSRCS= \
Stack.cpp \
Map.cpp \
StringList.cpp \
Tokenizer.cpp
Tokenizer.cpp \
txAtoms.cpp
!ifndef TX_EXE
CPPSRCS = $(CPPSRCS) \
@ -65,7 +66,8 @@ CPP_OBJS= \
.\$(OBJDIR)\Stack.obj \
.\$(OBJDIR)\Map.obj \
.\$(OBJDIR)\StringList.obj \
.\$(OBJDIR)\Tokenizer.obj
.\$(OBJDIR)\Tokenizer.obj \
.\$(OBJDIR)\txAtoms.obj
!ifndef TX_EXE
CPP_OBJS = $(CPP_OBJS) \
@ -81,7 +83,7 @@ CPP_OBJS = $(CPP_OBJS) \
EXPORTS = \
$(NULL)
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor
LINCS=-I$(PUBLIC)\xpcom -I..\xpath -I..\xslt
LCFLAGS = \
$(LCFLAGS) \

View File

@ -53,9 +53,8 @@
*
* To use this code standalone,
* TX_IMPL_ATOM_STATICS;
* has to appear in your source file. This is done by
* TX_IMPL_STATICS
* defined below. XSLTProcessor.cpp does this.
* has to appear in your source file.
* XSLTProcessor.cpp does this.
*/
#ifndef TRANSFRMX_ATOM_H
@ -136,7 +135,7 @@ private:
#define TX_RELEASE_ATOM(atom) {}
#define TX_RELEASE_IF_ATOM(atom) {}
#define TX_IF_RELEASE_ATOM(atom) {}
#define TX_GET_ATOM_STRING(atom, str) \
((atom)->getString(str))
@ -155,10 +154,10 @@ typedef nsIAtom txAtom;
#define TX_RELEASE_ATOM(atom) NS_RELEASE(atom)
#define TX_RELEASE_IF_ATOM(atom) NS_IF_RELEASE(atom)
#define TX_IF_RELEASE_ATOM(atom) NS_IF_RELEASE(atom)
#define TX_GET_ATOM_STRING(atom, string) \
NS_SUCCESS((atom)->ToString(string))
NS_SUCCEEDED((atom)->ToString(string.getNSString()))
#endif // TX_EXE

View File

@ -0,0 +1,156 @@
/* -*- Mode: C++; 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 TransforMiiX XSLT processor.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Van der Beken <peterv@netscape.com>
*
* 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 ***** */
#include "txAtoms.h"
#define TX_ATOM(_name, _value) txAtom* txXMLAtoms::_name = 0
XML_ATOMS;
#undef TX_ATOM
#define TX_ATOM(_name, _value) txAtom* txXPathAtoms::_name = 0
#include "txXPathAtomList.h"
#undef TX_ATOM
#define TX_ATOM(_name, _value) txAtom* txXSLTAtoms::_name = 0
#include "txXSLTAtomList.h"
#undef TX_ATOM
#ifndef TX_EXE
#define TX_ATOM(_name, _value) txAtom* txHTMLAtoms::_name = 0
#include "txHTMLAtomList.h"
#undef TX_ATOM
#endif
static PRUint32 gXMLRefCnt = 0;
static PRUint32 gXPathRefCnt = 0;
static PRUint32 gXSLTRefCnt = 0;
#ifndef TX_EXE
static PRUint32 gHTMLRefCnt = 0;
#endif
#ifdef TX_EXE
#define TX_ATOM(_name, _value) \
_name = TX_GET_ATOM(String(_value)); \
if (!_name) \
return MB_FALSE
#else
#define TX_ATOM(_name, _value) \
_name = NS_NewAtom(_value); \
NS_ENSURE_TRUE(_name, MB_FALSE)
#endif
MBool txXMLAtoms::init()
{
if (0 == gXMLRefCnt++) {
// create atoms
XML_ATOMS;
}
return MB_TRUE;
}
MBool txXPathAtoms::init()
{
if (0 == gXPathRefCnt++) {
// create atoms
#include "txXPathAtomList.h"
}
return MB_TRUE;
}
MBool txXSLTAtoms::init()
{
if (0 == gXSLTRefCnt++) {
// create atoms
#include "txXSLTAtomList.h"
}
return MB_TRUE;
}
#ifndef TX_EXE
MBool txHTMLAtoms::init()
{
if (0 == gHTMLRefCnt++) {
// create atoms
#include "txHTMLAtomList.h"
}
return MB_TRUE;
}
#endif
#undef TX_ATOM
#define TX_ATOM(_name, _value) \
TX_IF_RELEASE_ATOM(_name)
void txXMLAtoms::shutdown()
{
NS_ASSERTION(gXMLRefCnt != 0, "bad release atoms");
if (--gXMLRefCnt == 0) {
// release atoms
XML_ATOMS;
}
}
void txXPathAtoms::shutdown()
{
NS_ASSERTION(gXPathRefCnt != 0, "bad release atoms");
if (--gXPathRefCnt == 0) {
// release atoms
#include "txXPathAtomList.h"
}
}
void txXSLTAtoms::shutdown()
{
NS_ASSERTION(gXSLTRefCnt != 0, "bad release atoms");
if (--gXSLTRefCnt == 0) {
// release atoms
#include "txXSLTAtomList.h"
}
}
#ifndef TX_EXE
void txHTMLAtoms::shutdown()
{
NS_ASSERTION(gHTMLRefCnt != 0, "bad release atoms");
if (--gHTMLRefCnt == 0) {
// release atoms
#include "txHTMLAtomList.h"
}
}
#endif
#undef TX_ATOM

View File

@ -0,0 +1,98 @@
/* -*- Mode: C++; 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 TransforMiiX XSLT processor.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Van der Beken <peterv@netscape.com>
*
* 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 TRANSFRMX_ATOMS_H
#define TRANSFRMX_ATOMS_H
#include "txAtom.h"
/*
* Declare all atoms
*
* The atom names and values are stored in tx*AtomList.h and
* are brought to you by the magic of C preprocessing.
* Add new atoms to tx*AtomList.h and all support logic will
* be auto-generated.
*/
#define XML_ATOMS \
TX_ATOM(base, "base"); \
TX_ATOM(lang, "lang"); \
TX_ATOM(space, "space"); \
TX_ATOM(xml, "xml"); \
TX_ATOM(xmlns, "xmlns")
#define TX_ATOM(_name, _value) static txAtom* _name
class txXMLAtoms
{
public:
static MBool init();
static void shutdown();
XML_ATOMS;
};
class txXPathAtoms
{
public:
static MBool init();
static void shutdown();
#include "txXPathAtomList.h"
};
class txXSLTAtoms
{
public:
static MBool init();
static void shutdown();
#include "txXSLTAtomList.h"
};
#ifndef TX_EXE
class txHTMLAtoms
{
public:
static MBool init();
static void shutdown();
#include "txHTMLAtomList.h"
};
#endif
#undef TX_ATOM
#endif

View File

@ -40,6 +40,7 @@ OBJS =../base/ArrayList.$(OBJ_SUFFIX) \
../base/Stack.$(OBJ_SUFFIX) \
../base/StringList.$(OBJ_SUFFIX) \
../base/Tokenizer.$(OBJ_SUFFIX) \
../base/txAtoms.$(OBJ_SUFFIX) \
../base/TxString.$(OBJ_SUFFIX) \
../net/URIUtils.$(OBJ_SUFFIX) \
../xml/dom/standalone/Attr.$(OBJ_SUFFIX) \

View File

@ -38,6 +38,7 @@ CPP_OBJS= \
../base/$(OBJDIR)/Stack.obj \
../base/$(OBJDIR)/StringList.obj \
../base/$(OBJDIR)/Tokenizer.obj \
../base/$(OBJDIR)/txAtoms.obj \
../base/$(OBJDIR)/TxString.obj \
../net/$(OBJDIR)/URIUtils.obj \
../xml/dom/standalone/$(OBJDIR)/Attr.obj \

View File

@ -41,7 +41,7 @@ CPP_OBJS= \
EXPORTS = \
$(NULL)
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I..\base
LINCS=-I$(PUBLIC)\xpcom -I..\base
LCFLAGS = \
$(LCFLAGS) \

View File

@ -57,6 +57,7 @@ CPPSRCS = MozillaAttr.cpp \
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(srcdir)/../../../base -I$(srcdir)/../../ -I$(srcdir)/../../../net
INCLUDES += -I$(srcdir)/../../../base -I$(srcdir)/../../ -I$(srcdir)/../../../net \
-I$(srcdir)/../../../xpath -I$(srcdir)/../../../xslt
install:: $(OBJS)

View File

@ -44,6 +44,10 @@ Attr::Attr(nsIDOMAttr* aAttr, Document* aOwner) : Node(aAttr, aOwner)
return;
nsAutoString ns;
aAttr->GetNamespaceURI(ns);
if (ns.IsEmpty()) {
namespaceID = kNameSpaceID_None;
return;
}
NS_ASSERTION(aOwner->nsNSManager,
"owner document lacks namespace manager");
if (!aOwner->nsNSManager)

View File

@ -27,7 +27,7 @@
interface into a TransforMIIX Node interface.
*/
#include "txAtom.h"
#include "txAtoms.h"
#include "mozilladom.h"
#include "nsIContent.h"
#include "nsINameSpaceManager.h"
@ -433,16 +433,16 @@ Node* Node::getXPathParent()
* @param prefix atom for prefix to look up
* @return namespace ID for prefix
*/
PRInt32 Node::lookupNamespaceID(txAtom* prefix)
PRInt32 Node::lookupNamespaceID(txAtom* aPrefix)
{
NSI_FROM_TX(Node)
nsresult rv;
if (!nsNode)
return kNameSpaceID_Unknown;
if (prefix == txXMLAtoms::XMLNSPrefix)
if (aPrefix == txXMLAtoms::xmlns)
return kNameSpaceID_XMLNS;
if (prefix == txXMLAtoms::XMLPrefix)
if (aPrefix == txXMLAtoms::xml)
return kNameSpaceID_XML;
nsCOMPtr<nsIContent> elem;
@ -467,7 +467,7 @@ PRInt32 Node::lookupNamespaceID(txAtom* prefix)
while (elem) {
nsAutoString uri;
rv = elem->GetAttr(kNameSpaceID_XMLNS, prefix, uri);
rv = elem->GetAttr(kNameSpaceID_XMLNS, aPrefix, uri);
NS_ENSURE_SUCCESS(rv, kNameSpaceID_Unknown);
if (rv != NS_CONTENT_ATTR_NOT_THERE) {
PRInt32 nsId;

View File

@ -76,8 +76,8 @@ CPP_OBJS= \
EXPORTS = \
$(NULL)
LINCS= -I..\..\..\base -I..\..\dom \
-I..\.. -I..\..\..\net
LINCS= -I..\..\..\base -I..\..\dom -I..\.. -I..\..\..\net
-I..\..\..\xpath -I..\..\..\xslt
LCFLAGS = \
$(LCFLAGS) \

View File

@ -95,21 +95,6 @@ class Notation;
class ProcessingInstruction;
class Text;
/*
* Definition of txXMLAtoms
*/
class txXMLAtoms
{
public:
static txAtom* XMLPrefix;
static txAtom* XMLNSPrefix;
};
#define TX_IMPL_DOM_STATICS \
txAtom* txXMLAtoms::XMLPrefix = 0; \
txAtom* txXMLAtoms::XMLNSPrefix = 0
/*
* This macro creates a nsCOMPtr to a specific interface for the
* wrapper's Mozilla object. The nsCOMPtr will be named like the
@ -181,7 +166,7 @@ class MozillaObjectWrapper : public TxObject
void setNSObj(nsISupports* aNsObject, Document* aOwner);
nsISupports* getNSObj() const;
protected:
// We want to maintain a pointer back to the aOwner document for memory
// management.
@ -264,7 +249,7 @@ class Node : public MozillaObjectWrapper
// txXPathNode functions
virtual MBool getLocalName(txAtom** aLocalName);
virtual PRInt32 getNamespaceID();
virtual PRInt32 lookupNamespaceID(txAtom* prefix);
virtual PRInt32 lookupNamespaceID(txAtom* aPrefix);
virtual Node* getXPathParent();
protected:

View File

@ -26,7 +26,7 @@
//
#include "dom.h"
#include "txAtom.h"
#include "txAtoms.h"
//
//Construct an Attribute object using the specified name and document owner
@ -39,7 +39,7 @@ Attr::Attr(const String& name, Document* owner):
int idx = nodeName.indexOf(':');
if (idx == NOT_FOUND) {
mLocalName = TX_GET_ATOM(nodeName);
if (mLocalName == txXMLAtoms::XMLNSPrefix)
if (mLocalName == txXMLAtoms::xmlns)
mNamespaceID = kNameSpaceID_XMLNS;
else
mNamespaceID = kNameSpaceID_None;
@ -54,13 +54,13 @@ Attr::Attr(const String& name, Document* owner):
String prefix;
nodeName.subString(0, idx, prefix);
txAtom* prefixAtom = TX_GET_ATOM(prefix);
if (prefixAtom == txXMLAtoms::XMLNSPrefix)
if (prefixAtom == txXMLAtoms::xmlns)
mNamespaceID = kNameSpaceID_XMLNS;
else if (prefixAtom == txXMLAtoms::XMLPrefix)
else if (prefixAtom == txXMLAtoms::xml)
mNamespaceID = kNameSpaceID_XML;
else
mNamespaceID = kNameSpaceID_Unknown;
TX_RELEASE_IF_ATOM(prefixAtom);
TX_IF_RELEASE_ATOM(prefixAtom);
}
}
@ -69,7 +69,7 @@ Attr::Attr(const String& name, Document* owner):
//
Attr::~Attr()
{
TX_RELEASE_IF_ATOM(mLocalName);
TX_IF_RELEASE_ATOM(mLocalName);
}
//
@ -198,7 +198,7 @@ PRInt32 Attr::getNamespaceID()
nodeName.subString(0, idx, prefix);
txAtom* prefixAtom = TX_GET_ATOM(prefix);
mNamespaceID = lookupNamespaceID(prefixAtom);
TX_RELEASE_IF_ATOM(prefixAtom);
TX_IF_RELEASE_ATOM(prefixAtom);
return mNamespaceID;
}

View File

@ -26,9 +26,7 @@
//
#include "dom.h"
#include "txAtom.h"
const String XMLNS_ATTR = "xmlns";
#include "txAtoms.h"
//
//Construct a new element with the specified tagName and Document owner.
@ -59,7 +57,7 @@ Element::Element(const String& tagName, Document* owner) :
Element::~Element()
{
mAttributes.clear();
TX_RELEASE_IF_ATOM(mLocalName);
TX_IF_RELEASE_ATOM(mLocalName);
}
//
@ -86,8 +84,8 @@ PRInt32 Element::getNamespaceID()
Node* node = this;
while (node && node->getNodeType() == Node::ELEMENT_NODE) {
String nsURI;
if (((Element*)node)->getAttr(txXMLAtoms::XMLNSPrefix,
kNameSpaceID_XMLNS, nsURI)) {
if (((Element*)node)->getAttr(txXMLAtoms::xmlns, kNameSpaceID_XMLNS,
nsURI)) {
// xmlns = "" sets the default namespace ID to kNameSpaceID_None;
if (!nsURI.isEmpty()) {
mNamespaceID = txNamespaceManager::getNamespaceID(nsURI);
@ -106,7 +104,7 @@ PRInt32 Element::getNamespaceID()
nodeName.subString(0, idx, prefix);
txAtom* prefixAtom = TX_GET_ATOM(prefix);
mNamespaceID = lookupNamespaceID(prefixAtom);
TX_RELEASE_IF_ATOM(prefixAtom);
TX_IF_RELEASE_ATOM(prefixAtom);
}
return mNamespaceID;
}
@ -222,10 +220,10 @@ MBool Element::getAttr(txAtom* aLocalName, PRInt32 aNSID,
aNSID == attrNode->getNamespaceID() &&
aLocalName == localName) {
aValue.append(attrNode->getValue());
TX_RELEASE_IF_ATOM(localName);
TX_IF_RELEASE_ATOM(localName);
return MB_TRUE;
}
TX_RELEASE_IF_ATOM(localName);
TX_IF_RELEASE_ATOM(localName);
item = item->next;
}
return MB_FALSE;

View File

@ -46,6 +46,7 @@ CPPSRCS = Attr.cpp \
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(srcdir)/../../../base -I$(srcdir)/../../../net
INCLUDES += -I$(srcdir)/../../../base -I$(srcdir)/../../../net \
-I$(srcdir)/../../../xpath -I$(srcdir)/../../../xslt
install:: $(OBJS)

View File

@ -32,10 +32,7 @@
#include "dom.h"
#include "ArrayList.h"
#include "URIUtils.h"
#include "txAtom.h"
const String XMLBASE_ATTR = "xml:base";
const String XMLNS_ATTR = "xmlns";
#include "txAtoms.h"
NodeDefinition::NodeDefinition(NodeType type, const String& name,
const String& value, Document* owner)
@ -379,15 +376,15 @@ PRInt32 NodeDefinition::getNamespaceID()
//
// @return namespace associated with prefix
//
PRInt32 NodeDefinition::lookupNamespaceID(txAtom* prefix)
PRInt32 NodeDefinition::lookupNamespaceID(txAtom* aPrefix)
{
// this is http://www.w3.org/2000/xmlns/,
// ID = kNameSpaceID_XMLNS, see txNamespaceManager::Init
if (prefix == txXMLAtoms::XMLNSPrefix)
if (aPrefix == txXMLAtoms::xmlns)
return kNameSpaceID_XMLNS;
// this is http://www.w3.org/XML/1998/namespace,
// ID = kNameSpaceID_XML, see txNamespaceManager::Init
if (prefix == txXMLAtoms::XMLPrefix)
if (aPrefix == txXMLAtoms::xml)
return kNameSpaceID_XML;
Node* node = this;
@ -396,7 +393,7 @@ PRInt32 NodeDefinition::lookupNamespaceID(txAtom* prefix)
String name("xmlns:");
String prefixString;
TX_GET_ATOM_STRING(prefix,prefixString);
TX_GET_ATOM_STRING(aPrefix, prefixString);
name.append(prefixString);
Attr* xmlns;
while (node && node->getNodeType() == Node::ELEMENT_NODE) {
@ -430,14 +427,14 @@ String NodeDefinition::getBaseURI()
Node* node = this;
ArrayList baseUrls;
String url;
Node* xbAttr;
String attValue;
while (node) {
switch (node->getNodeType()) {
case Node::ELEMENT_NODE :
xbAttr = ((Element*)node)->getAttributeNode(XMLBASE_ATTR);
if (xbAttr)
baseUrls.add(new String(xbAttr->getNodeValue()));
if (((Element*)node)->getAttr(txXMLAtoms::base, kNameSpaceID_XML,
attValue))
baseUrls.add(new String(attValue));
break;
case Node::DOCUMENT_NODE :

View File

@ -49,7 +49,7 @@ ProcessingInstruction::ProcessingInstruction(const String& theTarget,
//
ProcessingInstruction::~ProcessingInstruction()
{
TX_RELEASE_IF_ATOM(mLocalName);
TX_IF_RELEASE_ATOM(mLocalName);
}
//

View File

@ -154,7 +154,7 @@ class Node : public TxObject
//txXPathNode functions
virtual MBool getLocalName(txAtom** aLocalName) = 0;
virtual PRInt32 getNamespaceID() = 0;
virtual PRInt32 lookupNamespaceID(txAtom* prefix) = 0;
virtual PRInt32 lookupNamespaceID(txAtom* aPrefix) = 0;
virtual Node* getXPathParent() = 0;
};
@ -670,7 +670,7 @@ class txNamespaceManager
public:
static PRInt32 getNamespaceID(const String& aURI)
{
if (!mNamespaces && !Init())
if (!mNamespaces && !init())
return kNameSpaceID_Unknown;
txListIterator nameIter(mNamespaces);
PRInt32 id=0;
@ -695,7 +695,7 @@ public:
// empty namespace, and errors
if (aID <= 0)
return NULL_STRING;
if (!mNamespaces && !Init())
if (!mNamespaces && !init())
return NULL_STRING;
txListIterator nameIter(mNamespaces);
String* aURI = (String*)nameIter.advance(aID);
@ -704,10 +704,10 @@ public:
return NULL_STRING;
}
static MBool Init()
static MBool init()
{
NS_ASSERTION(!mNamespaces,
"called without matching Shutdown()");
"called without matching shutdown()");
if (mNamespaces)
return MB_TRUE;
mNamespaces = new txList();
@ -743,9 +743,9 @@ public:
return MB_TRUE;
}
static void Shutdown()
static void shutdown()
{
NS_ASSERTION(mNamespaces, "called without matching Init()");
NS_ASSERTION(mNamespaces, "called without matching init()");
if (!mNamespaces)
return;
txListIterator iter(mNamespaces);
@ -759,19 +759,7 @@ private:
static txList* mNamespaces;
};
//
// Definition of txXMLAtoms
//
class txXMLAtoms
{
public:
static txAtom* XMLPrefix;
static txAtom* XMLNSPrefix;
};
#define TX_IMPL_DOM_STATICS \
txAtom* txXMLAtoms::XMLPrefix = 0; \
txAtom* txXMLAtoms::XMLNSPrefix = 0; \
txList* txNamespaceManager::mNamespaces = 0
txList* txNamespaceManager::mNamespaces = 0
#endif

View File

@ -66,8 +66,8 @@ CPP_OBJS= \
EXPORTS = \
$(NULL)
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I..\..\..\base -I..\..\dom \
-I..\.. -I..\..\..\net
LINCS=-I..\..\..\base -I..\..\..\net \
-I..\..\..\xpath -I..\..\..\xslt
LCFLAGS = \
$(LCFLAGS) \

View File

@ -50,7 +50,7 @@ CPP_OBJS= \
EXPORTS = \
$(NULL)
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I..\base -Idom
LINCS=-I$(PUBLIC)\xpcom -I..\base -Idom
LCFLAGS = \
$(LCFLAGS) \

View File

@ -31,7 +31,6 @@ REQUIRES = string \
appshell \
xpconnect \
caps \
raptor \
content \
$(NULL)

View File

@ -121,7 +121,7 @@ CPP_OBJS= \
EXPORTS = \
$(NULL)
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \
LINCS=-I$(PUBLIC)\xpcom \
-I..\base -I..\util -I..\xml -I..\xml\util -I..\xml\dom -I..\xslt \
-I..\xslt\functions -I..\xslt\util

View File

@ -0,0 +1,81 @@
/* -*- Mode: C++; 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 TransforMiiX XSLT processor.
*
* The Initial Developer of the Original Code is
* Jonas Sicking.
* Portions created by the Initial Developer are Copyright (C) 2001
* Jonas Sicking. All Rights Reserved.
*
* Contributor(s):
* Jonas Sicking <sicking@bigfoot.com>
*
* 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 ***** */
TX_ATOM(_asterix, "*");
TX_ATOM(boolean, "boolean");
TX_ATOM(ceiling, "ceiling");
TX_ATOM(concat, "concat");
TX_ATOM(contains, "contains");
TX_ATOM(count, "count");
TX_ATOM(_false, "false");
TX_ATOM(floor, "floor");
TX_ATOM(id, "id");
TX_ATOM(lang, "lang");
TX_ATOM(last, "last");
TX_ATOM(localName, "local-name");
TX_ATOM(name, "name");
TX_ATOM(namespaceUri, "namespace-uri");
TX_ATOM(normalizeSpace, "normalize-space");
TX_ATOM(_not, "not");
TX_ATOM(number, "number");
TX_ATOM(position, "position");
TX_ATOM(round, "round");
TX_ATOM(startsWith, "starts-with");
TX_ATOM(string, "string");
TX_ATOM(stringLength, "string-length");
TX_ATOM(substring, "substring");
TX_ATOM(substringAfter, "substring-after");
TX_ATOM(substringBefore, "substring-before");
TX_ATOM(sum, "sum");
TX_ATOM(translate, "translate");
TX_ATOM(_true, "true");
// XPath Axes
TX_ATOM(ancestor, "ancestor");
TX_ATOM(ancestorOrSelf, "ancestor-or-self");
TX_ATOM(attribute, "attribute");
TX_ATOM(child, "child");
TX_ATOM(descendant, "descendant");
TX_ATOM(descendantOrSelf, "descendant-or-self");
TX_ATOM(following, "following");
TX_ATOM(followingSibling, "following-sibling");
TX_ATOM(_namespace, "namespace");
TX_ATOM(parent, "parent");
TX_ATOM(preceding, "preceding");
TX_ATOM(precedingSibling, "preceding-sibling");
TX_ATOM(self, "self");

View File

@ -51,7 +51,7 @@
#include "Numbering.h"
#include "Tokenizer.h"
#include "URIUtils.h"
#include "txAtom.h"
#include "txAtoms.h"
#ifndef TX_EXE
#include "nsIObserverService.h"
#include "nsIURL.h"
@ -83,14 +83,12 @@ const String XSLTProcessor::NON_TEXT_TEMPLATE_WARNING =
"templates for the following element are not allowed to generate non character data: ";
/*
* Implement static variables for standalone
* atomservice
* and dom
* Implement static variables for atomservice and dom.
*/
#ifdef TX_EXE
TX_IMPL_ATOM_STATICS;
#endif
TX_IMPL_DOM_STATICS;
#endif
/**
* Creates a new XSLTProcessor
@ -166,35 +164,30 @@ NS_IMPL_RELEASE(XSLTProcessor)
#else
/*
* Initialize atom tables, hardcode xml and xmlns prefixes.
* Initialize atom tables.
*/
MBool txInit()
{
if (!txAtomService::Init())
if (!txNamespaceManager::init())
return MB_FALSE;
if (!txNamespaceManager::Init())
if (!txXMLAtoms::init())
return MB_FALSE;
String xml;
xml.append("xml");
txXMLAtoms::XMLPrefix = TX_GET_ATOM(xml);
if (!txXMLAtoms::XMLPrefix)
if (!txXPathAtoms::init())
return MB_FALSE;
xml.append("ns");
txXMLAtoms::XMLNSPrefix = TX_GET_ATOM(xml);
if (!txXMLAtoms::XMLNSPrefix)
return MB_FALSE;
return MB_TRUE;
return txXSLTAtoms::init();
}
/*
* To be called when done with transformiix
* To be called when done with transformiix.
*
* Free atom table, namespace manager
* Free atom table, namespace manager.
*/
MBool txShutdown()
{
txNamespaceManager::Shutdown();
txAtomService::Shutdown();
txNamespaceManager::shutdown();
txXMLAtoms::shutdown();
txXPathAtoms::shutdown();
txXSLTAtoms::shutdown();
return MB_TRUE;
}
#endif
@ -1212,7 +1205,7 @@ void XSLTProcessor::processAction
}
break;
}
// xsl:if
// xsl:choose
case XSLType::CHOOSE :
{
Node* tmp = actionElement->getFirstChild();
@ -1651,7 +1644,8 @@ void XSLTProcessor::processAction
void XSLTProcessor::processAttributeSets
(const String& names, Node* node, ProcessorState* ps)
{
if (names.isEmpty()) return;
if (names.isEmpty())
return;
//-- split names
Tokenizer tokenizer(names);

View File

@ -59,7 +59,7 @@ CPP_OBJS= \
EXPORTS = \
$(NULL)
LINCS= $(LINCS) -I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I..\..\base \
LINCS= $(LINCS) -I$(PUBLIC)\xpcom -I..\..\base \
-I..\..\xml\dom -I..\..\xpath -I..\..\xml -I..\ -I..\..\xml\util \
-I..\..\net -I$(DEPTH)\expat -I..\..\xml\parser -I..\util

View File

@ -60,7 +60,7 @@ EXPORTS = \
$(NULL)
!ifndef TX_EXE
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I..\xpath -I..\xml\dom -I..\xml\dom\mozImpl \
LINCS=-I$(PUBLIC)\xpcom -I..\xpath -I..\xml\dom -I..\xml\dom\mozImpl \
-I..\base -I ..\xml -I ..\xml\util -I .\util -I ..\net -I..\xml\parser -I.\functions
!else
LINCS=-I. -I..\base -I..\net -I..\xml -I..\xml\dom -I..\xml\util -I..\xml\parser \

View File

@ -0,0 +1,47 @@
/* -*- Mode: C++; 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 TransforMiiX XSLT processor.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Van der Beken <peterv@netscape.com>
*
* 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 ***** */
TX_ATOM(headerDefaultStyle, "default-style");
TX_ATOM(media, "media");
TX_ATOM(script, "script");
TX_ATOM(src, "src");
TX_ATOM(style, "style");
TX_ATOM(table, "table");
TX_ATOM(textarea, "textarea");
TX_ATOM(title, "title");
TX_ATOM(type, "type");

View File

@ -0,0 +1,125 @@
/* -*- Mode: C++; 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 TransforMiiX XSLT processor.
*
* The Initial Developer of the Original Code is
* Jonas Sicking.
* Portions created by the Initial Developer are Copyright (C) 2001
* Jonas Sicking. All Rights Reserved.
*
* Contributor(s):
* Jonas Sicking <sicking@bigfoot.com>
*
* 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 ***** */
// XSLT elements
TX_ATOM(applyImports, "apply-imports");
TX_ATOM(applyTemplates, "apply-templates");
TX_ATOM(attribute, "attribute");
TX_ATOM(attributeSet, "attribute-set");
TX_ATOM(callTemplate, "call-template");
TX_ATOM(choose, "choose");
TX_ATOM(comment, "comment");
TX_ATOM(copy, "copy");
TX_ATOM(copyOf, "copy-of");
TX_ATOM(decimalFormat, "decimal-format");
TX_ATOM(element, "element");
TX_ATOM(forEach, "for-each");
TX_ATOM(_if, "if");
TX_ATOM(import, "import");
TX_ATOM(include, "include");
TX_ATOM(key, "key");
TX_ATOM(message, "message");
TX_ATOM(number, "number");
TX_ATOM(otherwise, "otherwise");
TX_ATOM(output, "output");
TX_ATOM(param, "param");
TX_ATOM(processingInstruction, "processing-instruction");
TX_ATOM(preserveSpace, "preserve-space");
TX_ATOM(sort, "sort");
TX_ATOM(stripSpace, "strip-space");
TX_ATOM(stylesheet, "stylesheet");
TX_ATOM(_template, "template");
TX_ATOM(text, "text");
TX_ATOM(transform, "transform");
TX_ATOM(valueOf, "value-of");
TX_ATOM(variable, "variable");
TX_ATOM(when, "when");
TX_ATOM(withParam, "with-param");
// XSLT attributes
TX_ATOM(case_order, "case-order");
TX_ATOM(cdataSectionElements, "cdata-section-elements");
TX_ATOM(count, "count");
TX_ATOM(dataType, "data-type");
TX_ATOM(decimalSeparator, "decimal-separator");
TX_ATOM(defaultSpace, "default-space");
TX_ATOM(digit, "digit");
TX_ATOM(doctypePublic, "doctype-public");
TX_ATOM(doctypeSystem, "doctype-system");
TX_ATOM(elements, "elements");
TX_ATOM(encoding, "encoding");
TX_ATOM(format, "format");
TX_ATOM(from, "from");
TX_ATOM(groupingSeparator, "grouping-separator");
TX_ATOM(href, "href");
TX_ATOM(indent, "indent");
TX_ATOM(infinity, "infinity");
TX_ATOM(lang, "lang");
TX_ATOM(level, "level");
TX_ATOM(match, "match");
TX_ATOM(method, "method");
TX_ATOM(mediaType, "media-type");
TX_ATOM(minusSign, "minus-sign");
TX_ATOM(mode, "mode");
TX_ATOM(name, "name");
TX_ATOM(_namespace, "namespace");
TX_ATOM(NaN, "NaN");
TX_ATOM(omitXmlDeclaration, "omit-xml-declaration");
TX_ATOM(order, "order");
TX_ATOM(patternSeparator, "pattern-separator");
TX_ATOM(perMille, "per-mille");
TX_ATOM(percent, "percent");
TX_ATOM(priority, "priority");
TX_ATOM(select, "select");
TX_ATOM(standalone, "standalone");
TX_ATOM(test, "test");
TX_ATOM(use, "use");
TX_ATOM(useAttributeSets, "use-attribute-sets");
TX_ATOM(value, "value");
TX_ATOM(version, "version");
TX_ATOM(zeroDigit, "zero-digit");
// XSLT functions
TX_ATOM(current, "current");
TX_ATOM(document, "document");
TX_ATOM(elementAvailable, "element-available");
TX_ATOM(formatNumber, "format-number");
TX_ATOM(functionAvailable, "function-available");
TX_ATOM(generateId, "generate-id");
TX_ATOM(unparsedEntityUri, "unparsed-entity-uri");
TX_ATOM(systemProperty, "system-property");

View File

@ -50,7 +50,7 @@ CPP_OBJS= \
EXPORTS = \
$(NULL)
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I..\..\base -I..\..\xml\dom \
LINCS=-I$(PUBLIC)\xpcom -I..\..\base -I..\..\xml\dom \
-I..\..\xpath -I..\..\xml -I..\ -I..\..\xml\util -I..\functions
LCFLAGS = \