Compare commits
38 Commits
TX_COMPILE
...
Bugzilla_P
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c591d53e2 | ||
|
|
c1aa983fd5 | ||
|
|
3551227412 | ||
|
|
d0cc91f285 | ||
|
|
65ff7d56b3 | ||
|
|
800eccde9a | ||
|
|
5360e5b008 | ||
|
|
da759055dd | ||
|
|
1f960bb1bd | ||
|
|
e0f4b89db1 | ||
|
|
025b6e8e46 | ||
|
|
704f46aa53 | ||
|
|
f26338df7e | ||
|
|
58548c3f0d | ||
|
|
9a6b4393ad | ||
|
|
4316819604 | ||
|
|
9d93dfabb8 | ||
|
|
d2ddb07675 | ||
|
|
66d426dc97 | ||
|
|
b7e91cb3b6 | ||
|
|
5ac0899827 | ||
|
|
4f49e57a3b | ||
|
|
38c27be28f | ||
|
|
d60d3d6121 | ||
|
|
db0b87fb6c | ||
|
|
6e2791a4b7 | ||
|
|
14542c62c7 | ||
|
|
38ebcba576 | ||
|
|
a5502157a9 | ||
|
|
ba69b37618 | ||
|
|
22b863a5e9 | ||
|
|
3e54979994 | ||
|
|
d73ca44c76 | ||
|
|
a4fc52b12e | ||
|
|
353baca797 | ||
|
|
4618ab6c36 | ||
|
|
faaed9c15f | ||
|
|
675f64d0ae |
@@ -1,34 +0,0 @@
|
||||
#
|
||||
# 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 Axel Hecht.
|
||||
# Portions created by Axel Hecht are Copyright (C) Axel Hecht.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <axel@pike.org>
|
||||
#
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = source
|
||||
ifndef TX_EXE
|
||||
DIRS += build
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
@@ -1,152 +0,0 @@
|
||||
#
|
||||
# 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 Axel Hecht.
|
||||
# Portions created by Axel Hecht are Copyright (C) Axel Hecht.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <axel@pike.org>
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = transformiix
|
||||
LIBRARY_NAME = transformiix
|
||||
EXPORT_LIBRARY = 1
|
||||
ifneq ($(OS_ARCH),WINNT)
|
||||
SHORT_LIBNAME = t8iix
|
||||
endif
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
dom \
|
||||
content \
|
||||
widget \
|
||||
necko \
|
||||
js \
|
||||
xpconnect \
|
||||
caps \
|
||||
locale \
|
||||
unicharutil \
|
||||
htmlparser \
|
||||
webshell \
|
||||
docshell \
|
||||
layout \
|
||||
uconv \
|
||||
$(NULL)
|
||||
IS_COMPONENT = 1
|
||||
MODULE_NAME = TransformiixModule
|
||||
|
||||
|
||||
CPPSRCS = XSLTProcessorModule.cpp
|
||||
LOBJS = ../source/base/Double.$(OBJ_SUFFIX) \
|
||||
../source/base/List.$(OBJ_SUFFIX) \
|
||||
../source/base/SimpleErrorObserver.$(OBJ_SUFFIX) \
|
||||
../source/base/txAtoms.$(OBJ_SUFFIX) \
|
||||
../source/base/txExpandedNameMap.$(OBJ_SUFFIX) \
|
||||
../source/base/txNamespaceMap.$(OBJ_SUFFIX) \
|
||||
../source/base/txURIUtils.$(OBJ_SUFFIX) \
|
||||
../source/xml/dom/mozImpl/MozillaAttr.$(OBJ_SUFFIX) \
|
||||
../source/xml/dom/mozImpl/MozillaDocument.$(OBJ_SUFFIX) \
|
||||
../source/xml/dom/mozImpl/MozillaElement.$(OBJ_SUFFIX) \
|
||||
../source/xml/dom/mozImpl/MozillaNamedNodeMap.$(OBJ_SUFFIX) \
|
||||
../source/xml/dom/mozImpl/MozillaNode.$(OBJ_SUFFIX) \
|
||||
../source/xml/dom/mozImpl/MozillaProcInstruction.$(OBJ_SUFFIX) \
|
||||
../source/xpath/AdditiveExpr.$(OBJ_SUFFIX) \
|
||||
../source/xpath/AttributeValueTemplate.$(OBJ_SUFFIX) \
|
||||
../source/xpath/BooleanExpr.$(OBJ_SUFFIX) \
|
||||
../source/xpath/BooleanFunctionCall.$(OBJ_SUFFIX) \
|
||||
../source/xpath/BooleanResult.$(OBJ_SUFFIX) \
|
||||
../source/xpath/ExprLexer.$(OBJ_SUFFIX) \
|
||||
../source/xpath/ExprParser.$(OBJ_SUFFIX) \
|
||||
../source/xpath/FilterExpr.$(OBJ_SUFFIX) \
|
||||
../source/xpath/FunctionCall.$(OBJ_SUFFIX) \
|
||||
../source/xpath/LocationStep.$(OBJ_SUFFIX) \
|
||||
../source/xpath/MultiplicativeExpr.$(OBJ_SUFFIX) \
|
||||
../source/xpath/NodeSet.$(OBJ_SUFFIX) \
|
||||
../source/xpath/NodeSetFunctionCall.$(OBJ_SUFFIX) \
|
||||
../source/xpath/nsXPathEvaluator.$(OBJ_SUFFIX) \
|
||||
../source/xpath/nsXPathException.$(OBJ_SUFFIX) \
|
||||
../source/xpath/nsXPathExpression.$(OBJ_SUFFIX) \
|
||||
../source/xpath/nsXPathNSResolver.$(OBJ_SUFFIX) \
|
||||
../source/xpath/nsXPathResult.$(OBJ_SUFFIX) \
|
||||
../source/xpath/nsXPath1Scheme.$(OBJ_SUFFIX) \
|
||||
../source/xpath/NumberExpr.$(OBJ_SUFFIX) \
|
||||
../source/xpath/NumberFunctionCall.$(OBJ_SUFFIX) \
|
||||
../source/xpath/NumberResult.$(OBJ_SUFFIX) \
|
||||
../source/xpath/PathExpr.$(OBJ_SUFFIX) \
|
||||
../source/xpath/PredicateList.$(OBJ_SUFFIX) \
|
||||
../source/xpath/RelationalExpr.$(OBJ_SUFFIX) \
|
||||
../source/xpath/RootExpr.$(OBJ_SUFFIX) \
|
||||
../source/xpath/StringExpr.$(OBJ_SUFFIX) \
|
||||
../source/xpath/StringFunctionCall.$(OBJ_SUFFIX) \
|
||||
../source/xpath/StringResult.$(OBJ_SUFFIX) \
|
||||
../source/xpath/txNameTest.$(OBJ_SUFFIX) \
|
||||
../source/xpath/txNodeTypeTest.$(OBJ_SUFFIX) \
|
||||
../source/xpath/txForwardContext.$(OBJ_SUFFIX) \
|
||||
../source/xpath/txNodeSetContext.$(OBJ_SUFFIX) \
|
||||
../source/xpath/UnionExpr.$(OBJ_SUFFIX) \
|
||||
../source/xpath/UnaryExpr.$(OBJ_SUFFIX) \
|
||||
../source/xpath/VariableRefExpr.$(OBJ_SUFFIX) \
|
||||
../source/xml/XMLUtils.$(OBJ_SUFFIX) \
|
||||
../source/xml/XMLDOMUtils.$(OBJ_SUFFIX) \
|
||||
../source/xml/parser/txXMLParser.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txBufferingHandler.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txOutputFormat.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txExecutionState.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txInstructions.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txMozillaStylesheetCompiler.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txMozillaTextOutput.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txMozillaXSLTProcessor.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txMozillaXMLOutput.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txRtfHandler.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txStylesheet.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txStylesheetCompileHandlers.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txStylesheetCompiler.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txTextHandler.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txToplevelItems.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txUnknownHandler.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txXSLTNumber.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txXSLTNumberCounters.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txXSLTPatterns.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txXSLTProcessor.$(OBJ_SUFFIX) \
|
||||
../source/xslt/txPatternParser.$(OBJ_SUFFIX) \
|
||||
../source/xslt/functions/CurrentFunctionCall.$(OBJ_SUFFIX) \
|
||||
../source/xslt/functions/DocumentFunctionCall.$(OBJ_SUFFIX) \
|
||||
../source/xslt/functions/ElementAvailableFnCall.$(OBJ_SUFFIX) \
|
||||
../source/xslt/functions/FunctionAvailableFnCall.$(OBJ_SUFFIX) \
|
||||
../source/xslt/functions/GenerateIdFunctionCall.$(OBJ_SUFFIX) \
|
||||
../source/xslt/functions/SystemPropertyFunctionCall.$(OBJ_SUFFIX) \
|
||||
../source/xslt/functions/txFormatNumberFunctionCall.$(OBJ_SUFFIX) \
|
||||
../source/xslt/functions/txKeyFunctionCall.$(OBJ_SUFFIX) \
|
||||
../source/xslt/util/txNodeSorter.$(OBJ_SUFFIX) \
|
||||
../source/xslt/util/txXPathResultComparator.$(OBJ_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(MOZ_JS_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir)/../source/xslt -I$(srcdir)/../source/base \
|
||||
-I$(srcdir)/../source/xml -I$(srcdir)/../source/xml/dom \
|
||||
-I$(srcdir)/../source/xml/parser -I$(srcdir)/../source/xpath \
|
||||
-I$(srcdir)/../source/xslt/util -I$(srcdir)/../source/xslt/functions
|
||||
@@ -1,279 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Peter Van der Beken are Copyright (C) 2000
|
||||
* Peter Van der Beken. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Van der Beken, peter.vanderbeken@pandora.be
|
||||
* -- original author.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIDOMClassInfo.h"
|
||||
#include "nsIExceptionService.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIScriptNameSpaceManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsXPathEvaluator.h"
|
||||
#include "nsXPathException.h"
|
||||
#include "nsXPathExpression.h"
|
||||
#include "nsXPathNSResolver.h"
|
||||
#include "nsXPathResult.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "txAtoms.h"
|
||||
#include "txMozillaXSLTProcessor.h"
|
||||
#include "TxLog.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "txURIUtils.h"
|
||||
#include "txXSLTProcessor.h"
|
||||
#include "nsXPath1Scheme.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsXPath1SchemeProcessor)
|
||||
|
||||
/* 1c1a3c01-14f6-11d6-a7f2-ea502af815dc */
|
||||
#define TRANSFORMIIX_DOMCI_EXTENSION_CID \
|
||||
{ 0x1c1a3c01, 0x14f6, 0x11d6, {0xa7, 0xf2, 0xea, 0x50, 0x2a, 0xf8, 0x15, 0xdc} }
|
||||
|
||||
/* {0C351177-0159-4500-86B0-A219DFDE4258} */
|
||||
#define TRANSFORMIIX_XPATH1_SCHEME_CID \
|
||||
{ 0xc351177, 0x159, 0x4500, { 0x86, 0xb0, 0xa2, 0x19, 0xdf, 0xde, 0x42, 0x58 } }
|
||||
|
||||
#define TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID \
|
||||
"@mozilla.org/transformiix-domci-extender;1"
|
||||
|
||||
NS_DOMCI_EXTENSION(Transformiix)
|
||||
static NS_DEFINE_CID(kXSLTProcessorCID, TRANSFORMIIX_XSLT_PROCESSOR_CID);
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(XSLTProcessor)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIXSLTProcessor)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIXSLTProcessorObsolete) // XXX DEPRECATED
|
||||
NS_DOMCI_EXTENSION_ENTRY_END(XSLTProcessor, nsIXSLTProcessor, PR_TRUE,
|
||||
&kXSLTProcessorCID)
|
||||
|
||||
static NS_DEFINE_CID(kXPathEvaluatorCID, TRANSFORMIIX_XPATH_EVALUATOR_CID);
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(XPathEvaluator)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIDOMXPathEvaluator)
|
||||
NS_DOMCI_EXTENSION_ENTRY_END(XPathEvaluator, nsIDOMXPathEvaluator, PR_TRUE,
|
||||
&kXPathEvaluatorCID)
|
||||
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(XPathException)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIDOMXPathException)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIException)
|
||||
NS_DOMCI_EXTENSION_ENTRY_END(XPathException, nsIDOMXPathException, PR_TRUE,
|
||||
nsnull)
|
||||
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(XPathExpression)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIDOMXPathExpression)
|
||||
NS_DOMCI_EXTENSION_ENTRY_END(XPathExpression, nsIDOMXPathExpression,
|
||||
PR_TRUE, nsnull)
|
||||
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(XPathNSResolver)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIDOMXPathNSResolver)
|
||||
NS_DOMCI_EXTENSION_ENTRY_END(XPathNSResolver, nsIDOMXPathNSResolver,
|
||||
PR_TRUE, nsnull)
|
||||
|
||||
NS_DOMCI_EXTENSION_ENTRY_BEGIN(XPathResult)
|
||||
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsIDOMXPathResult)
|
||||
NS_DOMCI_EXTENSION_ENTRY_END(XPathResult, nsIDOMXPathResult, PR_TRUE,
|
||||
nsnull)
|
||||
NS_DOMCI_EXTENSION_END
|
||||
|
||||
// Factory Constructor
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(txMozillaXSLTProcessor)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsXPathEvaluator)
|
||||
|
||||
NS_DECL_DOM_CLASSINFO(XSLTProcessor)
|
||||
NS_DECL_DOM_CLASSINFO(XPathEvaluator)
|
||||
NS_DECL_DOM_CLASSINFO(XPathException)
|
||||
NS_DECL_DOM_CLASSINFO(XPathExpression)
|
||||
NS_DECL_DOM_CLASSINFO(XPathNSResolver)
|
||||
NS_DECL_DOM_CLASSINFO(XPathResult)
|
||||
|
||||
static NS_METHOD
|
||||
RegisterTransformiix(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath,
|
||||
const char *registryLocation,
|
||||
const char *componentType,
|
||||
const nsModuleComponentInfo *info)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsICategoryManager> catman =
|
||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsXPIDLCString previous;
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"XSLTProcessor",
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"XPathEvaluator",
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"XPathException",
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"XPathExpression",
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"XPathNSResolver",
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_CLASS,
|
||||
"XPathResult",
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
char* iidString = NS_GET_IID(nsIXSLTProcessorObsolete).ToString();
|
||||
if (!iidString)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_INTERFACE,
|
||||
"nsIXSLTProcessorObsolete",
|
||||
iidString,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
nsCRT::free(iidString);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
iidString = NS_GET_IID(nsIXSLTProcessor).ToString();
|
||||
if (!iidString)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = catman->AddCategoryEntry(JAVASCRIPT_DOM_INTERFACE,
|
||||
"nsIXSLTProcessor",
|
||||
iidString,
|
||||
PR_TRUE, PR_TRUE, getter_Copies(previous));
|
||||
nsCRT::free(iidString);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static PRBool gInitialized = PR_FALSE;
|
||||
static nsIExceptionProvider *gXPathExceptionProvider = 0;
|
||||
nsINameSpaceManager *gTxNameSpaceManager = 0;
|
||||
|
||||
// Perform our one-time intialization for this module
|
||||
PR_STATIC_CALLBACK(nsresult)
|
||||
Initialize(nsIModule* aSelf)
|
||||
{
|
||||
NS_PRECONDITION(!gInitialized, "module already initialized");
|
||||
if (gInitialized)
|
||||
return NS_OK;
|
||||
|
||||
gInitialized = PR_TRUE;
|
||||
|
||||
gXPathExceptionProvider = new nsXPathExceptionProvider();
|
||||
if (!gXPathExceptionProvider)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(gXPathExceptionProvider);
|
||||
nsCOMPtr<nsIExceptionService> xs =
|
||||
do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
|
||||
if (xs)
|
||||
xs->RegisterExceptionProvider(gXPathExceptionProvider,
|
||||
NS_ERROR_MODULE_DOM_XPATH);
|
||||
|
||||
if (!txXSLTProcessor::init()) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult rv = CallGetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID,
|
||||
&gTxSecurityManager);
|
||||
if (NS_FAILED(rv)) {
|
||||
gTxSecurityManager = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = CallGetService(NS_NAMESPACEMANAGER_CONTRACTID, &gTxNameSpaceManager);
|
||||
if (NS_FAILED(rv)) {
|
||||
gTxNameSpaceManager = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Shutdown this module, releasing all of the module resources
|
||||
PR_STATIC_CALLBACK(void)
|
||||
Shutdown(nsIModule* aSelf)
|
||||
{
|
||||
NS_PRECONDITION(gInitialized, "module not initialized");
|
||||
if (!gInitialized)
|
||||
return;
|
||||
|
||||
gInitialized = PR_FALSE;
|
||||
if (gXPathExceptionProvider) {
|
||||
nsCOMPtr<nsIExceptionService> xs =
|
||||
do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
|
||||
if (xs)
|
||||
xs->UnregisterExceptionProvider(gXPathExceptionProvider,
|
||||
NS_ERROR_MODULE_DOM_XPATH);
|
||||
NS_RELEASE(gXPathExceptionProvider);
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(XSLTProcessor));
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(XPathEvaluator));
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(XPathException));
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(XPathExpression));
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(XPathNSResolver));
|
||||
NS_IF_RELEASE(NS_CLASSINFO_NAME(XPathResult));
|
||||
|
||||
txXSLTProcessor::shutdown();
|
||||
|
||||
NS_IF_RELEASE(gTxSecurityManager);
|
||||
NS_IF_RELEASE(gTxNameSpaceManager);
|
||||
}
|
||||
|
||||
// Component Table
|
||||
static const nsModuleComponentInfo gComponents[] = {
|
||||
{ "XSLTProcessor",
|
||||
TRANSFORMIIX_XSLT_PROCESSOR_CID,
|
||||
TRANSFORMIIX_XSLT_PROCESSOR_CONTRACTID,
|
||||
txMozillaXSLTProcessorConstructor,
|
||||
RegisterTransformiix },
|
||||
{ "XPathEvaluator",
|
||||
TRANSFORMIIX_XPATH_EVALUATOR_CID,
|
||||
NS_XPATH_EVALUATOR_CONTRACTID,
|
||||
nsXPathEvaluatorConstructor },
|
||||
{ "Transformiix DOMCI Extender",
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CID,
|
||||
TRANSFORMIIX_DOMCI_EXTENSION_CONTRACTID,
|
||||
NS_DOMCI_EXTENSION_CONSTRUCTOR(Transformiix) },
|
||||
{ "XPath1 XPointer Scheme Processor",
|
||||
TRANSFORMIIX_XPATH1_SCHEME_CID,
|
||||
NS_XPOINTER_SCHEME_PROCESSOR_BASE "xpath1",
|
||||
nsXPath1SchemeProcessorConstructor }
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(TransformiixModule, gComponents,
|
||||
Initialize, Shutdown)
|
||||
@@ -1,30 +0,0 @@
|
||||
var err = initInstall("Transformiix", "Transformiix", $Version$);
|
||||
logComment("initInstall: " + err);
|
||||
|
||||
var fProgram = getFolder("Program");
|
||||
logComment("fProgram: " + fProgram);
|
||||
|
||||
if (verifyDiskSpace(fProgram, $SpaceRequired$))
|
||||
{
|
||||
err = addDirectory("Transformiix",
|
||||
$Version$,
|
||||
"bin",
|
||||
fProgram,
|
||||
"",
|
||||
true );
|
||||
|
||||
logComment("addDirectory() returned: " + err);
|
||||
|
||||
if (err==SUCCESS)
|
||||
{
|
||||
err = performInstall();
|
||||
logComment("performInstall() returned: " + err);
|
||||
}
|
||||
else
|
||||
{
|
||||
cancelInstall(err);
|
||||
logComment("cancelInstall() due to error: " + err);
|
||||
}
|
||||
}
|
||||
else
|
||||
cancelInstall(INSUFFICIENT_DISK_SPACE);
|
||||
@@ -1,227 +0,0 @@
|
||||
TransforMiiX (TM)
|
||||
(C) Copyright 1999, 2000, The MITRE Corporation, Keith Visco, et al. All rights reserved.
|
||||
|
||||
Note: The changes listed here mainly reflect the core XSLT processor and
|
||||
the standalone version.
|
||||
|
||||
Build 20000906
|
||||
|
||||
-- Fixed UTF8 bug
|
||||
- reported by Steve Tinney (stinney@sas.upenn.edu)
|
||||
|
||||
-- Updated Expat for standalone version
|
||||
|
||||
Build 20000725
|
||||
|
||||
-- Windows Makefiles are up to date to create Mozilla module
|
||||
- thanx to Arthur Barrett and Justin Smith
|
||||
|
||||
Build 20000722
|
||||
|
||||
-- Fixed leading + trailing whitspace when printing comments
|
||||
- reported by Jeff Bailey
|
||||
|
||||
-- Fixed bug in ExprLexer caused by a previous patch
|
||||
- The prevToken was being set to NULL, in cases when
|
||||
it shouldn't have been
|
||||
- discovered when looking for an error reported by
|
||||
Bernhard Zwischenbrugger
|
||||
|
||||
Build 20000618
|
||||
|
||||
-- Added changes from Olivier Gerardin for improved
|
||||
handling of template parameters
|
||||
|
||||
Build 20000523
|
||||
|
||||
-- Added fix from Marc Schefer regarding OR expressions
|
||||
- If the left hand expression was false...the right
|
||||
hand expression was not evaluated (which should
|
||||
only happen if the expression is an AND expr).
|
||||
|
||||
-- Added support for document() function
|
||||
- implemented by Olivier Gerardin
|
||||
- The second argument to the function is not yet supported
|
||||
|
||||
-- Added support for lang() function
|
||||
- implemented by Marina Mechtcherikova
|
||||
|
||||
-- Fixed bug with doing xsl:copy-of on a document node.
|
||||
- reported by Olivier Gerardin
|
||||
|
||||
|
||||
Build 20000420
|
||||
|
||||
-- Fixed document base issue with transfromiix.cpp (Nathan)
|
||||
- When an XSLT stylesheet is specified on the command line
|
||||
the document base was still defaulting to the XML document,
|
||||
instead of the stylesheet
|
||||
|
||||
-- Fixed bug in namespace-uri() function [NodeSetFunctionCall.cpp] - Marina
|
||||
- If an expression was passed as an argument to the function,
|
||||
which evaluated to an empty NodeSet, the context node was being
|
||||
used, which is incorrect. We now just return an empty string.
|
||||
|
||||
-- Fixed bug in PathExpr::matches (Marina)
|
||||
- expressions such as "foo//bar" would not always match
|
||||
properly if more than one node existed in the final
|
||||
set of "matching context nodes" (so basically if foo
|
||||
was not the root element).
|
||||
|
||||
|
||||
Build 20000419
|
||||
|
||||
-- Added the generate-id function
|
||||
-- Added XPath Extension Function support
|
||||
|
||||
Build 20000413
|
||||
|
||||
-- Added some bug fixes from Marina
|
||||
-- fixed parsing of multiple predicates
|
||||
-- added support to handle attribute-set recursion
|
||||
-- added appropriate calls to handle use-attribute-sets on xsl:copy
|
||||
|
||||
Build 20000412
|
||||
|
||||
-- Fixed the following Axes names in Names.cpp so that
|
||||
the are compatible with the XSLT 1.0 recommendation (Marina)
|
||||
-- FOLLOWING_SIBLING_AXIS - removed the trailing s
|
||||
-- PRECEDING_SIBLING_AXIS - removed the trailing s
|
||||
|
||||
-- Added support for xsl:sort (kvisco)
|
||||
-- simple sorting is working...documentation to follow
|
||||
-- Added StringComparator and DefaultStringComparator
|
||||
-- we need some more comparators for I18N support
|
||||
-- Did some directory structure changes
|
||||
- source/xsl is now source/xslt
|
||||
- source/xsl/expr is now source/xpath
|
||||
-- Changed xslt/XSLProcessor.* to XSLTProcessor.*
|
||||
|
||||
-- Incorporated some changes from Olivier Gerardin for the Expat parser
|
||||
|
||||
Build 20000331
|
||||
|
||||
-- Fixed a memory leak with translate() function (kvisco)
|
||||
-- StringFunctionCall.cpp
|
||||
-- Updated the necessary source files to support the changes to
|
||||
the String class (kvisco)
|
||||
-- Overloaded String::toCharArray to automatically create the
|
||||
character array (tomk)
|
||||
-- Changed String::toChar to String::toCharArray (tomk)
|
||||
|
||||
|
||||
Build 20000327
|
||||
-- Fixed "dot" bug in CNAME parsing (ExprLexer.cpp) reported by Nathan Pride
|
||||
|
||||
Build 20000326
|
||||
-- Added Peter Van der Beken's changes to net/URIUtils for integration
|
||||
within Mozilla
|
||||
|
||||
-- Added Marina Mechtcheriakova's changes to xml/parser/XMLParser.cpp to fix
|
||||
a Unicode bug in ::startElement. Instead of improperly casting char*
|
||||
as DOM_CHAR*, the proper String constructor, String(char*) is used
|
||||
|
||||
Build 20000322
|
||||
-- Added Unicode bug fix from Lidong
|
||||
|
||||
Build 20000318
|
||||
-- Added Olivier's implementation of the XPath Number functions
|
||||
-- Added missing prototype to TxString.h (Peter Van der Beken)
|
||||
|
||||
Build 20000222
|
||||
-- Added Attribute parent mapping since DOM 1.0 doesn't support it
|
||||
-- Added default sorting of NodeSet by DocumentOrder
|
||||
-- yes this is a hint that xsl:sort is will be available soon
|
||||
|
||||
Build 20000218
|
||||
-- Fixed bug reported by Thiery Le Bouil, xsl:param was getting
|
||||
processed, and then treated as a literal element
|
||||
|
||||
Build 20000217
|
||||
|
||||
-- Changed StringList#iterator to return a pointer instead of a reference
|
||||
-- Added patches from Eric Du for FreeBSD, sorry for the delay in committing these
|
||||
|
||||
Build 20000216
|
||||
|
||||
-- Fixed bug with using wildcards directly after the parent operator, such as "/*"
|
||||
-- Fixed bug with PredicateList#isEmpty which was returning the opposite of the
|
||||
expected value.
|
||||
-- this also caused default priorities to be incorrectly calculated.
|
||||
|
||||
Build 19991110
|
||||
-- fixed bug with PathExpr and LocationStep with respect
|
||||
to the ::match method
|
||||
-- problem reported by Oblix
|
||||
-- Added support for xsl:include (only file URLs will work)
|
||||
-- fixed the built-in xsl:apply-templates rule to handle text nodes
|
||||
-- moved code base to Linux platform for default development environment
|
||||
|
||||
Build 19990818
|
||||
-- Added very simple support for xsl:number
|
||||
-- Added support for xsl:with-param
|
||||
-- Added more XPath support
|
||||
-- added operator precedence
|
||||
-- added and, or, <,<=,>=,>
|
||||
|
||||
|
||||
Build 19990816
|
||||
-- Changed focus from 19990709 to 19990813 XSLT Working Draft
|
||||
-- Made some changes for Borland C compatibility
|
||||
-- submitted by Stefan Heesch
|
||||
-- added xsl:copy-of
|
||||
-- fixed a bug with DOM Element, to allow DocumentFragments as children
|
||||
|
||||
Build 19990813
|
||||
-- added new example: identity.xml/xsl which tests:
|
||||
-- xsl:copy, node()
|
||||
-- added comment(), pi(), and node()
|
||||
-- XMLParser still needs to handle reading in XML comments
|
||||
-- added xsl:copy
|
||||
-- added xsl:processing-instruction
|
||||
-- added xsl:comment
|
||||
|
||||
Build 19990812
|
||||
-- Created base/Double.cpp (primitives.h)
|
||||
-- Based off some code submitted by Larry Fitzpatrick, changed Name from
|
||||
FloatPort to Double, I wanted to add more Double related methods
|
||||
-- changed the NaN() method to just a static double
|
||||
-- All expr classes now use Double::isNaN() and Double::NaN
|
||||
-- I added Double::isInfinite, Double::POSITIVE_INFINITY and
|
||||
Double::NEGATIVE_INFINITY
|
||||
-- Added base/Integer.cpp back into Makefile
|
||||
-- added Integer::toString(int,String);
|
||||
-- changed implementation
|
||||
-- Moved code to convert from Strings to doubles and from doubles to Strings
|
||||
into the Double class
|
||||
-- removed testdom.cpp from xml/dom
|
||||
-- Added more changes from Larry Fitzpatrick and Michele Lee for
|
||||
porting issues
|
||||
-- added appropriate return values for:
|
||||
-- xml/dom/Element.cpp
|
||||
-- xml/dom/NodeDefinition.cpp
|
||||
-- base/StringList.cpp
|
||||
-- xsl/expr/PredicateList.cpp
|
||||
-- Added remaining String Function Calls
|
||||
-- substring(), substring-after(), substring-before(), translate(),
|
||||
string-length()
|
||||
|
||||
|
||||
Build 19990810
|
||||
-- Added most of the Whitespace handling
|
||||
-- Added ErrorObserver interface
|
||||
-- ErrorObserver is now used throughout most of the code
|
||||
-- Added SimpleErrorObserver implementation of ErrorObserver
|
||||
-- Moved main() method from XSLProcessor.cpp to tranformiix.cpp
|
||||
-- Added the following XPath functions:
|
||||
-- local-part(), name(), namespace()
|
||||
-- see functions.xml/functions.xsl for available functions
|
||||
|
||||
Build 19990806
|
||||
-- Incoporated Changes From Larry Fitzpatrick
|
||||
-- Added more XPath functions
|
||||
-- last(), count(), string(), contains(), starts-with(), concat()
|
||||
-- see functions.xml/functions.xsl for available functions
|
||||
-- Added xsl:text support
|
||||
|
||||
|
||||
@@ -1,273 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>XSLT Templates and Compiling</title>
|
||||
<style type="text/css">
|
||||
.section {
|
||||
background-color: #cfcfcf;
|
||||
margin-left: 2em;
|
||||
}
|
||||
.required {
|
||||
font-weight: bold;
|
||||
}
|
||||
.TODO {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>XSLT Templates and Compiling</h1>
|
||||
<p>This document describes compiling of XSLT stylesheets and the
|
||||
evaluation of the result.</p>
|
||||
<div>
|
||||
<ul>
|
||||
<li><a href="#pre">Prerequisites</a></li>
|
||||
<li><a href="#comp">Compilation</a></li>
|
||||
<li><a href="#eval">Evaluation</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<h2><a name="pre">Objectives:</a></h2>
|
||||
<ul>
|
||||
<li>Speed</li>
|
||||
<li>Better support for AVTs</li>
|
||||
<li>Interruptability of processing</li>
|
||||
<li>exclude and alias namespaces</li>
|
||||
</ul>
|
||||
<h2>Concepts:</h2>
|
||||
<div>
|
||||
<dl>
|
||||
<dt>LRE namespaces</dt>
|
||||
<dd>All namespace aliases are merged wit import precedence
|
||||
into an array of all namespace ids, which is used to map the
|
||||
LRE namespace in the source to the LRE namespace in the
|
||||
result. Non-aliased namespaces just have their namespace id
|
||||
in that array.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<h2><a name="comp">Compilation:</a></h2>
|
||||
<p>The XSLT specification describes XSLT in terms of the XPath
|
||||
datamodel, something pretty close to a DOM. So we talk about the
|
||||
input in terms of DOM elements.</p>
|
||||
<div>The DOM nodes in a stylesheet get compiled into either
|
||||
<ul>
|
||||
<li>nothing :-) (stuff like xsl:output),</li>
|
||||
<li><code>xslTopElement</code>s or</li>
|
||||
<li><code>xslInstruction</code>s.</li>
|
||||
</ul>
|
||||
The <code>xslInstruction</code>s fall into classes,
|
||||
<ol>
|
||||
<li>simple instructions,</li>
|
||||
<li>utilities (no-op, variable-pop, push-handler),</li>
|
||||
<li>branching instructions,</li>
|
||||
<li>instructions changing the result handler and</li>
|
||||
<li>instructions calling into different
|
||||
<code>xslTopElement</code>s.</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h2><a name="eval">How do instructions work?</a></h2>
|
||||
<div>The general pattern used to create output from a set of
|
||||
instructions is
|
||||
<pre>while (instruction) {
|
||||
rv = instruction.do(args);
|
||||
if (NS_FAILED(rv)) {
|
||||
//cleanup
|
||||
return rv;
|
||||
}
|
||||
instruction = instruction.mNext;
|
||||
}</pre>
|
||||
This says pretty much all about simple and utility instructions.
|
||||
</div>
|
||||
<h3>Branching instructions</h3>
|
||||
<div>see <a href="#choose">xsl:choose</a>. The trailing single
|
||||
no-op helps in rejoining the paths, as that no-op can be created
|
||||
before the paths and thus easily appended to each end of the
|
||||
paths.</div>
|
||||
<h3>Instructions that change the output handler</h3>
|
||||
<div>These instructions (attribute, comment, pi creating text
|
||||
handlers, variable possibly creating a rtf handler) get created
|
||||
by inserting a push-handler-instruction into the workflow for
|
||||
the start of the element and the XSLT instruction at the
|
||||
end. The handler instruction should keep a non-owning reference
|
||||
to the push-handler-instruction to get the result and restore
|
||||
the previous handler.</div>
|
||||
|
||||
<h3><a name="apply-imports">xsl:apply-imports</a></h3>
|
||||
<div class="section">no idea</div>
|
||||
|
||||
<h3><a name="apply-templates">xsl:apply-templates</a></h3>
|
||||
<div class="section">
|
||||
<dl>
|
||||
<dt>members:</dt>
|
||||
<dd>
|
||||
<dl>
|
||||
<dt>select</dt> <dd>node-set-expression</dd>
|
||||
<dt>mode</dt> <dd>qname</dd>
|
||||
<dt>sorts</dt> <dd>list of xsl:sort elements</dd>
|
||||
<dt>params</dt> <dd>list of xsl:with-param elements</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>do()</dt>
|
||||
<dd>set up the params, if any, evaluate the select, create a
|
||||
evalContext and push it on the evalContextStack. push the next
|
||||
instruction to the instruction return stack. trigger the new
|
||||
context (how do we do this?).</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<h3><a name="attribute">xsl:attribute</a></h3>
|
||||
<div class="section">
|
||||
<dl>
|
||||
<dt>members:</dt>
|
||||
<dd>
|
||||
<dl>
|
||||
<dt class="required">name</dt> <dd>AVT with QName value</dd>
|
||||
<dt>namespace</dt> <dd>AVT with uri value</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>do()</dt>
|
||||
<dd>the start tag pushes a textValueHandler, the end tag pops
|
||||
the value handler and calls the outputhandler::attribute</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<h3><a name="attribute-set">xsl:attribute-set</a> (tle)</h3>
|
||||
<div class="section"><span class="TODO">attribute sets are merged,
|
||||
we should pay attention that multiple stylesheet compilers
|
||||
don't mix their content. Order of attributes is relevant, IMHO.</span>
|
||||
<dl>
|
||||
<dt>members:</dt>
|
||||
<dd>
|
||||
<dl>
|
||||
<dt class="required">name</dt> <dd>qname</dd>
|
||||
<dt>use-attribute-sets</dt> <dd>list of qnames</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>do()</dt>
|
||||
<dd>merging and stuff needed in the global stylesheet object,
|
||||
(NOT part of <a href="#import-frame">import frame).</a></dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<h3><a name="call-template">xsl:call-template</a></h3>
|
||||
<div class="section">
|
||||
<dl>
|
||||
<dt>members:</dt>
|
||||
<dd>
|
||||
<dl>
|
||||
<dt class="required">name</dt> <dd>qname</dd>
|
||||
<dt>with-params</dt> <dd>list of xsl:with-params</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>do()</dt>
|
||||
<dd>push the next instruction onto the instruction return
|
||||
stack, lookup the template and set the instruction pointer
|
||||
to the called template. Setup the params, if there are. This
|
||||
does not change the evalContextStack.
|
||||
<div class="issue">Can we cache this? What happens if a
|
||||
added stylesheet between two transforms changes which
|
||||
stylesheet this qname resolves to?</div></dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<h3><a name="choose">xsl:choose</a></h3>
|
||||
<div class="section">
|
||||
This is a branching instruction with one exit point and several
|
||||
conditional entry points (xsl:when) and one default
|
||||
(xsl:otherwise). The conditional entry points start with a
|
||||
conditionalGotoInstrunction, which jumps to the next entry point
|
||||
if they don't succeed. Each of them ends with a gotoInstruction
|
||||
that jumps to the end of the xsl:choose (for simplicity in the
|
||||
compilation phase, this might be a noopInstruction). The
|
||||
xsl:otherwise is just the instructions list of the
|
||||
xsl:otherwise, linked to the ending noopInstruction. Note that
|
||||
this construct a single instruction list for the complete
|
||||
xsl:choose, as the mNext of the final gotos is the next entry
|
||||
point. This mNext is only used for iterations, though.
|
||||
</div>
|
||||
|
||||
<h3><a name="comment">xsl:comment</a></h3>
|
||||
<div class="section">
|
||||
<dl>
|
||||
<dt>do()</dt>
|
||||
<dd>startElement pushes a textHandler, endElement takes the
|
||||
value and calls ::comment() in the output handler</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<h3><a name="copy">xsl:copy</a></h3>
|
||||
<div class="section">
|
||||
<dl>
|
||||
<dt>members:</dt>
|
||||
<dd></dd>
|
||||
<dt>do()</dt>
|
||||
<dd>xsl:copy has a <a
|
||||
href="#attribute-sets">use-attribute-sets</a> attribute,
|
||||
<span class="TODO">TODO</span></dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<h3><a name="copy-of">xsl:copy-of</a></h3>
|
||||
<div class="section">
|
||||
<dl>
|
||||
<dt>members:</dt>
|
||||
<dd>
|
||||
<dl>
|
||||
<dt class="required">select</dt>
|
||||
<dd>an expression to be added to the result tree</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>do()</dt>
|
||||
<dd>the value of the result is added to the result tree. If
|
||||
the result is a RTF, the RTF is just fed into the output
|
||||
handler, if the result is not a nodeset, it is converted
|
||||
into a string and ::characters is called on the output
|
||||
handler. For nodesets, the result is a list of source nodes
|
||||
which have to be interpreted, for example thru the
|
||||
stylesheet compiler. This has be xslt-blind, that is, xslt
|
||||
elements in the source must be treated as LRE elements and
|
||||
copied into the result, instead of generating XSLT
|
||||
instructions. <span class="TODO">is this all?</span></dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<h3><a name="decimal-format">xsl:decimal-format</a> (tle)</h3>
|
||||
<div class="section">xsl:decimal-format is stored in the global
|
||||
stylesheet object, import precedence <b>does not</b> apply.</div>
|
||||
|
||||
<h3><a name="element">xsl:element</a></h3>
|
||||
<div class="section">
|
||||
<dl>
|
||||
<dt>members:</dt>
|
||||
<dd>
|
||||
<dl>
|
||||
<dt class="required">name</dt> <dd>AVT with QName
|
||||
value</dd>
|
||||
<dt>namespace</dt> <dd>AVT with URI value</dd>
|
||||
</dl>
|
||||
</dd>
|
||||
<dt>do()</dt>
|
||||
<dd>xsl:element has <a
|
||||
href="#attribute-sets">attribute-set</a>s, <span
|
||||
class="TODO">todo</span>. Other than that, this just
|
||||
generates an element. Note that the attributes of this
|
||||
element have to be discarded, if the name AVT does not
|
||||
evaluate to a QName.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<h3><a name="fallback">xsl:fallback</a></h3>
|
||||
<div class="section"><span class="TODO">do we care?</span></div>
|
||||
|
||||
<h3><a name=""></a></h3>
|
||||
<div class="section">
|
||||
<dl>
|
||||
<dt>members:</dt>
|
||||
<dd></dd>
|
||||
<dt>do()</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,376 +0,0 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Transformiix (TM) Contributors</TITLE>
|
||||
<META name="author" content="Keith Visco">
|
||||
</HEAD>
|
||||
<BODY Text="#000000" BGColor="#FFFFFF">
|
||||
<!-- OUTER TABLE -->
|
||||
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="640">
|
||||
<TR>
|
||||
<TD WIDTH="80"></TD>
|
||||
<TD WIDTH="560" COLSPAN="2" ALIGN="RIGHT">
|
||||
<B><FONT SIZE="+2">Transfor<FONT Color="blue">Mii</FONT>X</FONT></B>
|
||||
<SUP>TM</SUP>
|
||||
</TD>
|
||||
</TR>
|
||||
<TD WIDTH="80"><BR></TD>
|
||||
<TD WIDTH="560" COLSPAN="2">
|
||||
<!-- Contents -->
|
||||
<HR SIZE="1" />
|
||||
<BR/>
|
||||
<P>
|
||||
Much of the original <B>Transfor<FONT Color="blue">Mii</FONT>X</B> code was ported
|
||||
from <A HREF="http://www.clc-marketing.com/xslp">XSL:P</A>,
|
||||
an open source XSLT processor. Thanks to all the contributors of
|
||||
that project. TransforMiiX is now a whole new beast...thanks to all
|
||||
of the hard work of those listed below.
|
||||
<P>
|
||||
<P>
|
||||
<B>Core Developers</B><P>
|
||||
The following people have contributed substantial time and
|
||||
effort to the development.
|
||||
<TABLE WIDTH="100%" CELLSPACING="1">
|
||||
<TR BGColor="#EEEEEE"><TH>Name</TH><TH>Contribution</TH><TH>Company</TH></TR>
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A href="mailto:kvisco@ziplink.net">Visco, Keith</a>
|
||||
</TD>
|
||||
<TD VALIGN="TOP" WIDTH="300">
|
||||
Software design, and most of the XSLT implementation and
|
||||
base classes implementation.
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="http://www.exoffice.com">Exoffice Technologies</A>
|
||||
<P>
|
||||
<FONT SIZE="-1">Formerly with The MITRE Corporation</FONT>.
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A href="mailto:tomk@mitre.org">Kneeland, Tom</a>
|
||||
</TD>
|
||||
<TD>
|
||||
Software design, DOM Implementation. Handled the initial
|
||||
Mozilla integration and wrapper classes,
|
||||
String and String wrapper classes.
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="http://www.mitre.org">The MITRE Corporation</A>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:peter.vanderbeken@pandora.be">Van der Beken, Peter</A>
|
||||
</TD>
|
||||
<TD VALING="TOP" WIDTH="300">
|
||||
Leading the Transformiix/Mozilla integration,
|
||||
and Macintosh porting issues. Without Peter...we'd be doomed! :-)
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:axel@pike.org">Hecht, Axel</A> (AKA - Pike)
|
||||
</TD>
|
||||
<TD WIDTH="300">
|
||||
Build issues...configure, Make, etc. Solaris porting issues.
|
||||
All nasty comments on regarding make files should now be directed to Pike!
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
</P>
|
||||
<P>
|
||||
<P>
|
||||
<B>Additional Developers</B><P>
|
||||
The following people have contributed to the development.
|
||||
<BR>(appearing in alphabetical order)
|
||||
<TABLE WIDTH="100%" CELLSPACING="1">
|
||||
<TR BGColor="#EEEEEE"><TH>Name</TH><TH>Contribution</TH><TH>Company</TH></TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:arthur.barrett@march-hare.com">Barrett, Arthur</A>
|
||||
</TD>
|
||||
<TD WIDTH="300">
|
||||
Working on Windows makefiles.
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:bbrown@solana.com">Brown, William Lewis</A>
|
||||
</TD>
|
||||
<TD WIDTH="300">
|
||||
Working with Marina on XSLT 1.0 conformity issues.
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:duxy@leyou.com.cn">Du, Eric</A>
|
||||
</TD>
|
||||
<TD WIDTH="300">
|
||||
FreeBSD floating point porting issues
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:lef@opentext.com">Fitzpatrick, Larry</A>
|
||||
</TD>
|
||||
<TD WIDTH="300">
|
||||
Larry was the first contributor to the project. He sent
|
||||
a number of C++ porting issues with Visual C++,
|
||||
and has influenced some of the early design.
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="http://www.opentext.com">OpenText</A>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:ogerardin@vo.lu">Gerardin, Olivier</A>
|
||||
</TD>
|
||||
<TD WIDTH="300">
|
||||
Implemented the XPath Number functions, the document()
|
||||
function, as well as some other changes/improvements.
|
||||
<FONT SIZE="-1">
|
||||
(see <A HREF="changes.txt">changes.txt</A> for more info)
|
||||
</FONT>
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="http://www.digitalwave.lu">DigitalWave</A>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:rguarino@wavo.com">Guarino, Bobbi</A>
|
||||
</TD>
|
||||
<TD WIDTH="300">
|
||||
Solaris porting issues
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="http://www.wavo.com">Wavo Corporation</A>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:Heesch@t-online.de">Heesch, Stefan</A>
|
||||
</TD>
|
||||
<TD WIDTH="300">
|
||||
C++ porting issues with Borland C
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<BR><A HREF=""></A>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:joe@pwd.hp.com">Kuan, Joseph</A>
|
||||
</TD>
|
||||
<TD WIDTH="300">
|
||||
Sent changes for getting TransforMiiX to build on HPUX, SUNOS and AIX.
|
||||
<I>I still need to add these into the CVS.</I>
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="http://www.hp.com">Hewlett-Packard</A>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:mclee@oblix.com">Lee, Michele</A>
|
||||
</TD>
|
||||
<TD WIDTH="300">
|
||||
C++ porting issues, bug reports
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="http://www.oblix.com">Oblix</A>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:lidong@leyou.com.cn">Lidong</A>
|
||||
</TD>
|
||||
<TD WIDTH="300">
|
||||
Some Unicode bug fixes
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="http://www.leyou.com">Leyou.com</A>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:mmarina@mindspring.com">Mechtcheriakova, Marina</A>
|
||||
</TD>
|
||||
<TD WIDTH="300">
|
||||
Contributed a number of bug fixes, as well as handling
|
||||
some conformity issues.
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:kbob@oblix.com">Miller, Bob</A>
|
||||
</TD>
|
||||
<TD WIDTH="300">
|
||||
A number of bug fixes, C++ porting issues
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="http://www.oblix.com">Oblix</A>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:andreas.otte@primus-online.de">Otte, Andreas</A>
|
||||
</TD>
|
||||
<TD WIDTH="300">
|
||||
Helping Axel with build issues...configure, make files, etc.
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:npride@wavo.com">Pride, Nathan</A>
|
||||
</TD>
|
||||
<TD WIDTH="300">
|
||||
Solaris porting issues, some general bug fixes
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="http://www.wavo.com">Wavo Corporation</A>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD VALIGN="TOP">
|
||||
<A HREF="mailto:jjs@acis.com.au">Smith, Justin</A>
|
||||
</TD>
|
||||
<TD WIDTH="300">
|
||||
Working on Windows Makefiles.
|
||||
</TD>
|
||||
<TD VALIGN="TOP">
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
|
||||
</TABLE>
|
||||
|
||||
<P><B>Testing/Feedback (Suggestions/Bug Reports)</B><P>
|
||||
The following people have used TransforMiiX and provided feedback that has been
|
||||
beneficial to the development.
|
||||
<BR>(appearing in alphabetical order)
|
||||
<TABLE BORDER="0" WIDTH="100%">
|
||||
<TR BGColor="#EEEEEE"><TD><B>Name</B></TD><TD><B>Company</B></TD></TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD><A HREF="mailto:jbailey@nisa.net">Bailey, Jeff</A></TD>
|
||||
<TD><BR></TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD><A HREF="mailto:bbrown@solana.com">Brown, William Lewis</A></TD>
|
||||
<TD><BR></TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD><A HREF="mailto:tlebouil@lucent.com">Le Bouil, Thierry</A></TD>
|
||||
<TD><A HREF="http://www.lucent.com">Lucent Technologies, Inc.</A></TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD><A HREF="mailto:schefer@xo3.com">Schefer, Marc</A></TD>
|
||||
<TD><BR></TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD><A HREF="mailto:stinney@sas.upenn.edu">Tinney, Steve</A></TD>
|
||||
<TD><A HREF="http://www.upenn.com">University of Pennsylvania</A></TD>
|
||||
<!-- Comments: UTF8 bug report -->
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD><A HREF="mailto:jiwei.wang@saraide.com">Wang, Jiwei</A></TD>
|
||||
<TD><BR></TD>
|
||||
</TR>
|
||||
|
||||
<!-- Entry -->
|
||||
<TR BGColor="#EEEEEE">
|
||||
<TD>
|
||||
<A HREF="mailto:bzwische@email.archlab.tuwien.ac.at">
|
||||
Zwischenbrugger, Bernhard</A>
|
||||
</TD>
|
||||
<TD><BR></TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
<!-- End Contents -->
|
||||
|
||||
<!-- Footer -->
|
||||
<HR SIZE="1">
|
||||
<FONT SIZE="-1">
|
||||
The MITRE Corporation, Keith Visco (C) Copyright 1999-2000, All rights reserved<BR>
|
||||
Email:<A HREF="mailto:kvisco@ziplink.net">kvisco@ziplink.net</A>
|
||||
</FONT>
|
||||
<!-- End Footer -->
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<!-- End Outer Table -->
|
||||
</HTML>
|
||||
@@ -1,172 +0,0 @@
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>TransforMiiX(tm)</TITLE>
|
||||
<META name="author" content="Keith Visco">
|
||||
</HEAD>
|
||||
<BODY Text="#000000" BGColor="#FFFFFF">
|
||||
<!-- OUTER TABLE -->
|
||||
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="640">
|
||||
<TR>
|
||||
<TD WIDTH="80"></TD>
|
||||
<TD WIDTH="80">
|
||||
<B><I><FONT SIZE="+2" COLOR="BLUE">MITRE</FONT></I></B>
|
||||
</TD>
|
||||
<TD WIDTH="480" ALIGN="RIGHT">
|
||||
<B><FONT SIZE="+2">Transfor<FONT Color="blue">Mii</FONT>X</FONT></B>
|
||||
<SUP>TM</SUP>
|
||||
</TD>
|
||||
</TR>
|
||||
<TD WIDTH="80"><BR></TD>
|
||||
<TD WIDTH="560" COLSPAN="2">
|
||||
<!-- Contents -->
|
||||
|
||||
<HR SIZE="1" />
|
||||
<BR/>
|
||||
<P>
|
||||
<B>Transfor<FONT Color="blue">Mii</FONT>X</B> is an XSLT processor which is
|
||||
not yet complete, but supports a good portion of the
|
||||
<A HREF="http://www.w3.org/TR/1999/REC-xslt-19991116">XSLT 1.0 recommendation</A>.
|
||||
|
||||
<P>
|
||||
<B>Transfor<FONT Color="blue">Mii</FONT>X</B> was designed to be a "standalone"
|
||||
XSLT processor. This means you can call the processor from the command line,
|
||||
or via the XSLProcessor API. The only thing TransforMiiX requires is an XML parser,
|
||||
and the currently supported parser is
|
||||
<A href="http://www.jclark.com/xml/expat.html">Expat</A> written by James Clark.
|
||||
</P>
|
||||
<P>
|
||||
There is currently an effort undergoing to integrate
|
||||
TransforMiiX with Mozilla. This effort
|
||||
is not yet complete and therefor the XSLT processor cannot yet be used
|
||||
within the Mozilla browser. Integration is nearing completion, however.
|
||||
</P>
|
||||
<P>
|
||||
<HR SIZE="1">
|
||||
<P>
|
||||
<B>Running <B>Transfor<FONT Color="blue">Mii</FONT>X</B> from the command line</B>
|
||||
<P />
|
||||
The command line syntax is pretty straight forward:
|
||||
<P>
|
||||
<B>example:</B> <I>transfrmx -i my.xml -s my.xsl -o my.out</I>
|
||||
</P>
|
||||
This will process the XML source file called "my.xml" using the "my.xsl" XSLT stylesheet,
|
||||
and the result will be placed in "my.out".
|
||||
|
||||
The "-s" flag is not required if the XSLT stylesheet is specified inside the XML source
|
||||
document using the "xml-stylesheet" PI (processing instruction).
|
||||
<P>
|
||||
The stylesheet PI, should appear below the XML declaration
|
||||
("<FONT SIZE="-1"><?xml version="1.0"?></FONT>").
|
||||
<P>
|
||||
<B>example:</B>
|
||||
<TABLE BGColor="" BORDER="1">
|
||||
<TR>
|
||||
<TD>
|
||||
<PRE>
|
||||
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="my.xsl" type="text/xsl"?>
|
||||
<document>
|
||||
...
|
||||
</document>
|
||||
</PRE>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<P>
|
||||
The command line program is in "source/main/transformiix.cpp" and is simply
|
||||
a wrapper for "source/xsl/XSLProcessor.cpp" which is the TransforMiiX API.
|
||||
</P>
|
||||
<P>
|
||||
Feel free to run the examples in the "source/examples" directory, they are a
|
||||
good example of what has been implemented so far in TransforMiiX.
|
||||
<P>
|
||||
|
||||
<HR SIZE="1">
|
||||
<P>
|
||||
<B>What is the current status of Transfor<FONT Color="blue">Mii</FONT>X</B>?
|
||||
<P />
|
||||
You can check the current status by looking three main files:
|
||||
<UL>
|
||||
<LI><A HREF="changes.txt">changes.txt</A> - lists the changes from different builds
|
||||
<LI><A HREF="remaining.txt">remaining.txt</A> - lists what needs to be implemented.
|
||||
<LI><A HREF="known-issues.html">known-issues.html</A> - lists known bugs or issues.
|
||||
<BR />
|
||||
-- this is a little out of date...sorry.
|
||||
</UL>
|
||||
<P>
|
||||
<HR SIZE="1">
|
||||
<P>
|
||||
<B>What can I do to help finish the implementation of
|
||||
Transfor<FONT Color="blue">Mii</FONT>X</B>?
|
||||
<P />
|
||||
There are a number of things that can be done:
|
||||
<P>
|
||||
<B>Development</B>
|
||||
<OL>
|
||||
<LI>Check out the source code, build it.
|
||||
<LI>Use it.
|
||||
<LI>Familiarize yourself with the code.
|
||||
<LI>Look at the the "to-do" or "known issues" list and choose something
|
||||
that you would like to work on.
|
||||
<LI> If it's a large task, notify us that you are working on a task or issue, or
|
||||
would like to contribute to the existing effort of a specific task.
|
||||
<BR>
|
||||
If it's a simple change you may contact us first to make sure
|
||||
you are not duplicating effort, or feel free to just make the changes.
|
||||
<LI>If you have CVS commit status, commit your code,
|
||||
otherwise submit your code to be integrated to us.
|
||||
<BR>
|
||||
<B>
|
||||
<FONT SIZE="-1">
|
||||
Please do a "cvs update" to make sure you have the latest changes, and that
|
||||
your changes work with any code changes that might have occured during
|
||||
your development.
|
||||
</FONT>
|
||||
</B>
|
||||
</OL>
|
||||
|
||||
<B>Bug Reporting</B>
|
||||
<OL>
|
||||
<LI>Check out the source code, build it.
|
||||
<LI>Use it.
|
||||
<LI>Submit any bugs to the
|
||||
<A HREF="news://news.mozilla.org/netscape.public.mozilla.layout.xslt">
|
||||
mailing list [netscape.public.mozilla.layout.xslt]</A>
|
||||
or directly to us.
|
||||
</OL>
|
||||
|
||||
<B>Documentation</B>
|
||||
<OL>
|
||||
<LI>Check out the source code, build it.
|
||||
<LI>Use it.
|
||||
<LI>Find something that's not documented - pretty easy to do at this point.
|
||||
<LI>Document #3.
|
||||
<LI>If you have commit status, commit your documentation, otherwise
|
||||
submit your documentation directly to us.
|
||||
</OL>
|
||||
<P>
|
||||
|
||||
<B>Miscellaneous (but important)</B> <BR>
|
||||
<FONT SIZE="-1"> -- I just wouldn't be myself if I didn't add these! -- Keith :-) </FONT>
|
||||
<OL>
|
||||
<LI>Get me a date with Claudia Schiffer or Kelly Hu.
|
||||
<LI>Get me some coffee!
|
||||
</OL>
|
||||
<P>
|
||||
<!-- End Contents -->
|
||||
|
||||
<!-- Footer -->
|
||||
<HR SIZE="1">
|
||||
<FONT SIZE="-1">
|
||||
The MITRE Corporation, Keith Visco (C) Copyright 1999, All rights reserved<BR>
|
||||
Email: <A HREF="mailto:kvisco@ziplink.net">Keith Visco</A>,
|
||||
<A HREF="mailto:tomk@mitre.org">Tom Kneeland</A>
|
||||
</FONT>
|
||||
<!-- End Footer -->
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<!-- End Outer Table -->
|
||||
</HTML>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,27 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Peter Van der Beken are Copyright (C) 2000
|
||||
* Peter Van der Beken. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Van der Beken, peter.vanderbeken@pandora.be
|
||||
* -- original author.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "MacSharedPrefix.h"
|
||||
@@ -1,27 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Peter Van der Beken are Copyright (C) 2000
|
||||
* Peter Van der Beken. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Van der Beken, peter.vanderbeken@pandora.be
|
||||
* -- original author.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "MacSharedPrefix_debug.h"
|
||||
@@ -1,47 +0,0 @@
|
||||
# ***** 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.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Axel Hecht.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2002
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <axel@pike.org>
|
||||
#
|
||||
# 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 *****
|
||||
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MOZ_CHROME_FILE_FORMAT=flat
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
@@ -1,77 +0,0 @@
|
||||
/* -*- 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
|
||||
* Axel Hecht.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
const enablePrivilege = netscape.security.PrivilegeManager.enablePrivilege;
|
||||
const IOSERVICE_CTRID = "@mozilla.org/network/io-service;1";
|
||||
const nsIIOService = Components.interfaces.nsIIOService;
|
||||
const SIS_CTRID = "@mozilla.org/scriptableinputstream;1";
|
||||
const nsISIS = Components.interfaces.nsIScriptableInputStream;
|
||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
const STDURL_CTRID = "@mozilla.org/network/standard-url;1";
|
||||
const nsIURI = Components.interfaces.nsIURI;
|
||||
|
||||
var gStop = false;
|
||||
|
||||
function loadFile(aUriSpec)
|
||||
{
|
||||
enablePrivilege('UniversalXPConnect');
|
||||
var serv = Components.classes[IOSERVICE_CTRID].
|
||||
getService(nsIIOService);
|
||||
if (!serv) {
|
||||
throw Components.results.ERR_FAILURE;
|
||||
}
|
||||
var chan = serv.newChannel(aUriSpec, null, null);
|
||||
var instream =
|
||||
Components.classes[SIS_CTRID].createInstance(nsISIS);
|
||||
instream.init(chan.open());
|
||||
|
||||
return instream.read(instream.available());
|
||||
}
|
||||
|
||||
function dump20(aVal)
|
||||
{
|
||||
const pads = ' ';
|
||||
if (typeof(aVal)=='string')
|
||||
out = aVal;
|
||||
else if (typeof(aVal)=='number')
|
||||
out = Number(aVal).toFixed(2);
|
||||
else
|
||||
out = new String(aVal);
|
||||
dump(pads.substring(0, 20 - out.length));
|
||||
dump(out);
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/* -*- 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
|
||||
* Axel Hecht.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
var gParser = new DOMParser;
|
||||
var gProc = new XSLTProcessor;
|
||||
var gTimeout;
|
||||
|
||||
function Test(aTitle, aSourceURL, aStyleURL, aNumber, aObserver)
|
||||
{
|
||||
this.mTitle = aTitle;
|
||||
this.mObserver = aObserver;
|
||||
this.mTotal = aNumber;
|
||||
this.mDone = 0;
|
||||
var xmlcontent = loadFile(aSourceURL);
|
||||
var xslcontent = loadFile(aStyleURL);
|
||||
this.mSource = gParser.parseFromString(xmlcontent, 'text/xml');
|
||||
this.mStyle = gParser.parseFromString(xslcontent, 'text/xml');
|
||||
}
|
||||
|
||||
function runTest(aTitle, aSourceURL, aStyleURL, aNumber, aObserver)
|
||||
{
|
||||
test = new Test(aTitle, aSourceURL, aStyleURL, aNumber,
|
||||
aObserver);
|
||||
gTimeout = setTimeout(onNextTransform, 100, test, 0);
|
||||
}
|
||||
|
||||
function onNextTransform(aTest, aNumber)
|
||||
{
|
||||
res = document.implementation.createDocument('', '', null);
|
||||
var startTime = Date.now();
|
||||
gProc.transformDocument(aTest.mSource, aTest.mStyle, res, null);
|
||||
var endTime = Date.now();
|
||||
aNumber++;
|
||||
var progress = aNumber / aTest.mTotal * 100;
|
||||
if (aTest.mObserver) {
|
||||
aTest.mObserver.progress(aTest.mTitle, endTime - startTime,
|
||||
progress);
|
||||
}
|
||||
if (aNumber < aTest.mTotal) {
|
||||
gTimeout = setTimeout(onNextTransform, 100, aTest, aNumber);
|
||||
} else if (aTest.mObserver) {
|
||||
aTest.mObserver.done(aTest.mTitle);
|
||||
}
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
/* -*- 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
|
||||
* Axel Hecht.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
var view =
|
||||
{
|
||||
configUrl: null,
|
||||
testArray: null,
|
||||
mCurrent: null,
|
||||
|
||||
browseForConfig: function()
|
||||
{
|
||||
enablePrivilege('UniversalXPConnect');
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"].
|
||||
createInstance(nsIFilePicker);
|
||||
fp.init(window,'XSLTMark Description File',nsIFilePicker.modeOpen);
|
||||
fp.appendFilter('*.conf', '*.conf');
|
||||
fp.appendFilters(nsIFilePicker.filterAll);
|
||||
var res = fp.show();
|
||||
|
||||
if (res == nsIFilePicker.returnOK) {
|
||||
this.configUrl = Components.classes[STDURL_CTRID].createInstance(nsIURI);
|
||||
this.configUrl.spec = fp.fileURL.spec;
|
||||
document.getElementById('config').setAttribute('value', this.configUrl.spec);
|
||||
}
|
||||
this.parseConfig();
|
||||
return true;
|
||||
},
|
||||
|
||||
parseConfig: function()
|
||||
{
|
||||
this.testArray = new Array();
|
||||
var test;
|
||||
if (!this.configUrl) {
|
||||
return;
|
||||
}
|
||||
|
||||
var content = loadFile(this.configUrl.spec);
|
||||
|
||||
var lines = content.split("\n");
|
||||
var line, res;
|
||||
var head = /^\[(.+)\]$/;
|
||||
var instruct = /^(.+)=(.+)$/;
|
||||
while (lines.length) {
|
||||
line = lines.shift();
|
||||
if (head.test(line)) {
|
||||
test = new Object;
|
||||
res = head.exec(line);
|
||||
test['title'] = res[1];
|
||||
this.testArray.push(test);
|
||||
}
|
||||
else if (line == '') {
|
||||
test = undefined;
|
||||
}
|
||||
else {
|
||||
res = instruct.exec(line);
|
||||
test[res[1]] = res[2];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onLoad: function()
|
||||
{
|
||||
this.mCurrentStatus = document.getElementById('currentStatus');
|
||||
this.mCurrentProgress = document.getElementById('currentProgress');
|
||||
this.mTotalProgress = document.getElementById('totalProgress');
|
||||
this.mOutput = document.getElementById('transformOutput');
|
||||
this.mDetailOutput =
|
||||
document.getElementById('transformDetailedOutput');
|
||||
this.mDetail = true;
|
||||
},
|
||||
|
||||
progress: function(aTitle, aTime, aProgress)
|
||||
{
|
||||
// dump20(aTitle);
|
||||
// dump20(aTime);
|
||||
// dump20(aProgress);
|
||||
this.mCurrentProgress.value = aProgress;
|
||||
this.displayDetailTime(aTime);
|
||||
this.mTimes.push(aTime);
|
||||
// dump("\n");
|
||||
},
|
||||
|
||||
done: function(aTitle)
|
||||
{
|
||||
// dump(aTitle + " is finished.\n");
|
||||
this.mCurrent++;
|
||||
this.mCurrentProgress.value = 0;
|
||||
this.displayTotalTime();
|
||||
if (this.mCurrent >= this.testArray.length) {
|
||||
this.mTotalProgress.value = 0;
|
||||
this.mCurrentStatus.value = "done";
|
||||
return;
|
||||
}
|
||||
this.mTotalProgress.value = this.mCurrent*100/this.testArray.length;
|
||||
var test = this.testArray[this.mCurrent];
|
||||
enablePrivilege('UniversalXPConnect');
|
||||
this.displayTest(test.title);
|
||||
runTest(test.title, this.configUrl.resolve(test.input),
|
||||
this.configUrl.resolve(test.stylesheet),
|
||||
test.iterations, this);
|
||||
},
|
||||
|
||||
onStop: function()
|
||||
{
|
||||
clearTimeout(gTimeout);
|
||||
this.mCurrentProgress.value = 0;
|
||||
this.mTotalProgress.value = 0;
|
||||
this.mCurrentStatus.value = "stopped";
|
||||
},
|
||||
|
||||
displayTest: function(aTitle)
|
||||
{
|
||||
this.mTimes = new Array;
|
||||
aTitle += "\t";
|
||||
this.mCurrentStatus.value = aTitle;
|
||||
this.mOutput.value += aTitle;
|
||||
if (this.mDetail) {
|
||||
this.mDetailOutput.value += aTitle;
|
||||
}
|
||||
},
|
||||
|
||||
displayDetailTime: function(aTime)
|
||||
{
|
||||
if (this.mDetail) {
|
||||
this.mDetailOutput.value += aTime + " ms\t";
|
||||
}
|
||||
},
|
||||
|
||||
displayTotalTime: function()
|
||||
{
|
||||
var sum = 0;
|
||||
for (k = 0; k < this.mTimes.length; k++) {
|
||||
sum += this.mTimes[k];
|
||||
}
|
||||
var mean = sum / this.mTimes.length;
|
||||
this.mOutput.value += Number(mean).toFixed(2) + " ms\t" + sum + " ms\t";
|
||||
var variance = 0;
|
||||
for (k = 0; k < this.mTimes.length; k++) {
|
||||
var n = this.mTimes[k] - mean;
|
||||
variance += n*n;
|
||||
}
|
||||
variance = Math.sqrt(variance/this.mTimes.length);
|
||||
this.mOutput.value += Number(variance).toFixed(2)+"\n";
|
||||
if (this.mDetail) {
|
||||
this.mDetailOutput.value += "\n";
|
||||
}
|
||||
},
|
||||
|
||||
runBenchmark: function()
|
||||
{
|
||||
enablePrivilege('UniversalXPConnect');
|
||||
if (!this.testArray) {
|
||||
if (!this.configUrl) {
|
||||
this.configUrl = Components.classes[STDURL_CTRID].createInstance(nsIURI);
|
||||
this.configUrl.spec = document.getElementById('config').value;
|
||||
}
|
||||
this.parseConfig();
|
||||
}
|
||||
|
||||
this.mCurrent = 0;
|
||||
var test = this.testArray[this.mCurrent];
|
||||
this.mOutput.value = '';
|
||||
if (this.mDetail) {
|
||||
this.mDetailOutput.value = '';
|
||||
}
|
||||
this.displayTest(test.title);
|
||||
runTest(test.title, this.configUrl.resolve(test.input),
|
||||
this.configUrl.resolve(test.stylesheet),
|
||||
test.iterations, this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Axel Hecht.
|
||||
* Portions created by Axel Hecht are Copyright (C) 2002 Axel Hecht.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org> (Original Author)
|
||||
*/
|
||||
|
||||
textbox.out {
|
||||
white-space: pre;
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
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.
|
||||
|
||||
The Initial Developer of the Original Code is Axel Hecht.
|
||||
Portions created by Axel Hecht are Copyright (C) 2002 Axel Hecht.
|
||||
All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Axel Hecht <axel@pike.org> (Original Author)
|
||||
-->
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="XSLTMark.css" type="text/css"?>
|
||||
<window id="XSLTMarkHarness"
|
||||
title="XSLTMark"
|
||||
onload="view.onLoad()"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
orient="vertical">
|
||||
<script type="application/x-javascript" src="XSLTMark-static.js" />
|
||||
<script type="application/x-javascript" src="XSLTMark-test.js" />
|
||||
<script type="application/x-javascript" src="XSLTMark-view.js" />
|
||||
|
||||
<hbox>
|
||||
<groupbox orient="horizontal">
|
||||
<caption label="test description file" />
|
||||
<label value=""/><!-- needed, otherwise groupbox fucks up :-( -->
|
||||
<textbox id="config" persist="value" readonly="true"/>
|
||||
<button label="browse..." oncommand="view.browseForConfig();" />
|
||||
</groupbox>
|
||||
<groupbox orient="horizontal">
|
||||
<caption label="test control" />
|
||||
<button label="run..."
|
||||
oncommand="setTimeout('view.runBenchmark();', 0);" />
|
||||
<button label="stop" oncommand="view.onStop();" />
|
||||
</groupbox>
|
||||
<groupbox orient="horizontal">
|
||||
<caption label="options" />
|
||||
<label value="responsiveness: "/>
|
||||
<menulist label="sloppy">
|
||||
<menupopup>
|
||||
<menuitem label="sloppy" selected="true"/>
|
||||
<menuitem label="bad"/>
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</groupbox>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<textbox id="currentStatus" readonly="true" flex="1"/>
|
||||
<progressmeter id="currentProgress" mode="normal" value="0" flex="2"/>
|
||||
<progressmeter id="totalProgress" mode="normal" value="0" flex="2"/>
|
||||
</hbox>
|
||||
<hbox flex="1">
|
||||
<textbox id="transformOutput" class="out" readonly="true" multiline="true" flex="1"/>
|
||||
</hbox>
|
||||
<hbox flex="1">
|
||||
<textbox id="transformDetailedOutput" class="out" readonly="true" multiline="true" flex="1"/>
|
||||
</hbox>
|
||||
</window>
|
||||
@@ -1,120 +0,0 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Axel Hecht.
|
||||
* Portions created by Axel Hecht are Copyright (C) 2001 Axel Hecht.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org> (Original Author)
|
||||
*/
|
||||
|
||||
// ----------------------
|
||||
// DiffDOM(node1,node2)
|
||||
// ----------------------
|
||||
|
||||
var isHTML = false;
|
||||
|
||||
function DiffDOM(node1, node2, aIsHTML)
|
||||
{
|
||||
isHTML = aIsHTML;
|
||||
return DiffNodeAndChildren(node1, node2);
|
||||
}
|
||||
|
||||
|
||||
// namespace attributes in the second node are ignored
|
||||
const nsreg = /^xmlns[|:\w]/;
|
||||
|
||||
// This function does the work of DiffDOM by recursively calling
|
||||
// itself to explore the tree
|
||||
function DiffNodeAndChildren(node1, node2)
|
||||
{
|
||||
if (!node1 && !node2)
|
||||
return true;
|
||||
if (!node1 || !node2)
|
||||
return ErrorUp("One of the nodes is null", node1, node2);
|
||||
if (node1.type!=node2.type)
|
||||
return ErrorUp("Different node types", node1, node2);
|
||||
|
||||
var attributes = node2.attributes;
|
||||
if (attributes && attributes.length) {
|
||||
var item, name, ns, value, otherValue;
|
||||
for (var index = 0; index < attributes.length; index++) {
|
||||
item = attributes.item(index);
|
||||
ns = item.namespaceURI;
|
||||
if (ns) {
|
||||
name = item.localName;
|
||||
otherValue = node2.getAttributeNS(ns, name);
|
||||
}
|
||||
else {
|
||||
name = item.nodeName;
|
||||
otherValue = node2.getAttribute(name);
|
||||
}
|
||||
value = item.nodeValue;
|
||||
if (!nsreg.test(name) && otherValue!=value) {
|
||||
return ErrorUp("Different values for attribute", node1, node2);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (node1.attributes && node1.attributes.length) {
|
||||
return ErrorUp("Different number of attributes", node1, node2);
|
||||
}
|
||||
|
||||
if (isHTML) {
|
||||
if (node1.nodeName.toLowerCase()!=node2.nodeName.toLowerCase())
|
||||
return ErrorUp("Different node names", node1, node2);
|
||||
}
|
||||
else {
|
||||
if (node1.nodeName!=node2.nodeName)
|
||||
return ErrorUp("Different node names", node1, node2);
|
||||
}
|
||||
if (node1.nodeValue!=node2.nodeValue)
|
||||
return ErrorUp("Different node values", node1, node2);
|
||||
if (!isHTML)
|
||||
if (node1.namespaceURI!=node2.namespaceURI)
|
||||
return ErrorUp("Different namespace", node1, node2);
|
||||
if (node1.hasChildNodes() != node2.hasChildNodes())
|
||||
return ErrorUp("Different children", node1, node2);
|
||||
if (node1.childNodes) {
|
||||
if (node1.childNodes.length != node2.childNodes.length)
|
||||
return ErrorUp("Different number of children", node1, node2);
|
||||
for (var child = 0; child < node1.childNodes.length; child++) {
|
||||
if (!DiffNodeAndChildren(node1.childNodes[child],
|
||||
node2.childNodes[child])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function ErrorUp(errMsg, node1, node2)
|
||||
{
|
||||
dump("Error: "+errMsg+"\n");
|
||||
if (node1) {
|
||||
dump("Node 1: "+node1+", ");
|
||||
if (node1.nodeType == Node.TEXT_NODE)
|
||||
dump("nodeValue: "+node1.nodeValue+"\n");
|
||||
else
|
||||
dump("nodeName: "+node1.namespaceURI+":"+node1.nodeName+"\n");
|
||||
}
|
||||
if (node2) {
|
||||
dump("Node 2: "+node2+", ");
|
||||
if (node2.nodeType == Node.TEXT_NODE)
|
||||
dump("nodeValue: "+node2.nodeValue+"\n");
|
||||
else
|
||||
dump("nodeName: "+node2.namespaceURI+":"+node2.nodeName+"\n");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
// ----------------------
|
||||
// DumpDOM(node)
|
||||
//
|
||||
// Call this function to dump the contents of the DOM starting at the specified node.
|
||||
// Use node = document.documentElement to dump every element of the current document.
|
||||
// Use node = top.window.document.documentElement to dump every element.
|
||||
//
|
||||
// 8-13-99 Updated to dump almost all attributes of every node. There are still some attributes
|
||||
// that are purposely skipped to make it more readable.
|
||||
// ----------------------
|
||||
function DumpDOM(node)
|
||||
{
|
||||
dump("--------------------- DumpDOM ---------------------\n");
|
||||
|
||||
DumpNodeAndChildren(node, "");
|
||||
|
||||
dump("------------------- End DumpDOM -------------------\n");
|
||||
}
|
||||
|
||||
|
||||
// This function does the work of DumpDOM by recursively calling itself to explore the tree
|
||||
function DumpNodeAndChildren(node, prefix)
|
||||
{
|
||||
dump(prefix + "<" + node.nodeName);
|
||||
|
||||
var attributes = node.attributes;
|
||||
|
||||
if ( attributes && attributes.length )
|
||||
{
|
||||
var item, name, value;
|
||||
|
||||
for ( var index = 0; index < attributes.length; index++ )
|
||||
{
|
||||
item = attributes.item(index);
|
||||
name = item.nodeName;
|
||||
value = item.nodeValue;
|
||||
|
||||
if ( (name == 'lazycontent' && value == 'true') ||
|
||||
(name == 'xulcontentsgenerated' && value == 'true') ||
|
||||
(name == 'id') ||
|
||||
(name == 'instanceOf') )
|
||||
{
|
||||
// ignore these
|
||||
}
|
||||
else
|
||||
{
|
||||
dump(" " + name + "=\"" + value + "\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( node.nodeType == 1 )
|
||||
{
|
||||
// id
|
||||
var text = node.getAttribute('id');
|
||||
if ( text && text[0] != '$' )
|
||||
dump(" id=\"" + text + "\"");
|
||||
}
|
||||
|
||||
if ( node.nodeName == "#text" )
|
||||
dump(" = \"" + node.data + "\"");
|
||||
|
||||
dump(">\n");
|
||||
|
||||
// dump IFRAME && FRAME DOM
|
||||
if ( node.nodeName == "IFRAME" || node.nodeName == "FRAME" )
|
||||
{
|
||||
if ( node.name )
|
||||
{
|
||||
var wind = top.frames[node.name];
|
||||
if ( wind && wind.document && wind.document.documentElement )
|
||||
{
|
||||
dump(prefix + "----------- " + node.nodeName + " -----------\n");
|
||||
DumpNodeAndChildren(wind.document.documentElement, prefix + " ");
|
||||
dump(prefix + "--------- End " + node.nodeName + " ---------\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
// children of nodes (other than frames)
|
||||
else if ( node.childNodes )
|
||||
{
|
||||
for ( var child = 0; child < node.childNodes.length; child++ )
|
||||
DumpNodeAndChildren(node.childNodes[child], prefix + " ");
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
The buster is a XUL interface to the conformance tests shipped as part of
|
||||
Xalan. For information about Xalan, please see http://xml.apache.org/.
|
||||
For your convenience we provide a packed distribution of all needed files
|
||||
in http://www.axel.pike.org/mozilla/xalan.tar.gz. Please see the included
|
||||
LICENSE.txt or http://xml.apache.org/dist/LICENSE.txt for terms of
|
||||
distributing those files.
|
||||
|
||||
To use the buster, open buster.xul with a XSLT enabled Mozilla.
|
||||
Open the rdf index file shipped with the test package into the
|
||||
"Xalan index", and the available tests will show up as a tree.
|
||||
Once you have selected the tests you're interested in, press the button
|
||||
"run checked tests", and all the tests will be run.
|
||||
You can save the results into an rdf, and load it for comparison and
|
||||
regression hunting.
|
||||
|
||||
DiffDOM tries to find out, which tests failed, and will DumpDOM both the
|
||||
result and the reference solution. Not all reference solutions load
|
||||
properly, those need manual love.
|
||||
|
||||
Good luck and fun
|
||||
|
||||
Axel Hecht <axel@pike.org>
|
||||
@@ -1,115 +0,0 @@
|
||||
/* -*- 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
|
||||
* Axel Hecht.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
* 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 ***** */
|
||||
|
||||
const kFileOutStreamCID = "@mozilla.org/network/file-output-stream;1";
|
||||
const nsIFileOutputStream = Components.interfaces.nsIFileOutputStream;
|
||||
|
||||
var cmdFileController =
|
||||
{
|
||||
supportsCommand: function(aCommand)
|
||||
{
|
||||
switch(aCommand) {
|
||||
case 'cmd_fl_save':
|
||||
case 'cmd_fl_import':
|
||||
return true;
|
||||
default:
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isCommandEnabled: function(aCommand)
|
||||
{
|
||||
return this.supportsCommand(aCommand);
|
||||
},
|
||||
doCommand: function(aCommand)
|
||||
{
|
||||
switch(aCommand) {
|
||||
case 'cmd_fl_save':
|
||||
var sink = new Object;
|
||||
sink.write = function(aContent, aCount)
|
||||
{
|
||||
// replace NC:succ with NC:orig_succ,
|
||||
// so the rdf stuff differs
|
||||
var content = aContent.replace(/NC:succ/g,"NC:orig_succ");
|
||||
content = content.replace(/NC:failCount/g,"NC:orig_failCount");
|
||||
this.mSink.write(content, content.length);
|
||||
return aCount;
|
||||
};
|
||||
var fp = doCreateRDFFP('Xalan results',
|
||||
nsIFilePicker.modeSave);
|
||||
var res = fp.show();
|
||||
|
||||
if (res == nsIFilePicker.returnOK ||
|
||||
res == nsIFilePicker.returnReplace) {
|
||||
var serial = doCreate(kRDFXMLSerializerID,
|
||||
nsIRDFXMLSerializer);
|
||||
serial.init(view.mResultDS);
|
||||
serial.QueryInterface(nsIRDFXMLSource);
|
||||
var fl = fp.file;
|
||||
var fstream = doCreate(kFileOutStreamCID,
|
||||
nsIFileOutputStream);
|
||||
fstream.init(fl, 26, 420, 0);
|
||||
sink.mSink = fstream;
|
||||
serial.Serialize(sink);
|
||||
}
|
||||
break;
|
||||
case 'cmd_fl_import':
|
||||
var fp = doCreateRDFFP('Previous Xalan results',
|
||||
nsIFilePicker.modeLoad);
|
||||
var res = fp.show();
|
||||
|
||||
if (res == nsIFilePicker.returnOK) {
|
||||
var fl = fp.file;
|
||||
if (view.mPreviousResultDS) {
|
||||
view.database.RemoveDataSource(view.mPreviousResultDS);
|
||||
view.mPreviousResultDS = null;
|
||||
}
|
||||
view.mPreviousResultDS = kRDFSvc.GetDataSource(fp.fileURL.spec);
|
||||
view.database.AddDataSource(view.mPreviousResultDS);
|
||||
}
|
||||
|
||||
document.getElementById('obs_orig_success')
|
||||
.setAttribute('hidden','false');
|
||||
break;
|
||||
default:
|
||||
alert('Unknown Command'+aCommand);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
registerController(cmdFileController);
|
||||
@@ -1,71 +0,0 @@
|
||||
/* -*- 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
|
||||
* Axel Hecht.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
* 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 ***** */
|
||||
|
||||
var xalan_field;
|
||||
|
||||
function onLoad()
|
||||
{
|
||||
view.tree = document.getElementById('out');
|
||||
view.boxObject = view.tree.boxObject.QueryInterface(Components.interfaces.nsITreeBoxObject);
|
||||
{
|
||||
view.mIframe = document.getElementById('hiddenHtml');
|
||||
view.mIframe.webNavigation.allowPlugins = false;
|
||||
view.mIframe.webNavigation.allowJavascript = false;
|
||||
view.mIframe.webNavigation.allowMetaRedirects = false;
|
||||
view.mIframe.webNavigation.allowImages = false;
|
||||
}
|
||||
view.database = view.tree.database;
|
||||
view.builder = view.tree.builder.QueryInterface(nsIXULTemplateBuilder);
|
||||
view.builder.QueryInterface(nsIXULTreeBuilder);
|
||||
runItem.prototype.kDatabase = view.database;
|
||||
xalan_field = document.getElementById("xalan_rdf");
|
||||
var persistedUrl = xalan_field.getAttribute('url');
|
||||
if (persistedUrl) {
|
||||
view.xalan_url = persistedUrl;
|
||||
xalan_field.value = persistedUrl;
|
||||
}
|
||||
view.setDataSource();
|
||||
return true;
|
||||
}
|
||||
|
||||
function onUnload()
|
||||
{
|
||||
if (xalan_field)
|
||||
xalan_field.setAttribute('url', xalan_field.value);
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
/* -*- 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
|
||||
* Axel Hecht.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
* 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 ***** */
|
||||
|
||||
// helper function to shortcut component creation
|
||||
function doCreate(aContract, aInterface)
|
||||
{
|
||||
return Components.classes[aContract].createInstance(aInterface);
|
||||
}
|
||||
|
||||
// for the items, loading a text file
|
||||
const IOSERVICE_CTRID = "@mozilla.org/network/io-service;1";
|
||||
const nsIIOService = Components.interfaces.nsIIOService;
|
||||
const SIS_CTRID = "@mozilla.org/scriptableinputstream;1"
|
||||
const nsISIS = Components.interfaces.nsIScriptableInputStream;
|
||||
|
||||
// rdf foo, onload handler
|
||||
const kRDFSvcContractID = "@mozilla.org/rdf/rdf-service;1";
|
||||
const kRDFInMemContractID =
|
||||
"@mozilla.org/rdf/datasource;1?name=in-memory-datasource";
|
||||
const kRDFContUtilsID = "@mozilla.org/rdf/container-utils;1";
|
||||
const kRDFXMLSerializerID = "@mozilla.org/rdf/xml-serializer;1";
|
||||
const kIOSvcContractID = "@mozilla.org/network/io-service;1";
|
||||
const kStandardURL = Components.classes["@mozilla.org/network/standard-url;1"];
|
||||
const nsIURL = Components.interfaces.nsIURL;
|
||||
const nsIStandardURL = Components.interfaces.nsIStandardURL;
|
||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
const nsIXULTreeBuilder = Components.interfaces.nsIXULTreeBuilder;
|
||||
const nsIXULTemplateBuilder = Components.interfaces.nsIXULTemplateBuilder;
|
||||
const kIOSvc = Components.classes[kIOSvcContractID]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
const nsIRDFService = Components.interfaces.nsIRDFService;
|
||||
const nsIRDFDataSource = Components.interfaces.nsIRDFDataSource;
|
||||
const nsIRDFRemoteDataSource = Components.interfaces.nsIRDFRemoteDataSource;
|
||||
const nsIRDFPurgeableDataSource =
|
||||
Components.interfaces.nsIRDFPurgeableDataSource;
|
||||
const nsIRDFResource = Components.interfaces.nsIRDFResource;
|
||||
const nsIRDFLiteral = Components.interfaces.nsIRDFLiteral;
|
||||
const nsIRDFInt = Components.interfaces.nsIRDFInt;
|
||||
const nsIRDFContainerUtils = Components.interfaces.nsIRDFContainerUtils;
|
||||
const nsIRDFXMLSerializer = Components.interfaces.nsIRDFXMLSerializer;
|
||||
const nsIRDFXMLSource = Components.interfaces.nsIRDFXMLSource;
|
||||
const kRDFSvc =
|
||||
Components.classes[kRDFSvcContractID].getService(nsIRDFService);
|
||||
const krTypeCat = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#category");
|
||||
const krTypeFailCount = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#failCount");
|
||||
const krTypeName = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#name");
|
||||
const krTypeSucc = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#succ");
|
||||
const krTypeOrigSucc = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#orig_succ");
|
||||
const krTypeOrigFailCount = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#orig_failCount");
|
||||
const krTypeOrigSuccCount = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#orig_succCount");
|
||||
const krTypePath = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#path");
|
||||
const krTypeParent = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#parent");
|
||||
const krTypePurp = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#purp");
|
||||
const krTypeSuccCount = kRDFSvc.GetResource("http://home.netscape.com/NC-rdf#succCount");
|
||||
const kGood = kRDFSvc.GetLiteral("yes");
|
||||
const kBad = kRDFSvc.GetLiteral("no");
|
||||
const kMixed = kRDFSvc.GetLiteral("+-");
|
||||
const kContUtils = doCreate(kRDFContUtilsID, nsIRDFContainerUtils);
|
||||
|
||||
function doCreateRDFFP(aTitle, aMode)
|
||||
{
|
||||
var fp = doCreate("@mozilla.org/filepicker;1", nsIFilePicker);
|
||||
fp.init(window, aTitle, aMode);
|
||||
fp.appendFilter('*.rdf', '*.rdf');
|
||||
fp.appendFilters(nsIFilePicker.filterAll);
|
||||
return fp;
|
||||
}
|
||||
|
||||
function goDoCommand(aCommand)
|
||||
{
|
||||
try {
|
||||
var controller =
|
||||
top.document.commandDispatcher.getControllerForCommand(aCommand);
|
||||
if (controller && controller.isCommandEnabled(aCommand))
|
||||
controller.doCommand(aCommand);
|
||||
}
|
||||
catch(e) {
|
||||
dump("An error "+e+" occurred executing the "+aCommand+" command\n");
|
||||
}
|
||||
}
|
||||
|
||||
function registerController(aController)
|
||||
{
|
||||
top.controllers.appendController(aController);
|
||||
}
|
||||
@@ -1,390 +0,0 @@
|
||||
/* -*- 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
|
||||
* Axel Hecht.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
* 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 ***** */
|
||||
|
||||
var parser = new DOMParser();
|
||||
var methodExpr = (new XPathEvaluator).createExpression("xsl:output/@method",
|
||||
{
|
||||
lookupNamespaceURI: function(aPrefix)
|
||||
{
|
||||
if (aPrefix == "xsl")
|
||||
return "http://www.w3.org/1999/XSL/Transform";
|
||||
return "";
|
||||
}
|
||||
});
|
||||
|
||||
const nsIWebProgListener = Components.interfaces.nsIWebProgressListener;
|
||||
|
||||
var runQueue =
|
||||
{
|
||||
mArray : new Array(),
|
||||
push : function(aRunItem)
|
||||
{
|
||||
this.mArray.push(aRunItem);
|
||||
},
|
||||
observe : function(aSubject, aTopic, aData)
|
||||
{
|
||||
var item = this.mArray.shift();
|
||||
if (item) {
|
||||
item.run(this);
|
||||
}
|
||||
},
|
||||
run : function()
|
||||
{
|
||||
this.observe(null,'','');
|
||||
}
|
||||
}
|
||||
|
||||
var itemCache =
|
||||
{
|
||||
mArray : new Array(),
|
||||
getItem : function(aResource)
|
||||
{
|
||||
// Directory selected
|
||||
if (kContUtils.IsSeq(runItem.prototype.kDatabase, aResource)) {
|
||||
var aSeq = kContUtils.MakeSeq(runItem.prototype.kDatabase, aResource);
|
||||
dump("sequence: "+aSeq+" with "+aSeq.GetCount()+" elements\n");
|
||||
var child, children = aSeq.GetElements();
|
||||
var m = 0, first;
|
||||
while (children.hasMoreElements()) {
|
||||
m += 1;
|
||||
child = children.getNext();
|
||||
child.QueryInterface(nsIRDFResource);
|
||||
if (!first)
|
||||
first = itemCache.getItem(child);
|
||||
else
|
||||
itemCache.getItem(child);
|
||||
}
|
||||
return first;
|
||||
}
|
||||
if (aResource.Value in this.mArray) {
|
||||
return this.mArray[aResource.Value];
|
||||
}
|
||||
var retItem = new runItem(aResource);
|
||||
this.mArray[aResource.Value] = retItem;
|
||||
runQueue.push(retItem);
|
||||
return retItem;
|
||||
},
|
||||
rerunItem : function(aResource, aObserver)
|
||||
{
|
||||
var anItem = new runItem(aResource);
|
||||
this.mArray[aResource.Value] = anItem;
|
||||
anItem.run(aObserver);
|
||||
},
|
||||
observe : function(aSubject, aTopic, aData)
|
||||
{
|
||||
this.mRun += 1;
|
||||
if (aTopic == "success") {
|
||||
if (aData == "yes") {
|
||||
this.mGood += 1;
|
||||
}
|
||||
else {
|
||||
this.mFalse +=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function runItem(aResource)
|
||||
{
|
||||
this.mResource = aResource;
|
||||
// Directory selected
|
||||
if (kContUtils.IsSeq(this.kDatabase,this.mResource)) {
|
||||
var aSeq = kContUtils.MakeSeq(this.kDatabase,this.mResource);
|
||||
dump("THIS SHOULDN'T HAPPEN\n");
|
||||
var child, children = aSeq.GetElements();
|
||||
var m = 0;
|
||||
while (children.hasMoreElements()) {
|
||||
m += 1;
|
||||
child = children.getNext();
|
||||
child.QueryInterface(nsIRDFResource);
|
||||
itemCache.getItem(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
runItem.prototype =
|
||||
{
|
||||
// RDF resource associated with this test
|
||||
mResource : null,
|
||||
// XML documents for the XSLT transformation
|
||||
mSourceDoc : null,
|
||||
mStyleDoc : null,
|
||||
mResDoc : null,
|
||||
// XML or plaintext document for the reference
|
||||
mRefDoc : null,
|
||||
// bitfield signaling the loaded documents
|
||||
mLoaded : 0,
|
||||
kSource : 1,
|
||||
kStyle : 2,
|
||||
kReference : 4,
|
||||
// a observer, potential argument to run()
|
||||
mObserver : null,
|
||||
mSuccess : null,
|
||||
mMethod : 'xml',
|
||||
// XSLTProcessor, shared by the instances
|
||||
kProcessor : new XSLTProcessor(),
|
||||
kXalan : kStandardURL.createInstance(nsIURL),
|
||||
kDatabase : null,
|
||||
kObservers : new Array(),
|
||||
|
||||
run : function(aObserver)
|
||||
{
|
||||
if (aObserver && typeof(aObserver)=='function' ||
|
||||
(typeof(aObserver)=='object' &&
|
||||
typeof(aObserver.observe)=='function')) {
|
||||
this.mObserver=aObserver;
|
||||
}
|
||||
var name = this.kDatabase.GetTarget(this.mResource, krTypeName, true);
|
||||
if (name) {
|
||||
var cat = this.kDatabase.GetTarget(this.mResource, krTypeCat, true);
|
||||
var path = this.kDatabase.GetTarget(this.mResource, krTypePath, true);
|
||||
cat = cat.QueryInterface(nsIRDFLiteral);
|
||||
name = name.QueryInterface(nsIRDFLiteral);
|
||||
path = path.QueryInterface(nsIRDFLiteral);
|
||||
var xalan_fl = this.kXalan.resolve(cat.Value+"/"+path.Value);
|
||||
var xalan_ref = this.kXalan.resolve(cat.Value+"-gold/"+path.Value);
|
||||
this.mRefURL =
|
||||
this.kXalan.resolve(cat.Value + "-gold/" + path.Value + ".out");
|
||||
dump(name.Value+" links to "+xalan_fl+"\n");
|
||||
}
|
||||
// Directory selected
|
||||
if (kContUtils.IsSeq(this.kDatabase,this.mResource)) {
|
||||
return;
|
||||
var aSeq = kContUtils.MakeSeq(this.kDatabase,this.mResource);
|
||||
dump("sequence: "+aSeq+" with "+aSeq.GetCount()+" elements\n");
|
||||
var child, children = aSeq.GetElements();
|
||||
var m = 0;
|
||||
while (children.hasMoreElements()) {
|
||||
m += 1;
|
||||
child = children.getNext();
|
||||
child.QueryInterface(nsIRDFResource);
|
||||
}
|
||||
}
|
||||
this.mSourceDoc = document.implementation.createDocument('', '', null);
|
||||
this.mSourceDoc.addEventListener("load",this.onload(1),false);
|
||||
this.mSourceDoc.load(xalan_fl+".xml");
|
||||
this.mStyleDoc = document.implementation.createDocument('', '', null);
|
||||
this.mStyleDoc.addEventListener("load",this.styleLoaded(),false);
|
||||
this.mStyleDoc.load(xalan_fl+".xsl");
|
||||
},
|
||||
|
||||
// nsIWebProgressListener
|
||||
QueryInterface: function(aIID)
|
||||
{
|
||||
return this;
|
||||
},
|
||||
onStateChange: function(aProg, aRequest, aFlags, aStatus)
|
||||
{
|
||||
if ((aFlags & nsIWebProgListener.STATE_STOP) &&
|
||||
(aFlags & nsIWebProgListener.STATE_IS_DOCUMENT)) {
|
||||
aProg.removeProgressListener(this);
|
||||
this.mRefDoc = document.getElementById('hiddenHtml').contentDocument;
|
||||
this.fileLoaded(4);
|
||||
}
|
||||
},
|
||||
onProgressChange: function(aProg, b,c,d,e,f)
|
||||
{
|
||||
},
|
||||
onLocationChange: function(aProg, aRequest, aURI)
|
||||
{
|
||||
},
|
||||
onStatusChange: function(aProg, aRequest, aStatus, aMessage)
|
||||
{
|
||||
},
|
||||
onSecurityChange: function(aWebProgress, aRequest, aState)
|
||||
{
|
||||
},
|
||||
|
||||
// onload handler helper
|
||||
onload : function(file)
|
||||
{
|
||||
var self = this;
|
||||
return function(e)
|
||||
{
|
||||
return self.fileLoaded(file);
|
||||
};
|
||||
},
|
||||
|
||||
styleLoaded : function()
|
||||
{
|
||||
var self = this;
|
||||
return function(e)
|
||||
{
|
||||
return self.styleLoadedHelper();
|
||||
};
|
||||
},
|
||||
styleLoadedHelper : function()
|
||||
{
|
||||
var method = methodExpr.evaluate(this.mStyleDoc.documentElement, 2,
|
||||
null).stringValue;
|
||||
var refContent;
|
||||
if (!method) {
|
||||
// implicit method, guess from result
|
||||
refContent = this.loadTextFile(this.mRefURL);
|
||||
if (refContent.match(/^\s*<html/gi)) {
|
||||
method = 'html';
|
||||
}
|
||||
else {
|
||||
method = 'xml';
|
||||
}
|
||||
}
|
||||
this.mMethod = method;
|
||||
|
||||
switch (method) {
|
||||
case 'xml':
|
||||
if (!refContent) {
|
||||
refContent = this.loadTextFile(this.mRefURL);
|
||||
}
|
||||
this.mRefDoc = parser.parseFromString(refContent, 'text/xml');
|
||||
this.mLoaded += 4;
|
||||
break;
|
||||
case 'html':
|
||||
view.loadHtml(this.mRefURL, this);
|
||||
break;
|
||||
case 'text':
|
||||
if (!refContent) {
|
||||
refContent = this.loadTextFile(this.mRefURL);
|
||||
}
|
||||
const ns = 'http://www.mozilla.org/TransforMiix';
|
||||
const qn = 'transformiix:result';
|
||||
this.mRefDoc =
|
||||
document.implementation.createDocument(ns, qn, null);
|
||||
var txt = this.mRefDoc.createTextNode(refContent);
|
||||
this.mRefDoc.documentElement.appendChild(txt);
|
||||
this.mLoaded += 4;
|
||||
break;
|
||||
default:
|
||||
throw "unkown XSLT output method";
|
||||
}
|
||||
this.fileLoaded(2)
|
||||
},
|
||||
|
||||
fileLoaded : function(mask)
|
||||
{
|
||||
this.mLoaded += mask;
|
||||
if (this.mLoaded < 7) {
|
||||
return;
|
||||
}
|
||||
this.doTransform();
|
||||
},
|
||||
|
||||
doTransform : function()
|
||||
{
|
||||
this.kProcessor.reset();
|
||||
try {
|
||||
this.kProcessor.importStylesheet(this.mStyleDoc);
|
||||
this.mResDoc =
|
||||
this.kProcessor.transformToDocument(this.mSourceDoc);
|
||||
this.mRefDoc.normalize();
|
||||
isGood = DiffDOM(this.mResDoc.documentElement,
|
||||
this.mRefDoc.documentElement,
|
||||
this.mMethod == 'html');
|
||||
} catch (e) {
|
||||
isGood = false;
|
||||
};
|
||||
dump("This succeeded. "+isGood+"\n");
|
||||
isGood = isGood.toString();
|
||||
for (var i=0; i<this.kObservers.length; i++) {
|
||||
var aObs = this.kObservers[i];
|
||||
if (typeof(aObs)=='object' && typeof(aObs.observe)=='function') {
|
||||
aObs.observe(this.mResource, 'success', isGood);
|
||||
}
|
||||
else if (typeof(aObs)=='function') {
|
||||
aObs(this.mResource, 'success', isGood);
|
||||
}
|
||||
}
|
||||
if (this.mObserver) {
|
||||
if (typeof(this.mObserver)=='object') {
|
||||
this.mObserver.observe(this.mResource, 'success', isGood);
|
||||
}
|
||||
else {
|
||||
this.mObserver(this.mResource, 'success', isGood);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
loadTextFile : function(url)
|
||||
{
|
||||
var serv = Components.classes[IOSERVICE_CTRID].
|
||||
getService(nsIIOService);
|
||||
if (!serv) {
|
||||
throw Components.results.ERR_FAILURE;
|
||||
}
|
||||
var chan = serv.newChannel(url, null, null);
|
||||
var instream = doCreate(SIS_CTRID, nsISIS);
|
||||
instream.init(chan.open());
|
||||
|
||||
return instream.read(instream.available());
|
||||
}
|
||||
}
|
||||
|
||||
runItem.prototype.kXalan.QueryInterface(nsIStandardURL);
|
||||
|
||||
var cmdTestController =
|
||||
{
|
||||
supportsCommand: function(aCommand)
|
||||
{
|
||||
switch(aCommand) {
|
||||
case 'cmd_tst_run':
|
||||
case 'cmd_tst_runall':
|
||||
return true;
|
||||
default:
|
||||
}
|
||||
return false;
|
||||
},
|
||||
isCommandEnabled: function(aCommand)
|
||||
{
|
||||
return this.supportsCommand(aCommand);
|
||||
},
|
||||
doCommand: function(aCommand)
|
||||
{
|
||||
switch(aCommand) {
|
||||
case 'cmd_tst_run':
|
||||
dump("cmd_tst_run\n");
|
||||
break;
|
||||
case 'cmd_tst_runall':
|
||||
dump("cmd_tst_runall\n");
|
||||
var tst_run = document.getElementById('cmd_tst_run');
|
||||
tst_run.doCommand();
|
||||
default:
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
registerController(cmdTestController);
|
||||
@@ -1,227 +0,0 @@
|
||||
/* -*- 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
|
||||
* Axel Hecht.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
* 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 ***** */
|
||||
|
||||
var view =
|
||||
{
|
||||
onRun : function()
|
||||
{
|
||||
runQueue.mArray = new Array();
|
||||
var sels = this.boxObject.selection,a=new Object(),b=new Object(),k;
|
||||
var rowResource, name, path;
|
||||
for (k=0;k<sels.getRangeCount();k++){
|
||||
sels.getRangeAt(k,a,b);
|
||||
for (var l=a.value;l<=b.value;l++) {
|
||||
rowResource = this.builder.getResourceAtIndex(l);
|
||||
itemCache.getItem(rowResource);
|
||||
}
|
||||
}
|
||||
runQueue.run();
|
||||
},
|
||||
displayTest : function()
|
||||
{
|
||||
var current = this.boxObject.selection.currentIndex;
|
||||
var rowResource = this.builder.getResourceAtIndex(current);
|
||||
var item = itemCache.getItem(rowResource);
|
||||
},
|
||||
browseForRDF : function()
|
||||
{
|
||||
var fp = doCreateRDFFP('Xalan Description File',
|
||||
nsIFilePicker.modeOpen);
|
||||
var res = fp.show();
|
||||
|
||||
if (res == nsIFilePicker.returnOK) {
|
||||
var furl = fp.fileURL;
|
||||
this.setDataSource(fp.fileURL.spec);
|
||||
}
|
||||
},
|
||||
dump_Good : function()
|
||||
{
|
||||
var enumi = this.mResultDS.GetSources(krTypeSucc, kGood, true);
|
||||
var k = 0;
|
||||
while (enumi.hasMoreElements()) {
|
||||
k += 1;
|
||||
dump(enumi.getNext().QueryInterface(nsIRDFResource).Value+"\n");
|
||||
}
|
||||
dump("found "+k+" good tests\n");
|
||||
},
|
||||
prune_ds : function()
|
||||
{
|
||||
if (this.mResultDS) {
|
||||
this.mResultDS.QueryInterface(nsIRDFPurgeableDataSource).Sweep();
|
||||
}
|
||||
regressionStats.init()
|
||||
itemCache.mArray = new Array();
|
||||
},
|
||||
setDataSource : function(aSpec)
|
||||
{
|
||||
var baseSpec;
|
||||
if (aSpec) {
|
||||
baseSpec = aSpec;
|
||||
}
|
||||
else {
|
||||
baseSpec = document.getElementById("xalan_rdf").value;
|
||||
}
|
||||
if (this.mXalanDS && this.mXalanDS.URI == baseSpec) {
|
||||
this.mXalanDS.QueryInterface(nsIRDFRemoteDataSource);
|
||||
this.mXalanDS.Refresh(true);
|
||||
}
|
||||
else {
|
||||
if (this.mXalanDS) {
|
||||
this.database.RemoveDataSource(view.mXalanDS);
|
||||
}
|
||||
this.mXalanDS = kRDFSvc.GetDataSourceBlocking(baseSpec);
|
||||
if (!this.mXalanDS) {
|
||||
alert("Unable do load DataSource: "+baseSpec);
|
||||
return;
|
||||
}
|
||||
this.database.AddDataSource(this.mXalanDS);
|
||||
}
|
||||
regressionStats.init();
|
||||
if (!this.mResultDS) {
|
||||
this.mResultDS = doCreate(kRDFInMemContractID,
|
||||
nsIRDFDataSource);
|
||||
this.database.AddDataSource(view.mResultDS);
|
||||
if (!this.mResultDS) {
|
||||
alert("Unable to create result InMemDatasource");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.builder.rebuild();
|
||||
document.getElementById("xalan_rdf").value = baseSpec;
|
||||
runItem.prototype.kXalan.init(runItem.prototype.kXalan.URLTYPE_STANDARD,
|
||||
0, baseSpec, null, null);
|
||||
},
|
||||
loadHtml : function(aUrl, aListener)
|
||||
{
|
||||
const nsIIRequestor = Components.interfaces.nsIInterfaceRequestor;
|
||||
const nsIWebProgress = Components.interfaces.nsIWebProgress;
|
||||
var req = this.mIframe.webNavigation.QueryInterface(nsIIRequestor);
|
||||
var prog = req.getInterface(nsIWebProgress);
|
||||
prog.addProgressListener(aListener, nsIWebProgress.NOTIFY_ALL);
|
||||
this.mIframe.webNavigation.loadURI(aUrl, 0,null,null,null);
|
||||
},
|
||||
fillItemContext : function()
|
||||
{
|
||||
var index = view.boxObject.selection.currentIndex;
|
||||
var res = view.builder.getResourceAtIndex(index);
|
||||
var purp = view.mXalanDS.GetTarget(res, krTypePurp, true);
|
||||
return (purp != null);
|
||||
}
|
||||
}
|
||||
|
||||
regressionStats =
|
||||
{
|
||||
observe: function(aSubject, aTopic, aData)
|
||||
{
|
||||
if (aTopic != 'success') {
|
||||
return;
|
||||
}
|
||||
var arc = (aData == "true") ? krTypeSuccCount : krTypeFailCount;
|
||||
this.assertNewCount(aSubject, arc, 1);
|
||||
},
|
||||
init: function()
|
||||
{
|
||||
if (this.mRegressionDS) {
|
||||
this.mRegressionDS.QueryInterface(nsIRDFPurgeableDataSource).Sweep();
|
||||
}
|
||||
else {
|
||||
this.mRegressionDS =
|
||||
doCreate(kRDFInMemContractID, nsIRDFDataSource);
|
||||
view.database.AddDataSource(this.mRegressionDS);
|
||||
}
|
||||
},
|
||||
getParent: function(aDS, aSource)
|
||||
{
|
||||
// parent chached?
|
||||
var parent = this.mRegressionDS.GetTarget(aSource, krTypeParent, true);
|
||||
if (!parent) {
|
||||
var labels = view.mXalanDS.ArcLabelsIn(aSource);
|
||||
while (labels.hasMoreElements()) {
|
||||
var arc = labels.getNext().QueryInterface(nsIRDFResource);
|
||||
if (arc.Value.match(this.mChildRE)) {
|
||||
parent = view.mXalanDS.GetSource(arc, aSource, true);
|
||||
// cache the parent
|
||||
this.mRegressionDS.Assert(aSource, krTypeParent,
|
||||
parent, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return parent;
|
||||
},
|
||||
assertNewCount: function(aSource, aArc, aIncrement)
|
||||
{
|
||||
var root = kRDFSvc.GetResource('urn:root');
|
||||
var count = 0;
|
||||
// parent chached?
|
||||
var parent = this.getParent(view.XalanDS, aSource);
|
||||
while (parent && !parent.EqualsNode(root)) {
|
||||
var countRes = view.mResultDS.GetTarget(parent, aArc, true);
|
||||
if (countRes) {
|
||||
count = countRes.QueryInterface(nsIRDFInt).Value;
|
||||
}
|
||||
var newCountRes = kRDFSvc.GetIntLiteral(count + aIncrement);
|
||||
if (!newCountRes) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (countRes) {
|
||||
view.mResultDS.Change(parent, aArc, countRes, newCountRes);
|
||||
}
|
||||
else {
|
||||
view.mResultDS.Assert(parent, aArc, newCountRes, true);
|
||||
}
|
||||
parent = this.getParent(view.XalanDS, parent);
|
||||
}
|
||||
},
|
||||
mRegressionDS: 0,
|
||||
mChildRE: /http:\/\/www\.w3\.org\/1999\/02\/22-rdf-syntax-ns#_/
|
||||
}
|
||||
|
||||
function rdfObserve(aSubject, aTopic, aData)
|
||||
{
|
||||
if (aTopic == "success") {
|
||||
var target = (aData == "true") ? kGood : kBad;
|
||||
view.mResultDS.Assert(aSubject, krTypeSucc, target, true);
|
||||
|
||||
regressionStats.observe(aSubject, aTopic, aData);
|
||||
}
|
||||
}
|
||||
|
||||
runItem.prototype.kObservers.push(rdfObserve);
|
||||
@@ -1,38 +0,0 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 Axel Hecht.
|
||||
* Portions created by Axel Hecht are Copyright (C) 2002 Axel Hecht.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org> (Original Author)
|
||||
*/
|
||||
|
||||
|
||||
label.head {
|
||||
padding: 5px;
|
||||
font-size: medium;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
treechildren:-moz-tree-cell(success yes)
|
||||
{
|
||||
background-color: green ;
|
||||
}
|
||||
|
||||
treechildren:-moz-tree-cell(success no)
|
||||
{
|
||||
background-color: red ;
|
||||
}
|
||||
@@ -1,227 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- ***** 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.
|
||||
-
|
||||
- The Initial Developer of the Original Code is Axel Hecht
|
||||
- Portions created by the Initial Developer are Copyright (C) 2002
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Axel Hecht <axel@pike.org> (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 LGPL or the GPL. 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 ***** -->
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="buster.css" type="text/css"?>
|
||||
|
||||
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://communicator/content/utilityOverlay.xul"?>
|
||||
|
||||
<window id="XalanBuster"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="onLoad()" onunload="onUnload()"
|
||||
title="Xalan testcase harness"
|
||||
persist="width,height"
|
||||
orient="vertical">
|
||||
<script type="application/x-javascript" src="buster-statics.js" />
|
||||
<script type="application/x-javascript" src="buster-test.js" />
|
||||
<script type="application/x-javascript" src="buster-view.js" />
|
||||
<script type="application/x-javascript" src="buster-handlers.js" />
|
||||
<script type="application/x-javascript" src="result-view.js" />
|
||||
<script type="application/x-javascript" src="buster-files.js" />
|
||||
<script type="application/x-javascript" src="DumpDOM.js" />
|
||||
<script type="application/x-javascript" src="DiffDOM.js" />
|
||||
|
||||
<commands id="busterKing">
|
||||
<commandset id="buster_file_cmds">
|
||||
<command id="cmd_fl_save" oncommand="goDoCommand('cmd_fl_save')" />
|
||||
<command id="cmd_fl_import" oncommand="goDoCommand('cmd_fl_import')"/>
|
||||
</commandset>
|
||||
<commandset id="buster_test_cmds">
|
||||
<command id="cmd_tst_run" oncommand="goDoCommand('cmd_tst_run')" />
|
||||
<command id="cmd_tst_runall" oncommand="goDoCommand('cmd_tst_runall')" />
|
||||
</commandset>
|
||||
<commandset id="commands">
|
||||
<command id="cmd_quit"/>
|
||||
<command id="cmd_close" oncommand="window.close();"/>
|
||||
</commandset>
|
||||
</commands>
|
||||
|
||||
<keyset>
|
||||
<key id="key_quit"/>
|
||||
<key id="key_close"/>
|
||||
</keyset>
|
||||
|
||||
<broadcasterset>
|
||||
<broadcaster id="obs_orig_success" hidden="true"/>
|
||||
<broadcaster id="not_yet" disabled="true"/>
|
||||
</broadcasterset>
|
||||
|
||||
|
||||
<menubar>
|
||||
<menu id="menu_File" label="File" accesskey="f">
|
||||
<menupopup id="menu_FilePopup">
|
||||
<menuitem label="Save results ..." accesskey="s"
|
||||
observes="cmd_fl_save"/>
|
||||
<menuitem label="Import results ..." accesskey="i"
|
||||
observes="cmd_fl_import"/>
|
||||
<menuitem id="menu_close"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu id="busterTests" label="Tests" accesskey="t">
|
||||
<menupopup id="tests-popup">
|
||||
<menuitem label="run a test" accesskey="r"
|
||||
observes="cmd_tst_run"/>
|
||||
<menuitem label="run all tests" accesskey="a"
|
||||
observes="cmd_tst_runall"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menubar>
|
||||
|
||||
<popupset>
|
||||
<popup id="itemcontext" onpopupshowing="return view.fillItemContext();">
|
||||
<menuitem label="View Test" oncommand="onNewResultView(event)"/>
|
||||
</popup>
|
||||
</popupset>
|
||||
|
||||
<hbox>
|
||||
<button label="check all" oncommand="check(true)" observes="not_yet"/>
|
||||
<button label="uncheck all" oncommand="check(false)" observes="not_yet"/>
|
||||
<button label="reset success" oncommand="view.prune_ds()" />
|
||||
<button label="run checked tests" oncommand="view.onRun()" />
|
||||
</hbox>
|
||||
<hbox>
|
||||
<label value="Xalan index: " class="head"/>
|
||||
<textbox id="xalan_rdf" persist="url" crop="end" size="40"/>
|
||||
<button label="browse..." oncommand="view.browseForRDF()" />
|
||||
</hbox>
|
||||
<hbox>
|
||||
<groupbox orient="horizontal"><caption label="search" />
|
||||
<button label="Search for " oncommand="select()" observes="not_yet"/>
|
||||
<textbox style="width: 10em;" id="search-name" persist="value" /><label value=" in " />
|
||||
<menulist id="search-field" persist="data" observes="not_yet">
|
||||
<menupopup>
|
||||
<menuitem value="1" label="Name" />
|
||||
<menuitem value="2" label="Purpose" />
|
||||
<menuitem value="3" label="Comment" />
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</groupbox>
|
||||
<spacer flex="1" /></hbox>
|
||||
|
||||
<tree id="out" flex="1" flags="dont-build-content" hidecolumnpicker="true"
|
||||
datasources="rdf:null" ref="urn:root" context="itemcontext">
|
||||
<treecols>
|
||||
<treecol id="NameColumn" flex="1" label="Name" sort="?name"
|
||||
primary="true" />
|
||||
<splitter class="tree-splitter" />
|
||||
<treecol id="PurpsColumn" flex="2" label="Purpose" sort="?purp" />
|
||||
<splitter class="tree-splitter" />
|
||||
<treecol id="SuccessColumn" flex="0" label="Success" />
|
||||
<splitter class="tree-splitter" observes="obs_orig_success" />
|
||||
<treecol id="OrigSuccessColumn" flex="0" label="Previously"
|
||||
observes="obs_orig_success" />
|
||||
</treecols>
|
||||
<template>
|
||||
<rule>
|
||||
<conditions>
|
||||
<treeitem uri="?uri" />
|
||||
<member container="?uri" child="?subheading" />
|
||||
<triple subject="?subheading"
|
||||
predicate="http://home.netscape.com/NC-rdf#purp"
|
||||
object="?purp" />
|
||||
</conditions>
|
||||
|
||||
<bindings>
|
||||
<binding subject="?subheading"
|
||||
predicate="http://home.netscape.com/NC-rdf#name"
|
||||
object="?name" />
|
||||
<binding subject="?subheading"
|
||||
predicate="http://home.netscape.com/NC-rdf#succ"
|
||||
object="?succ" />
|
||||
<binding subject="?subheading"
|
||||
predicate="http://home.netscape.com/NC-rdf#orig_succ"
|
||||
object="?orig_succ" />
|
||||
</bindings>
|
||||
|
||||
<action>
|
||||
<treechildren>
|
||||
<treeitem uri="?subheading">
|
||||
<treerow>
|
||||
<treecell ref="NameColumn" label="?name" />
|
||||
<treecell ref="PurpsColumn" label="?purp" />
|
||||
<treecell ref="SuccessColumn" label="?succ"
|
||||
properties="success ?succ"/>
|
||||
<treecell ref="OrigSuccessColumn" label="?orig_succ"
|
||||
properties="success ?orig_succ" />
|
||||
</treerow>
|
||||
</treeitem>
|
||||
</treechildren>
|
||||
</action>
|
||||
</rule>
|
||||
<rule>
|
||||
<conditions>
|
||||
<treeitem uri="?uri" />
|
||||
<member container="?uri" child="?subheading" />
|
||||
</conditions>
|
||||
|
||||
<bindings>
|
||||
<binding subject="?subheading"
|
||||
predicate="http://home.netscape.com/NC-rdf#dir"
|
||||
object="?dir" />
|
||||
<binding subject="?subheading"
|
||||
predicate="http://home.netscape.com/NC-rdf#succCount"
|
||||
object="?succ" />
|
||||
<binding subject="?subheading"
|
||||
predicate="http://home.netscape.com/NC-rdf#failCount"
|
||||
object="?fail" />
|
||||
<binding subject="?subheading"
|
||||
predicate="http://home.netscape.com/NC-rdf#orig_succCount"
|
||||
object="?orig_succ" />
|
||||
<binding subject="?subheading"
|
||||
predicate="http://home.netscape.com/NC-rdf#orig_failCount"
|
||||
object="?orig_fail" />
|
||||
</bindings>
|
||||
|
||||
<action>
|
||||
<treechildren>
|
||||
<treeitem uri="?subheading">
|
||||
<treerow>
|
||||
<treecell ref="NameColumn" label="?dir" />
|
||||
<treecell ref="PurpsColumn" label="" />
|
||||
<treecell ref="SuccessColumn" label="?succ / ?fail" />
|
||||
<treecell ref="OrigSuccessColumn" label="?orig_succ / ?orig_fail" />
|
||||
</treerow>
|
||||
</treeitem>
|
||||
</treechildren>
|
||||
</action>
|
||||
</rule>
|
||||
</template>
|
||||
</tree>
|
||||
<iframe style="visibility:hidden; height:0px;" id="hiddenHtml" />
|
||||
</window>
|
||||
@@ -1,95 +0,0 @@
|
||||
use File::Spec;
|
||||
|
||||
my(@chunks, @list, $entry, $main_cats, $spacing);
|
||||
@list = ('conf', 'perf');
|
||||
foreach $entry (@list) {
|
||||
$main_cats .= " <rdf:li><rdf:Description about=\"urn:x-buster:$entry\" nc:dir=\"$entry\" /></rdf:li>\n";
|
||||
go_in($entry, '', $entry);
|
||||
}
|
||||
if ($ARGV[0]) {
|
||||
open OUTPUT, ">$ARGV[0]";
|
||||
}
|
||||
else {
|
||||
open OUTPUT, ">xalan.rdf";
|
||||
};
|
||||
select(OUTPUT);
|
||||
print '<?xml version="1.0"?>
|
||||
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:nc="http://home.netscape.com/NC-rdf#">
|
||||
<rdf:Seq about="urn:root">
|
||||
' . $main_cats . ' </rdf:Seq>
|
||||
';
|
||||
print join('',@chunks);
|
||||
print '</rdf:RDF>
|
||||
';
|
||||
exit 0;
|
||||
|
||||
sub go_in {
|
||||
my($current, $about, $cat) = @_;
|
||||
my (@list, $entry, @subdirs, @files, @purps, $rdf);
|
||||
chdir $current;
|
||||
@list = <*>;
|
||||
|
||||
LOOP: foreach $entry (@list) {
|
||||
next LOOP if $entry=~/^CVS$/;
|
||||
if (! -d $entry) {
|
||||
if ($entry=~/^($current.*)\.xsl$/) {
|
||||
local $source = $entry;
|
||||
$source=~s/xsl$/xml/;
|
||||
next LOOP if ! -f $source;
|
||||
$entry=~/^($current.*)\.xsl$/;
|
||||
push(@files, $1);
|
||||
local ($purp, $purp_open);
|
||||
open STYLE, $entry;
|
||||
$purp_open = 0;
|
||||
while (<STYLE>) {
|
||||
if (/<!--\s+purpose: (.+)\s*-->/i) {
|
||||
$purp .= $1;
|
||||
}
|
||||
elsif (/<!--\s+purpose: (.+)\s*$/i) {
|
||||
$purp_open = 1;
|
||||
$purp .= $1;
|
||||
}
|
||||
elsif ($purp_open) {
|
||||
if (/\s*(\s.+)\s*-->/) {
|
||||
$purp_open = 0;
|
||||
$purp .= $1;
|
||||
}
|
||||
elsif (/\s*(\s.+)\s*$/) {
|
||||
$purp .= $1;
|
||||
}
|
||||
}
|
||||
}
|
||||
$purp=~s/"/'/g; $purp=~s/&/&/g; $purp=~s/</</g;
|
||||
$purp=~s/\r/ /g; $purp=~s/\s\s/ /g; $purp=~s/\s$//g;
|
||||
push(@purps, $purp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
push(@subdirs, $entry);
|
||||
}
|
||||
}
|
||||
|
||||
if (@subdirs > 0 || @files > 0) {
|
||||
my $topic = $about.$current; $topic=~s/\///g;
|
||||
$rdf = ' <rdf:Seq about="urn:x-buster:'.$topic."\">\n";
|
||||
foreach $entry (@subdirs) {
|
||||
if (go_in($entry, $about.$current.'/', $cat)) {
|
||||
my $id = 'urn:x-buster:'.$about.$current.$entry; $id=~s/\///g;
|
||||
$rdf .= " <rdf:li><rdf:Description about=\"$id\" nc:dir=\"$entry\" /></rdf:li>\n";
|
||||
}
|
||||
}
|
||||
for (my $i=0; $i < @files; $i++) {
|
||||
my $uri = $about.$current.'/'.$files[$i];
|
||||
$uri=~s/[^\/]+\///;
|
||||
my $id = $uri; $id=~s/\///g;
|
||||
$rdf .= " <rdf:li><rdf:Description about=\"urn:x-buster:$files[$i]\" nc:name=\"$files[$i]\" nc:purp=\"$purps[$i]\" nc:path=\"$uri\" nc:category=\"$cat\" /></rdf:li>\n";
|
||||
}
|
||||
$rdf .= " </rdf:Seq>\n";
|
||||
push(@chunks, $rdf);
|
||||
}
|
||||
|
||||
chdir File::Spec->updir;
|
||||
return (@subdirs > 0 || @files > 0);
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- ***** 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.
|
||||
-
|
||||
- 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 LGPL or the GPL. 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 ***** -->
|
||||
|
||||
<!DOCTYPE overlay [
|
||||
<!ENTITY % dtd1 SYSTEM "chrome://inspector/locale/inspector.dtd"> %dtd1;
|
||||
<!ENTITY % dtd2 SYSTEM "chrome://inspector/content/util.dtd"> %dtd2;
|
||||
]>
|
||||
|
||||
<?xul-overlay href="chrome://inspector/content/commandOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://inspector/content/keysetOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://inspector/content/popupOverlay.xul"?>
|
||||
|
||||
<?xml-stylesheet href="chrome://inspector/skin/inspectorWindow.css"?>
|
||||
|
||||
<window class="color-dialog"
|
||||
title="&Inspector.title;"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/ViewerRegistry.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/utils.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/xpcom/XPCU.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/rdf/RDFU.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/rdf/RDFArray.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/events/ObserverManager.js"/>
|
||||
<script type="application/x-javascript" src="chrome://inspector/content/jsutil/xul/FrameExchange.js"/>
|
||||
|
||||
<commandset id="cmdsGlobalCommands"/>
|
||||
<keyset id="ksGlobalKeyset"/>
|
||||
<popupset id="ppsViewerPopupset"/>
|
||||
|
||||
<domi-panelset id="bxPanelSet" flex="1" viewercommandset="cmdsGlobalCommands">
|
||||
<domi-panel title="&bxDocPanel.title;" flex="1"/>
|
||||
</domi-panelset>
|
||||
|
||||
</window>
|
||||
@@ -1,16 +0,0 @@
|
||||
label.heading {
|
||||
font-size: medium;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
button.close {
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
iframe {
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
vbox.hidden {
|
||||
display: none;
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
/* -*- 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
|
||||
* Axel Hecht.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
* 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 ***** */
|
||||
|
||||
function onNewResultView(event)
|
||||
{
|
||||
dump("onNewResultView\n");
|
||||
const db = runItem.prototype.kDatabase;
|
||||
const kXalan = runItem.prototype.kXalan;
|
||||
var index = view.boxObject.selection.currentIndex;
|
||||
var res = view.builder.getResourceAtIndex(index);
|
||||
var name = db.GetTarget(res, krTypeName, true);
|
||||
if (!name) {
|
||||
return false;
|
||||
}
|
||||
var cat = db.GetTarget(res, krTypeCat, true);
|
||||
var path = db.GetTarget(res, krTypePath, true);
|
||||
cat = cat.QueryInterface(nsIRDFLiteral);
|
||||
name = name.QueryInterface(nsIRDFLiteral);
|
||||
path = path.QueryInterface(nsIRDFLiteral);
|
||||
xalan_fl = kXalan.resolve(cat.Value+"/"+path.Value);
|
||||
xalan_ref = kXalan.resolve(cat.Value+"-gold/"+path.Value);
|
||||
var currentResultItem = new Object();
|
||||
currentResultItem.testpath = xalan_fl;
|
||||
currentResultItem.refpath = xalan_ref;
|
||||
var currentRunItem = itemCache.getItem(res);
|
||||
// XXX todo, keep a list of these windows, so that we can close them.
|
||||
resultWin = window.openDialog('result-view.xul','_blank',
|
||||
'chrome,resizable,dialog=no',
|
||||
currentResultItem, currentRunItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
var refInspector;
|
||||
var resInspector;
|
||||
|
||||
function onResultViewLoad(event)
|
||||
{
|
||||
dump("onResultViewLoad\n");
|
||||
aResultItem = window.arguments[0];
|
||||
aRunItem = window.arguments[1];
|
||||
var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
|
||||
document.getElementById('src').webNavigation.loadURI('view-source:'+
|
||||
aResultItem.testpath+'.xml', loadFlags, null, null, null);
|
||||
document.getElementById('style').webNavigation.loadURI('view-source:'+
|
||||
aResultItem.testpath+'.xsl', loadFlags, null, null, null);
|
||||
|
||||
if (aRunItem && aRunItem.mRefDoc && aRunItem.mResDoc) {
|
||||
document.getElementById("refSourceBox").setAttribute("class", "hidden");
|
||||
refInspector = new ObjectApp();
|
||||
refInspector.initialize("refInsp", aRunItem.mRefDoc);
|
||||
resInspector = new ObjectApp();
|
||||
resInspector.initialize("resInsp", aRunItem.mResDoc);
|
||||
}
|
||||
else {
|
||||
document.getElementById("inspectorBox").setAttribute("class", "hidden");
|
||||
document.getElementById('ref').webNavigation.loadURI('view-source:'+
|
||||
aResultItem.refpath+'.out', loadFlags, null, null, null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function onResultViewUnload(event)
|
||||
{
|
||||
dump("onResultUnload\n");
|
||||
}
|
||||
|
||||
function ObjectApp()
|
||||
{
|
||||
}
|
||||
|
||||
ObjectApp.prototype =
|
||||
{
|
||||
mDoc: null,
|
||||
mPanelSet: null,
|
||||
|
||||
initialize: function(aId, aDoc)
|
||||
{
|
||||
this.mDoc = aDoc;
|
||||
this.mPanelSet = document.getElementById(aId).contentDocument.getElementById("bxPanelSet");
|
||||
this.mPanelSet.addObserver("panelsetready", this, false);
|
||||
this.mPanelSet.initialize();
|
||||
},
|
||||
|
||||
doViewerCommand: function(aCommand)
|
||||
{
|
||||
this.mPanelSet.execCommand(aCommand);
|
||||
},
|
||||
|
||||
getViewer: function(aUID)
|
||||
{
|
||||
return this.mPanelSet.registry.getViewerByUID(aUID);
|
||||
},
|
||||
|
||||
onEvent: function(aEvent)
|
||||
{
|
||||
switch (aEvent.type) {
|
||||
case "panelsetready":
|
||||
{
|
||||
this.mPanelSet.getPanel(0).subject = this.mDoc;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,79 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- ***** 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.
|
||||
-
|
||||
- The Initial Developer of the Original Code is Axel Hecht
|
||||
- Portions created by the Initial Developer are Copyright (C) 2002
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Axel Hecht <axel@pike.org> (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 LGPL or the GPL. 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 ***** -->
|
||||
|
||||
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="result-view.css" type="text/css"?>
|
||||
|
||||
<window id="buster-result-view" title="Xalan testcase details"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
orient="vertical" persist="width height"
|
||||
onload="onResultViewLoad()" onunload="onResultViewUnload()">
|
||||
<script type="application/x-javascript" src="DumpDOM.js" />
|
||||
<script type="application/x-javascript" src="buster-statics.js" />
|
||||
<script type="application/x-javascript" src="buster-test.js" />
|
||||
<script type="application/x-javascript" src="result-view.js" />
|
||||
|
||||
<hbox>
|
||||
<button class="close" label="close this window"
|
||||
oncommand="window.close()" />
|
||||
</hbox>
|
||||
<vbox flex="1">
|
||||
<label class="heading" value="XML Source:" />
|
||||
<iframe flex="1" id="src" />
|
||||
</vbox>
|
||||
<vbox flex="1">
|
||||
<label class="heading" value="XSL Source:" />
|
||||
<iframe flex="1" id="style" />
|
||||
</vbox>
|
||||
<vbox flex="1" id="refSourceBox">
|
||||
<label class="heading" value="Reference Source:" />
|
||||
<iframe flex="1" id="ref" />
|
||||
</vbox>
|
||||
<vbox flex="2" id="inspectorBox">
|
||||
<hbox flex="1">
|
||||
<vbox flex="1">
|
||||
<label class="heading" value="Reference" />
|
||||
<iframe flex="1" id="refInsp" src="result-inspector.xul" />
|
||||
</vbox>
|
||||
<vbox flex="1">
|
||||
<label class="heading" value="Result" />
|
||||
<iframe flex="1" id="resInsp" src="result-inspector.xul" />
|
||||
</vbox>
|
||||
</hbox>
|
||||
</vbox>
|
||||
</window>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
|
||||
|
||||
<!-- list all the packages being supplied by this jar -->
|
||||
<RDF:Seq about="urn:mozilla:package:root">
|
||||
<RDF:li resource="urn:mozilla:package:xslt-qa"/>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- package information -->
|
||||
<RDF:Description about="urn:mozilla:package:xslt-qa"
|
||||
chrome:displayName="XSLT QA Tools"
|
||||
chrome:author="mozilla.org"
|
||||
chrome:name="xslt-qa"
|
||||
chrome:localeVersion="1.4a"
|
||||
chrome:skinVersion="1.2">
|
||||
</RDF:Description>
|
||||
|
||||
<!-- overlay information -->
|
||||
<RDF:Seq about="urn:mozilla:overlays">
|
||||
<RDF:li resource="chrome://navigator/content/navigatorOverlay.xul"/>
|
||||
</RDF:Seq>
|
||||
|
||||
<RDF:Seq about="chrome://navigator/content/navigatorOverlay.xul">
|
||||
<RDF:li>chrome://xslt-qa/content/xslt-qa-overlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
</RDF:RDF>
|
||||
@@ -1,17 +0,0 @@
|
||||
xslt-qa.jar:
|
||||
content/xslt-qa/contents.rdf (contents.rdf)
|
||||
content/xslt-qa/xslt-qa-overlay.xul (xslt-qa-overlay.xul)
|
||||
content/xslt-qa/xslt-qa-overlay.js (xslt-qa-overlay.js)
|
||||
content/xslt-qa/buster/buster.xul (buster/buster.xul)
|
||||
content/xslt-qa/buster/buster.css (buster/buster.css)
|
||||
content/xslt-qa/buster/buster-statics.js (buster/buster-statics.js)
|
||||
content/xslt-qa/buster/buster-handlers.js (buster/buster-handlers.js)
|
||||
content/xslt-qa/buster/buster-files.js (buster/buster-files.js)
|
||||
content/xslt-qa/buster/buster-test.js (buster/buster-test.js)
|
||||
content/xslt-qa/buster/buster-view.js (buster/buster-view.js)
|
||||
content/xslt-qa/buster/result-view.xul (buster/result-view.xul)
|
||||
content/xslt-qa/buster/result-inspector.xul (buster/result-inspector.xul)
|
||||
content/xslt-qa/buster/result-view.css (buster/result-view.css)
|
||||
content/xslt-qa/buster/result-view.js (buster/result-view.js)
|
||||
content/xslt-qa/buster/DumpDOM.js (buster/DumpDOM.js)
|
||||
content/xslt-qa/buster/DiffDOM.js (buster/DiffDOM.js)
|
||||
@@ -1,44 +0,0 @@
|
||||
/* -*- 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
|
||||
* Axel Hecht.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
* 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 ***** */
|
||||
|
||||
function onStartBuster()
|
||||
{
|
||||
window.open('chrome://xslt-qa/content/buster/buster.xul',
|
||||
'buster', 'chrome,resizable');
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- ***** 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.
|
||||
-
|
||||
- The Initial Developer of the Original Code is Axel Hecht
|
||||
- Portions created by the Initial Developer are Copyright (C) 2002
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Axel Hecht <axel@pike.org> (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 LGPL or the GPL. 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 ***** -->
|
||||
|
||||
<overlay id="xsltQAMenuID"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script src="xslt-qa-overlay.js" />
|
||||
<menupopup id="qaMenuPopup">
|
||||
<menuseparator/>
|
||||
<menu label="XSLT QA" accesskey="X">
|
||||
<menupopup>
|
||||
<menuitem label="Xalan Tests" oncommand="onStartBuster()"/>
|
||||
<menuitem label="XSLTMark" oncommand="alert('bar2')"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
</menupopup>
|
||||
</overlay>
|
||||
@@ -1,35 +0,0 @@
|
||||
#
|
||||
# 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 Axel Hecht.
|
||||
# Portions created by Axel Hecht are Copyright (C) Axel Hecht.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <axel@pike.org>
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = base xml xpath xslt
|
||||
|
||||
ifdef TX_EXE
|
||||
DIRS += lib main
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
@@ -1,313 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* Larry Fitzpatrick, lef@opentext.com
|
||||
*
|
||||
* Eric Du, duxy@leyou.com.cn
|
||||
* -- added fix for FreeBSD
|
||||
*
|
||||
* NaN/Infinity code copied from the JS-library with permission from
|
||||
* Netscape Communications Corporation: http://www.mozilla.org/js
|
||||
* http://lxr.mozilla.org/seamonkey/source/js/src/jsnum.h
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsString.h"
|
||||
#include "primitives.h"
|
||||
#include "XMLUtils.h"
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef WIN32
|
||||
#include <float.h>
|
||||
#endif
|
||||
#include "prdtoa.h"
|
||||
|
||||
/*
|
||||
* Utility class for doubles
|
||||
*/
|
||||
|
||||
//A trick to handle IEEE floating point exceptions on FreeBSD - E.D.
|
||||
#ifdef __FreeBSD__
|
||||
#include <ieeefp.h>
|
||||
#ifdef __alpha__
|
||||
fp_except_t allmask = FP_X_INV|FP_X_OFL|FP_X_UFL|FP_X_DZ|FP_X_IMP;
|
||||
#else
|
||||
fp_except_t allmask = FP_X_INV|FP_X_OFL|FP_X_UFL|FP_X_DZ|FP_X_IMP|FP_X_DNML;
|
||||
#endif
|
||||
fp_except_t oldmask = fpsetmask(~allmask);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros to workaround math-bugs bugs in various platforms
|
||||
*/
|
||||
|
||||
#ifdef IS_BIG_ENDIAN
|
||||
#define TX_DOUBLE_HI32(x) (((PRUint32 *)&(x))[0])
|
||||
#define TX_DOUBLE_LO32(x) (((PRUint32 *)&(x))[1])
|
||||
#else
|
||||
#define TX_DOUBLE_HI32(x) (((PRUint32 *)&(x))[1])
|
||||
#define TX_DOUBLE_LO32(x) (((PRUint32 *)&(x))[0])
|
||||
#endif
|
||||
|
||||
#define TX_DOUBLE_HI32_SIGNBIT 0x80000000
|
||||
#define TX_DOUBLE_HI32_EXPMASK 0x7ff00000
|
||||
#define TX_DOUBLE_HI32_MANTMASK 0x000fffff
|
||||
|
||||
//-- Initialize Double related constants
|
||||
#ifdef IS_BIG_ENDIAN
|
||||
const PRUint32 nanMask[2] = {TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_MANTMASK,
|
||||
0xffffffff};
|
||||
const PRUint32 infMask[2] = {TX_DOUBLE_HI32_EXPMASK, 0};
|
||||
const PRUint32 negInfMask[2] = {TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_SIGNBIT, 0};
|
||||
#else
|
||||
const PRUint32 nanMask[2] = {0xffffffff,
|
||||
TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_MANTMASK};
|
||||
const PRUint32 infMask[2] = {0, TX_DOUBLE_HI32_EXPMASK};
|
||||
const PRUint32 negInfMask[2] = {0, TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_SIGNBIT};
|
||||
#endif
|
||||
|
||||
const double Double::NaN = *((double*)nanMask);
|
||||
const double Double::POSITIVE_INFINITY = *((double*)infMask);
|
||||
const double Double::NEGATIVE_INFINITY = *((double*)negInfMask);
|
||||
|
||||
/*
|
||||
* Determines whether the given double represents positive or negative
|
||||
* inifinity
|
||||
*/
|
||||
MBool Double::isInfinite(double aDbl)
|
||||
{
|
||||
return ((TX_DOUBLE_HI32(aDbl) & ~TX_DOUBLE_HI32_SIGNBIT) == TX_DOUBLE_HI32_EXPMASK &&
|
||||
!TX_DOUBLE_LO32(aDbl));
|
||||
}
|
||||
|
||||
/*
|
||||
* Determines whether the given double is NaN
|
||||
*/
|
||||
MBool Double::isNaN(double aDbl)
|
||||
{
|
||||
return ((TX_DOUBLE_HI32(aDbl) & TX_DOUBLE_HI32_EXPMASK) == TX_DOUBLE_HI32_EXPMASK &&
|
||||
(TX_DOUBLE_LO32(aDbl) || (TX_DOUBLE_HI32(aDbl) & TX_DOUBLE_HI32_MANTMASK)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Determines whether the given double is negative
|
||||
*/
|
||||
MBool Double::isNeg(double aDbl)
|
||||
{
|
||||
return (TX_DOUBLE_HI32(aDbl) & TX_DOUBLE_HI32_SIGNBIT) != 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Converts the given String to a double, if the String value does not
|
||||
* represent a double, NaN will be returned
|
||||
*/
|
||||
class txStringToDouble
|
||||
{
|
||||
public:
|
||||
typedef PRUnichar input_type;
|
||||
typedef PRUnichar value_type;
|
||||
txStringToDouble(): mState(eWhitestart), mSign(ePositive) {}
|
||||
|
||||
PRUint32
|
||||
write(const input_type* aSource, PRUint32 aSourceLength)
|
||||
{
|
||||
if (mState == eIllegal) {
|
||||
return aSourceLength;
|
||||
}
|
||||
PRUint32 i = 0;
|
||||
PRUnichar c;
|
||||
for ( ; i < aSourceLength; ++i) {
|
||||
c = aSource[i];
|
||||
switch (mState) {
|
||||
case eWhitestart:
|
||||
if (c == '-') {
|
||||
mState = eDecimal;
|
||||
mSign = eNegative;
|
||||
}
|
||||
else if (c >= '0' && c <= '9') {
|
||||
mState = eDecimal;
|
||||
mBuffer.Append((char)c);
|
||||
}
|
||||
else if (c == '.') {
|
||||
mState = eMantissa;
|
||||
mBuffer.Append((char)c);
|
||||
}
|
||||
else if (!XMLUtils::isWhitespace(c)) {
|
||||
mState = eIllegal;
|
||||
return aSourceLength;
|
||||
}
|
||||
break;
|
||||
case eDecimal:
|
||||
if (c >= '0' && c <= '9') {
|
||||
mBuffer.Append((char)c);
|
||||
}
|
||||
else if (c == '.') {
|
||||
mState = eMantissa;
|
||||
mBuffer.Append((char)c);
|
||||
}
|
||||
else if (XMLUtils::isWhitespace(c)) {
|
||||
mState = eWhiteend;
|
||||
}
|
||||
else {
|
||||
mState = eIllegal;
|
||||
return aSourceLength;
|
||||
}
|
||||
break;
|
||||
case eMantissa:
|
||||
if (c >= '0' && c <= '9') {
|
||||
mBuffer.Append((char)c);
|
||||
}
|
||||
else if (XMLUtils::isWhitespace(c)) {
|
||||
mState = eWhiteend;
|
||||
}
|
||||
else {
|
||||
mState = eIllegal;
|
||||
return aSourceLength;
|
||||
}
|
||||
break;
|
||||
case eWhiteend:
|
||||
if (!XMLUtils::isWhitespace(c)) {
|
||||
mState = eIllegal;
|
||||
return aSourceLength;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return aSourceLength;
|
||||
}
|
||||
|
||||
double
|
||||
getDouble()
|
||||
{
|
||||
if (mState == eIllegal || mBuffer.IsEmpty() ||
|
||||
(mBuffer.Length() == 1 && mBuffer[0] == '.')) {
|
||||
return Double::NaN;
|
||||
}
|
||||
return mSign*PR_strtod(mBuffer.get(), 0);
|
||||
}
|
||||
private:
|
||||
nsCAutoString mBuffer;
|
||||
enum {
|
||||
eWhitestart,
|
||||
eDecimal,
|
||||
eMantissa,
|
||||
eWhiteend,
|
||||
eIllegal
|
||||
} mState;
|
||||
enum {
|
||||
eNegative = -1,
|
||||
ePositive = 1
|
||||
} mSign;
|
||||
};
|
||||
|
||||
double Double::toDouble(const nsAString& aSrc)
|
||||
{
|
||||
txStringToDouble sink;
|
||||
nsAString::const_iterator fromBegin, fromEnd;
|
||||
copy_string(aSrc.BeginReading(fromBegin), aSrc.EndReading(fromEnd), sink);
|
||||
return sink.getDouble();
|
||||
}
|
||||
|
||||
/*
|
||||
* Converts the value of the given double to a String, and places
|
||||
* The result into the destination String.
|
||||
* @return the given dest string
|
||||
*/
|
||||
void Double::toString(double aValue, nsAString& aDest)
|
||||
{
|
||||
|
||||
// check for special cases
|
||||
|
||||
if (isNaN(aValue)) {
|
||||
aDest.Append(NS_LITERAL_STRING("NaN"));
|
||||
return;
|
||||
}
|
||||
if (isInfinite(aValue)) {
|
||||
if (aValue < 0)
|
||||
aDest.Append(PRUnichar('-'));
|
||||
aDest.Append(NS_LITERAL_STRING("Infinity"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Mantissa length is 17, so this is plenty
|
||||
const int buflen = 20;
|
||||
char buf[buflen];
|
||||
|
||||
PRIntn intDigits, sign;
|
||||
char* endp;
|
||||
PR_dtoa(aValue, 0, 0, &intDigits, &sign, &endp, buf, buflen - 1);
|
||||
|
||||
// compute length
|
||||
PRInt32 length = endp - buf;
|
||||
if (length > intDigits) {
|
||||
// decimal point needed
|
||||
++length;
|
||||
if (intDigits < 1) {
|
||||
// leading zeros, -intDigits + 1
|
||||
length += 1 - intDigits;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// trailing zeros, total length given by intDigits
|
||||
length = intDigits;
|
||||
}
|
||||
if (aValue < 0)
|
||||
++length;
|
||||
PRUint32 oldlength = aDest.Length();
|
||||
aDest.SetLength(oldlength + length); // grow the string
|
||||
nsAString::iterator dest;
|
||||
aDest.BeginWriting(dest).advance(PRInt32(oldlength));
|
||||
if (aValue < 0) {
|
||||
*dest = '-'; ++dest;
|
||||
}
|
||||
int i;
|
||||
// leading zeros
|
||||
if (intDigits < 1) {
|
||||
*dest = '0'; ++dest;
|
||||
*dest = '.'; ++dest;
|
||||
for (i = 0; i > intDigits; --i) {
|
||||
*dest = '0'; ++dest;
|
||||
}
|
||||
}
|
||||
// mantissa
|
||||
int firstlen = PR_MIN(intDigits, endp - buf);
|
||||
for (i = 0; i < firstlen; i++) {
|
||||
*dest = buf[i]; ++dest;
|
||||
}
|
||||
if (i < endp - buf) {
|
||||
if (i > 0) {
|
||||
*dest = '.'; ++dest;
|
||||
}
|
||||
for (; i < endp - buf; i++) {
|
||||
*dest = buf[i]; ++dest;
|
||||
}
|
||||
}
|
||||
// trailing zeros
|
||||
for (; i < intDigits; i++) {
|
||||
*dest = '0'; ++dest;
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MITRE_ERROROBSERVER_H
|
||||
#define MITRE_ERROROBSERVER_H
|
||||
|
||||
#include "baseutils.h"
|
||||
#include "txError.h"
|
||||
#include <iostream.h>
|
||||
class nsAString;
|
||||
|
||||
/**
|
||||
* A simple interface for observing errors
|
||||
**/
|
||||
class ErrorObserver {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default Destructor for ErrorObserver
|
||||
**/
|
||||
virtual ~ErrorObserver() {};
|
||||
|
||||
/**
|
||||
* Notifies this Error observer of a new error aRes
|
||||
**/
|
||||
virtual void receiveError(const nsAString& errorMessage, nsresult aRes) = 0;
|
||||
|
||||
/**
|
||||
* Notifies this Error observer of a new error, with default
|
||||
* error code NS_ERROR_FAILURE
|
||||
**/
|
||||
void receiveError(const nsAString& errorMessage)
|
||||
{
|
||||
receiveError(errorMessage, NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}; //-- ErrorObserver
|
||||
|
||||
/**
|
||||
* A simple ErrorObserver which allows printing error messages to a stream
|
||||
**/
|
||||
class SimpleErrorObserver : public ErrorObserver {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates a new SimpleErrorObserver.
|
||||
* All errors will be printed to the console (cout).
|
||||
**/
|
||||
SimpleErrorObserver();
|
||||
|
||||
/**
|
||||
* Creates a new SimpleErrorObserver.
|
||||
* All errors will be printed to the given ostream.
|
||||
**/
|
||||
SimpleErrorObserver(ostream& errStream);
|
||||
|
||||
virtual ~SimpleErrorObserver() {};
|
||||
|
||||
/**
|
||||
* Notifies this Error observer of a new error aRes
|
||||
**/
|
||||
void receiveError(const nsAString& errorMessage, nsresult aRes);
|
||||
|
||||
virtual void supressWarnings(MBool supress);
|
||||
|
||||
private:
|
||||
|
||||
ostream* errStream;
|
||||
MBool hideWarnings;
|
||||
}; //-- SimpleErrorObserver
|
||||
#endif
|
||||
|
||||
@@ -1,420 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* Bob Miller, kbob@oblix.com
|
||||
* -- plugged core leak.
|
||||
*
|
||||
* Jonas Sicking, sicking@bigfoot.com
|
||||
* -- Cleanup/bugfix/features in Iterator
|
||||
* Added tx prefix to classnames
|
||||
*/
|
||||
|
||||
#include "List.h"
|
||||
|
||||
//----------------------------/
|
||||
//- Implementation of txList -/
|
||||
//----------------------------/
|
||||
|
||||
/**
|
||||
* Default constructor for a txList;
|
||||
**/
|
||||
|
||||
txList::txList() {
|
||||
firstItem = 0;
|
||||
lastItem = 0;
|
||||
itemCount = 0;
|
||||
} //-- txList;
|
||||
|
||||
/**
|
||||
* txList destructor, cleans up ListItems, but will not delete the Object
|
||||
* references
|
||||
*/
|
||||
txList::~txList() {
|
||||
clear();
|
||||
} //-- ~txList
|
||||
|
||||
nsresult txList::insert(int index, void* objPtr)
|
||||
{
|
||||
if (index >= itemCount) {
|
||||
return insertBefore(objPtr, 0);
|
||||
}
|
||||
// add inside the list
|
||||
ListItem* nextItem = firstItem;
|
||||
for (int i = 0; i < index; i++)
|
||||
nextItem = nextItem->nextItem;
|
||||
return insertBefore(objPtr, nextItem);
|
||||
} //-- insert
|
||||
|
||||
nsresult txList::add(void* objPtr)
|
||||
{
|
||||
return insertBefore(objPtr, 0);
|
||||
} //-- add
|
||||
|
||||
/**
|
||||
* Returns the object located at the given index. This may
|
||||
* be slow or fast depending on the implementation.
|
||||
* Note:
|
||||
* Currently this list is implemented via a linked list, so
|
||||
* this method will be slow (unless the list only has a couple
|
||||
* members) as it will need traverse the links each time
|
||||
* @return the object located at the given index
|
||||
**/
|
||||
void* txList::get(int index) {
|
||||
|
||||
if (index < 0 || index >= itemCount)
|
||||
return 0;
|
||||
|
||||
int c = 0;
|
||||
ListItem* item = firstItem;
|
||||
while ((c != index) && item) {
|
||||
item = item->nextItem;
|
||||
++c;
|
||||
}
|
||||
|
||||
if (item)
|
||||
return item->objPtr;
|
||||
return 0;
|
||||
} //-- get(int)
|
||||
|
||||
txList::ListItem* txList::getFirstItem() {
|
||||
return firstItem;
|
||||
} //-- getFirstItem
|
||||
|
||||
txList::ListItem* txList::getLastItem() {
|
||||
return lastItem;
|
||||
} //-- getLastItem
|
||||
|
||||
/**
|
||||
* Returns the number of items in this txList
|
||||
**/
|
||||
PRInt32 List::getLength() {
|
||||
return itemCount;
|
||||
} //-- getLength
|
||||
|
||||
|
||||
/**
|
||||
* Inserts the given Object pointer as the item just after refItem.
|
||||
* If refItem is a null pointer the Object will be inserted at the
|
||||
* beginning of the txList (ie, insert after nothing).
|
||||
* This method assumes refItem is a member of this list, and since this
|
||||
* is a private method, I feel that's a valid assumption
|
||||
**/
|
||||
nsresult txList::insertAfter(void* objPtr, ListItem* refItem)
|
||||
{
|
||||
//-- if refItem == null insert at front
|
||||
if (!refItem)
|
||||
return insertBefore(objPtr, firstItem);
|
||||
return insertBefore(objPtr, refItem->nextItem);
|
||||
} //-- insertAfter
|
||||
|
||||
/**
|
||||
* Inserts the given Object pointer as the item just before refItem.
|
||||
* If refItem is a null pointer the Object will be inserted at the
|
||||
* end of the txList (ie, insert before nothing).
|
||||
* This method assumes refItem is a member of this list, and since this
|
||||
* is a private method, I feel that's a valid assumption
|
||||
**/
|
||||
nsresult txList::insertBefore(void* objPtr, ListItem* refItem)
|
||||
{
|
||||
ListItem* item = new ListItem;
|
||||
NS_ENSURE_TRUE(item, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
item->objPtr = objPtr;
|
||||
item->nextItem = 0;
|
||||
item->prevItem = 0;
|
||||
|
||||
//-- if refItem == null insert at end
|
||||
if (!refItem) {
|
||||
//-- add to back of list
|
||||
if (lastItem) {
|
||||
lastItem->nextItem = item;
|
||||
item->prevItem = lastItem;
|
||||
}
|
||||
lastItem = item;
|
||||
if (!firstItem)
|
||||
firstItem = item;
|
||||
}
|
||||
else {
|
||||
//-- insert before given item
|
||||
item->nextItem = refItem;
|
||||
item->prevItem = refItem->prevItem;
|
||||
refItem->prevItem = item;
|
||||
|
||||
if (item->prevItem)
|
||||
item->prevItem->nextItem = item;
|
||||
else
|
||||
firstItem = item;
|
||||
}
|
||||
|
||||
// increase the item count
|
||||
++itemCount;
|
||||
|
||||
return NS_OK;
|
||||
} //-- insertBefore
|
||||
|
||||
void* txList::remove(void* objPtr) {
|
||||
ListItem* item = firstItem;
|
||||
while (item) {
|
||||
if (item->objPtr == objPtr) {
|
||||
remove(item);
|
||||
delete item;
|
||||
return objPtr;
|
||||
}
|
||||
item = item->nextItem;
|
||||
}
|
||||
// not in list
|
||||
return 0;
|
||||
} //-- remove
|
||||
|
||||
txList::ListItem* txList::remove(ListItem* item) {
|
||||
|
||||
if (!item)
|
||||
return item;
|
||||
|
||||
//-- adjust the previous item's next pointer
|
||||
if (item->prevItem) {
|
||||
item->prevItem->nextItem = item->nextItem;
|
||||
}
|
||||
//-- adjust the next item's previous pointer
|
||||
if (item->nextItem) {
|
||||
item->nextItem->prevItem = item->prevItem;
|
||||
}
|
||||
|
||||
//-- adjust first and last items
|
||||
if (item == firstItem)
|
||||
firstItem = item->nextItem;
|
||||
if (item == lastItem)
|
||||
lastItem = item->prevItem;
|
||||
|
||||
//-- decrease Item count
|
||||
--itemCount;
|
||||
return item;
|
||||
} //-- remove
|
||||
|
||||
void txList::clear()
|
||||
{
|
||||
ListItem* item = firstItem;
|
||||
while (item) {
|
||||
ListItem* tItem = item;
|
||||
item = item->nextItem;
|
||||
delete tItem;
|
||||
}
|
||||
firstItem = 0;
|
||||
lastItem = 0;
|
||||
itemCount = 0;
|
||||
}
|
||||
|
||||
//------------------------------------/
|
||||
//- Implementation of txListIterator -/
|
||||
//------------------------------------/
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new txListIterator for the given txList
|
||||
* @param list, the txList to create an Iterator for
|
||||
**/
|
||||
txListIterator::txListIterator(txList* list) {
|
||||
this->list = list;
|
||||
currentItem = 0;
|
||||
atEndOfList = MB_FALSE;
|
||||
} //-- txListIterator
|
||||
|
||||
txListIterator::~txListIterator() {
|
||||
//-- overrides default destructor to do nothing
|
||||
} //-- ~txListIterator
|
||||
|
||||
/**
|
||||
* Adds the Object pointer to the txList pointed to by this txListIterator.
|
||||
* The Object pointer is inserted as the next item in the txList
|
||||
* based on the current position within the txList
|
||||
* @param objPtr the Object pointer to add to the list
|
||||
**/
|
||||
nsresult txListIterator::addAfter(void* objPtr)
|
||||
{
|
||||
if (currentItem || !atEndOfList)
|
||||
return list->insertAfter(objPtr, currentItem);
|
||||
return list->insertBefore(objPtr, 0);
|
||||
|
||||
} //-- addAfter
|
||||
|
||||
/**
|
||||
* Adds the Object pointer to the txList pointed to by this txListIterator.
|
||||
* The Object pointer is inserted as the previous item in the txList
|
||||
* based on the current position within the txList
|
||||
* @param objPtr the Object pointer to add to the list
|
||||
**/
|
||||
nsresult txListIterator::addBefore(void* objPtr)
|
||||
{
|
||||
if (currentItem || atEndOfList)
|
||||
return list->insertBefore(objPtr, currentItem);
|
||||
return list->insertAfter(objPtr, 0);
|
||||
|
||||
} //-- addBefore
|
||||
|
||||
/**
|
||||
* Returns true if a sucessful call to the next() method can be made
|
||||
* @return MB_TRUE if a sucessful call to the next() method can be made,
|
||||
* otherwise MB_FALSE
|
||||
**/
|
||||
MBool txListIterator::hasNext() {
|
||||
MBool hasNext = MB_FALSE;
|
||||
if (currentItem)
|
||||
hasNext = (currentItem->nextItem != 0);
|
||||
else if (!atEndOfList)
|
||||
hasNext = (list->firstItem != 0);
|
||||
|
||||
return hasNext;
|
||||
} //-- hasNext
|
||||
|
||||
/**
|
||||
* Returns true if a sucessful call to the previous() method can be made
|
||||
* @return MB_TRUE if a sucessful call to the previous() method can be made,
|
||||
* otherwise MB_FALSE
|
||||
**/
|
||||
MBool txListIterator::hasPrevious() {
|
||||
MBool hasPrevious = MB_FALSE;
|
||||
if (currentItem)
|
||||
hasPrevious = (currentItem->prevItem != 0);
|
||||
else if (atEndOfList)
|
||||
hasPrevious = (list->lastItem != 0);
|
||||
|
||||
return hasPrevious;
|
||||
} //-- hasPrevious
|
||||
|
||||
/**
|
||||
* Returns the next Object pointer in the list
|
||||
**/
|
||||
void* txListIterator::next() {
|
||||
|
||||
void* obj = 0;
|
||||
if (currentItem)
|
||||
currentItem = currentItem->nextItem;
|
||||
else if (!atEndOfList)
|
||||
currentItem = list->firstItem;
|
||||
|
||||
if (currentItem)
|
||||
obj = currentItem->objPtr;
|
||||
else
|
||||
atEndOfList = MB_TRUE;
|
||||
|
||||
return obj;
|
||||
} //-- next
|
||||
|
||||
/**
|
||||
* Returns the previous Object in the list
|
||||
**/
|
||||
void* txListIterator::previous() {
|
||||
|
||||
void* obj = 0;
|
||||
|
||||
if (currentItem)
|
||||
currentItem = currentItem->prevItem;
|
||||
else if (atEndOfList)
|
||||
currentItem = list->lastItem;
|
||||
|
||||
if (currentItem)
|
||||
obj = currentItem->objPtr;
|
||||
|
||||
atEndOfList = MB_FALSE;
|
||||
|
||||
return obj;
|
||||
} //-- previous
|
||||
|
||||
/**
|
||||
* Returns the current Object
|
||||
**/
|
||||
void* txListIterator::current() {
|
||||
|
||||
if (currentItem)
|
||||
return currentItem->objPtr;
|
||||
|
||||
return 0;
|
||||
} //-- current
|
||||
|
||||
/**
|
||||
* Moves the specified number of steps
|
||||
**/
|
||||
void* txListIterator::advance(int i) {
|
||||
|
||||
void* obj = 0;
|
||||
|
||||
if (i > 0) {
|
||||
if (!currentItem && !atEndOfList) {
|
||||
currentItem = list->firstItem;
|
||||
--i;
|
||||
}
|
||||
for (; currentItem && i > 0; i--)
|
||||
currentItem = currentItem->nextItem;
|
||||
|
||||
atEndOfList = currentItem == 0;
|
||||
}
|
||||
else if (i < 0) {
|
||||
if (!currentItem && atEndOfList) {
|
||||
currentItem = list->lastItem;
|
||||
++i;
|
||||
}
|
||||
for (; currentItem && i < 0; i++)
|
||||
currentItem = currentItem->prevItem;
|
||||
|
||||
atEndOfList = MB_FALSE;
|
||||
}
|
||||
|
||||
if (currentItem)
|
||||
obj = currentItem->objPtr;
|
||||
|
||||
return obj;
|
||||
} //-- advance
|
||||
|
||||
/**
|
||||
* Removes the Object last returned by the next() or previous() methods;
|
||||
* @return the removed Object pointer
|
||||
**/
|
||||
void* txListIterator::remove() {
|
||||
|
||||
void* obj = 0;
|
||||
if (currentItem) {
|
||||
obj = currentItem->objPtr;
|
||||
txList::ListItem* item = currentItem;
|
||||
previous(); //-- make previous item the current item
|
||||
list->remove(item);
|
||||
delete item;
|
||||
}
|
||||
return obj;
|
||||
} //-- remove
|
||||
|
||||
/**
|
||||
* Resets the current location within the txList to the beginning of the txList
|
||||
**/
|
||||
void txListIterator::reset() {
|
||||
atEndOfList = MB_FALSE;
|
||||
currentItem = 0;
|
||||
} //-- reset
|
||||
|
||||
/**
|
||||
* Move the iterator to right after the last element
|
||||
**/
|
||||
void txListIterator::resetToEnd() {
|
||||
atEndOfList = MB_TRUE;
|
||||
currentItem = 0;
|
||||
} //-- moveToEnd
|
||||
@@ -1,217 +0,0 @@
|
||||
/*
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* Jonas Sicking, sicking@bigfoot.com
|
||||
* -- Cleanup/bugfix/features in Iterator
|
||||
* Added tx prefix to classnames
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TRANSFRMX_LIST_H
|
||||
#define TRANSFRMX_LIST_H
|
||||
|
||||
#include "baseutils.h"
|
||||
#include "TxObject.h"
|
||||
#include "txError.h"
|
||||
|
||||
class txListIterator;
|
||||
|
||||
/**
|
||||
* Represents an ordered list of Object pointers. Modeled after a Java 2 List.
|
||||
**/
|
||||
class txList : public TxObject {
|
||||
|
||||
friend class txListIterator;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates an empty txList
|
||||
**/
|
||||
txList();
|
||||
|
||||
/**
|
||||
* txList destructor, object references will not be deleted.
|
||||
**/
|
||||
virtual ~txList();
|
||||
|
||||
/**
|
||||
* Returns the object located at the given index. This may
|
||||
* be slow or fast depending on the implementation.
|
||||
* @return the object located at the given index
|
||||
**/
|
||||
void* get(int index);
|
||||
|
||||
/**
|
||||
* Returns the number of items in this txList
|
||||
**/
|
||||
PRInt32 getLength();
|
||||
|
||||
/**
|
||||
* Adds the given Object to the specified position in the list
|
||||
**/
|
||||
nsresult insert(int index, void* objPtr);
|
||||
|
||||
/**
|
||||
* Adds the given Object to the list
|
||||
**/
|
||||
nsresult add(void* objPtr);
|
||||
|
||||
/**
|
||||
* Removes the given Object pointer from the list
|
||||
**/
|
||||
void* remove(void* objPtr);
|
||||
|
||||
/*
|
||||
* Removes all the objects from the list
|
||||
*/
|
||||
void clear();
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
struct ListItem {
|
||||
ListItem* nextItem;
|
||||
ListItem* prevItem;
|
||||
void* objPtr;
|
||||
};
|
||||
|
||||
ListItem* getFirstItem();
|
||||
ListItem* getLastItem();
|
||||
|
||||
/**
|
||||
* Removes the given ListItem pointer from the list
|
||||
**/
|
||||
ListItem* remove(ListItem* sItem);
|
||||
|
||||
private:
|
||||
txList(const txList& aOther); // not implemented
|
||||
|
||||
ListItem* firstItem;
|
||||
ListItem* lastItem;
|
||||
PRInt32 itemCount;
|
||||
|
||||
nsresult insertAfter(void* objPtr, ListItem* sItem);
|
||||
nsresult insertBefore(void* objPtr, ListItem* sItem);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* An Iterator for the txList Class
|
||||
**/
|
||||
class txListIterator {
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a new txListIterator for the given txList
|
||||
* @param list, the txList to create an Iterator for
|
||||
**/
|
||||
txListIterator(txList* list);
|
||||
|
||||
/**
|
||||
* Destructor, destroys a given instance of a txListIterator
|
||||
**/
|
||||
~txListIterator();
|
||||
|
||||
/**
|
||||
* Adds the Object pointer to the txList pointed to by this txListIterator.
|
||||
* The Object pointer is inserted as the next item in the txList
|
||||
* based on the current position within the txList
|
||||
* @param objPtr the Object pointer to add to the list
|
||||
**/
|
||||
nsresult addAfter(void* objPtr);
|
||||
|
||||
/**
|
||||
* Adds the Object pointer to the txList pointed to by this txListIterator.
|
||||
* The Object pointer is inserted as the previous item in the txList
|
||||
* based on the current position within the txList
|
||||
* @param objPtr the Object pointer to add to the list
|
||||
**/
|
||||
nsresult addBefore(void* objPtr);
|
||||
|
||||
/**
|
||||
* Returns true if a sucessful call to the next() method can be made
|
||||
* @return MB_TRUE if a sucessful call to the next() method can be made,
|
||||
* otherwise MB_FALSE
|
||||
**/
|
||||
MBool hasNext();
|
||||
|
||||
/**
|
||||
* Returns true if a sucessful call to the previous() method can be made
|
||||
* @return MB_TRUE if a sucessful call to the previous() method can be made,
|
||||
* otherwise MB_FALSE
|
||||
**/
|
||||
MBool hasPrevious();
|
||||
|
||||
/**
|
||||
* Returns the next Object pointer from the list
|
||||
**/
|
||||
void* next();
|
||||
|
||||
/**
|
||||
* Returns the previous Object pointer from the list
|
||||
**/
|
||||
void* previous();
|
||||
|
||||
/**
|
||||
* Returns the current Object
|
||||
**/
|
||||
void* current();
|
||||
|
||||
/**
|
||||
* Moves the specified number of steps
|
||||
**/
|
||||
void* advance(int i);
|
||||
|
||||
/**
|
||||
* Removes the Object last returned by the next() or previous() methods;
|
||||
* @return the removed Object pointer
|
||||
**/
|
||||
void* remove();
|
||||
|
||||
/**
|
||||
* Resets the current location within the txList to the beginning of the txList
|
||||
**/
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* Resets the current location within the txList to the end of the txList
|
||||
**/
|
||||
void resetToEnd();
|
||||
|
||||
private:
|
||||
|
||||
//-- points to the current list item
|
||||
txList::ListItem* currentItem;
|
||||
|
||||
//-- points to the list to iterator over
|
||||
txList* list;
|
||||
|
||||
//-- we've moved off the end of the list
|
||||
MBool atEndOfList;
|
||||
};
|
||||
|
||||
typedef txList List;
|
||||
|
||||
#endif
|
||||
@@ -1,62 +0,0 @@
|
||||
#
|
||||
# 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 Axel Hecht.
|
||||
# Portions created by Axel Hecht are Copyright (C) Axel Hecht.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <axel@pike.org>
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
$(NULL)
|
||||
ifndef TX_EXE
|
||||
MODULE = transformiix
|
||||
REQUIRES += unicharutil \
|
||||
dom \
|
||||
content \
|
||||
widget \
|
||||
necko \
|
||||
caps \
|
||||
xpconnect \
|
||||
js \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
CPPSRCS = Double.cpp \
|
||||
List.cpp \
|
||||
SimpleErrorObserver.cpp \
|
||||
txAtoms.cpp \
|
||||
txExpandedNameMap.cpp \
|
||||
txNamespaceMap.cpp \
|
||||
txURIUtils.cpp
|
||||
|
||||
ifdef TX_EXE
|
||||
CPPSRCS += txStringUtils.cpp
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir)/../xpath -I$(srcdir)/../xslt -I$(srcdir)/../xml \
|
||||
-I$(srcdir)/../xml/dom -I$(srcdir)
|
||||
|
||||
libs:: $(OBJS)
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ErrorObserver.h"
|
||||
#include "nsString.h"
|
||||
|
||||
/**
|
||||
* Creates a new SimpleErrorObserver.
|
||||
* All errors will be printed to the console (cout).
|
||||
**/
|
||||
SimpleErrorObserver::SimpleErrorObserver() {
|
||||
#ifdef TX_EXE
|
||||
errStream = &cout;
|
||||
#endif
|
||||
hideWarnings = MB_FALSE;
|
||||
} //-- SimpleErrorObserver
|
||||
|
||||
/**
|
||||
* Creates a new SimpleErrorObserver.
|
||||
* All errors will be printed to the given ostream.
|
||||
**/
|
||||
SimpleErrorObserver::SimpleErrorObserver(ostream& errStream) {
|
||||
this->errStream = &errStream;
|
||||
hideWarnings = MB_FALSE;
|
||||
} //-- SimpleErrorObserver
|
||||
|
||||
/**
|
||||
* Notifies this Error observer of a new error using the given error level
|
||||
**/
|
||||
void SimpleErrorObserver::receiveError(const nsAString& errorMessage,
|
||||
nsresult aRes)
|
||||
{
|
||||
#ifdef TX_EXE
|
||||
if (NS_FAILED(aRes)) {
|
||||
*errStream << "error: ";
|
||||
}
|
||||
|
||||
*errStream << NS_LossyConvertUCS2toASCII(errorMessage).get() << endl;
|
||||
errStream->flush();
|
||||
#endif
|
||||
}
|
||||
|
||||
void SimpleErrorObserver::supressWarnings(MBool supress) {
|
||||
this->hideWarnings = supress;
|
||||
} //-- supressWarnings
|
||||
@@ -1,73 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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
|
||||
* Axel Hecht.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
*
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef TxLog_h__
|
||||
#define TxLog_h__
|
||||
|
||||
#include "prlog.h"
|
||||
#include "prmem.h"
|
||||
#endif
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
class txLog
|
||||
{
|
||||
public:
|
||||
static PRLogModuleInfo *xpath;
|
||||
static PRLogModuleInfo *xslt;
|
||||
};
|
||||
|
||||
#define TX_LG_IMPL \
|
||||
PRLogModuleInfo * txLog::xpath = 0; \
|
||||
PRLogModuleInfo * txLog::xslt = 0
|
||||
|
||||
#define TX_LG_CREATE \
|
||||
txLog::xpath = PR_NewLogModule("xpath"); \
|
||||
txLog::xslt = PR_NewLogModule("xslt")
|
||||
|
||||
#define TX_LG_DELETE \
|
||||
PR_FREEIF(txLog::xpath); \
|
||||
PR_FREEIF(txLog::xslt)
|
||||
|
||||
#else
|
||||
|
||||
#define TX_LG_IMPL
|
||||
#define TX_LG_CREATE
|
||||
#define TX_LG_DELETE
|
||||
|
||||
#endif
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* 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 Keith Visco.
|
||||
* Portions created by Keith Visco (C) 1999, 2000 Keith Visco.
|
||||
* All Rights Reserved..
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TRANSFRMX_TXOBJECT_H
|
||||
#define TRANSFRMX_TXOBJECT_H
|
||||
|
||||
#include "baseutils.h"
|
||||
|
||||
class TxObject {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Creates a new TxObject
|
||||
**/
|
||||
TxObject() {};
|
||||
|
||||
/**
|
||||
* Deletes this TxObject
|
||||
**/
|
||||
virtual ~TxObject() {};
|
||||
|
||||
/**
|
||||
* Returns the Hashcode for this TxObject
|
||||
**/
|
||||
virtual PRUint32 hashCode() {
|
||||
return NS_PTR_TO_INT32(this);
|
||||
} //-- hashCode
|
||||
|
||||
/**
|
||||
* Returns true if the given Object is equal to this object.
|
||||
* By default the comparison operator == is used, but this may
|
||||
* be overridden
|
||||
**/
|
||||
virtual MBool equals(TxObject* obj) {
|
||||
return (MBool)(obj == this);
|
||||
} //-- equals
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* Tom Kneeland, tomk@mitre.org
|
||||
* -- added PRUint32 to provide a common unsigned integer
|
||||
*
|
||||
*/
|
||||
|
||||
// Basic Definitions used throughout many of these classes
|
||||
|
||||
|
||||
#ifndef TRANSFRMX_BASEUTILS_H
|
||||
#define TRANSFRMX_BASEUTILS_H
|
||||
|
||||
#include "prtypes.h"
|
||||
#include "nscore.h"
|
||||
#include "nsDebug.h"
|
||||
typedef PRBool MBool;
|
||||
|
||||
#define MB_TRUE PR_TRUE
|
||||
#define MB_FALSE PR_FALSE
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* Larry Fitzpatrick, OpenText, lef@opentext.com
|
||||
* --
|
||||
*
|
||||
* Eric Du, duxy@leyou.com.cn
|
||||
* -- added fix for FreeBSD
|
||||
*
|
||||
* NaN/Infinity code copied from the JS-library with permission from
|
||||
* Netscape Communications Corporation: http://www.mozilla.org/js
|
||||
* http://lxr.mozilla.org/seamonkey/source/js/src/jsnum.h
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MITRE_PRIMITIVES_H
|
||||
#define MITRE_PRIMITIVES_H
|
||||
|
||||
#include "baseutils.h"
|
||||
class nsAString;
|
||||
|
||||
/*
|
||||
* Utility class for doubles
|
||||
*/
|
||||
class Double {
|
||||
public:
|
||||
|
||||
/*
|
||||
* Usefull constants
|
||||
*/
|
||||
|
||||
static const double NaN;
|
||||
static const double POSITIVE_INFINITY;
|
||||
static const double NEGATIVE_INFINITY;
|
||||
|
||||
/*
|
||||
* Determines whether the given double represents positive or negative
|
||||
* inifinity
|
||||
*/
|
||||
static MBool isInfinite(double aDbl);
|
||||
|
||||
/*
|
||||
* Determines whether the given double is NaN
|
||||
*/
|
||||
static MBool isNaN(double aDbl);
|
||||
|
||||
/*
|
||||
* Determines whether the given double is negative
|
||||
*/
|
||||
static MBool isNeg(double aDbl);
|
||||
|
||||
/*
|
||||
* Converts the value of the given double to a String, and appends
|
||||
* the result to the destination String.
|
||||
*/
|
||||
static void toString(double aValue, nsAString& aDest);
|
||||
|
||||
/*
|
||||
* Converts the given String to a double, if the String value does not
|
||||
* represent a double, NaN will be returned
|
||||
*/
|
||||
static double toDouble(const nsAString& aStr);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,141 +0,0 @@
|
||||
/* -*- 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) nsIAtom* txXMLAtoms::_name = 0
|
||||
XML_ATOMS;
|
||||
#undef TX_ATOM
|
||||
#define TX_ATOM(_name, _value) nsIAtom* txXPathAtoms::_name = 0
|
||||
#include "txXPathAtomList.h"
|
||||
#undef TX_ATOM
|
||||
#define TX_ATOM(_name, _value) nsIAtom* txXSLTAtoms::_name = 0
|
||||
#include "txXSLTAtomList.h"
|
||||
#undef TX_ATOM
|
||||
#define TX_ATOM(_name, _value) nsIAtom* txHTMLAtoms::_name = 0
|
||||
#include "txHTMLAtomList.h"
|
||||
#undef TX_ATOM
|
||||
|
||||
static PRUint32 gXMLRefCnt = 0;
|
||||
static PRUint32 gXPathRefCnt = 0;
|
||||
static PRUint32 gXSLTRefCnt = 0;
|
||||
static PRUint32 gHTMLRefCnt = 0;
|
||||
|
||||
#define TX_ATOM(_name, _value) \
|
||||
_name = NS_NewAtom(_value); \
|
||||
NS_ENSURE_TRUE(_name, MB_FALSE)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
MBool txHTMLAtoms::init()
|
||||
{
|
||||
if (0 == gHTMLRefCnt++) {
|
||||
// create atoms
|
||||
#include "txHTMLAtomList.h"
|
||||
}
|
||||
return MB_TRUE;
|
||||
}
|
||||
|
||||
#undef TX_ATOM
|
||||
|
||||
#define TX_ATOM(_name, _value) \
|
||||
NS_IF_RELEASE(_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"
|
||||
}
|
||||
}
|
||||
|
||||
void txHTMLAtoms::shutdown()
|
||||
{
|
||||
NS_ASSERTION(gHTMLRefCnt != 0, "bad release atoms");
|
||||
if (--gHTMLRefCnt == 0) {
|
||||
// release atoms
|
||||
#include "txHTMLAtomList.h"
|
||||
}
|
||||
}
|
||||
|
||||
#undef TX_ATOM
|
||||
@@ -1,100 +0,0 @@
|
||||
/* -*- 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 "nsIAtom.h"
|
||||
#include "baseutils.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(_empty, ""); \
|
||||
TX_ATOM(base, "base"); \
|
||||
TX_ATOM(_default, "default"); \
|
||||
TX_ATOM(lang, "lang"); \
|
||||
TX_ATOM(preserve, "preserve"); \
|
||||
TX_ATOM(space, "space"); \
|
||||
TX_ATOM(xml, "xml"); \
|
||||
TX_ATOM(xmlns, "xmlns")
|
||||
|
||||
#define TX_ATOM(_name, _value) static nsIAtom* _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"
|
||||
};
|
||||
|
||||
class txHTMLAtoms
|
||||
{
|
||||
public:
|
||||
static MBool init();
|
||||
static void shutdown();
|
||||
#include "txHTMLAtomList.h"
|
||||
};
|
||||
|
||||
#undef TX_ATOM
|
||||
|
||||
#endif
|
||||
@@ -1,84 +0,0 @@
|
||||
/* -*- 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
|
||||
* Axel Hecht.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
*
|
||||
* 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 __TX_ERROR
|
||||
#define __TX_ERROR
|
||||
|
||||
/*
|
||||
* Error value mockup for standalone.
|
||||
* See nsError.h for details.
|
||||
*/
|
||||
|
||||
#include "nsError.h"
|
||||
|
||||
#define NS_ERROR_XPATH_EVAL_FAILED NS_ERROR_FAILURE
|
||||
#define NS_ERROR_XPATH_PARSE_FAILED NS_ERROR_FAILURE
|
||||
#define NS_ERROR_XPATH_INVALID_ARG NS_ERROR_INVALID_ARG
|
||||
#define NS_ERROR_XSLT_INVALID_URL NS_ERROR_INVALID_ARG
|
||||
|
||||
#define NS_ERROR_XSLT_PARSE_FAILURE \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 1)
|
||||
|
||||
#define NS_ERROR_XPATH_PARSE_FAILURE \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 2)
|
||||
|
||||
#define NS_ERROR_XSLT_GET_NEW_HANDLER \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 3)
|
||||
|
||||
#define NS_ERROR_XSLT_ALREADY_SET \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 4)
|
||||
|
||||
#define NS_ERROR_XSLT_EXECUTION_FAILURE \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 5)
|
||||
|
||||
#define NS_ERROR_XPATH_UNKNOWN_FUNCTION \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 6)
|
||||
|
||||
#define NS_ERROR_XSLT_BAD_RECURSION \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 7)
|
||||
|
||||
#define NS_ERROR_XSLT_BAD_VALUE \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 8)
|
||||
|
||||
#define NS_ERROR_XSLT_NODESET_EXPECTED \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 9)
|
||||
|
||||
#define NS_ERROR_XSLT_ABORTED \
|
||||
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 10)
|
||||
|
||||
#endif // __TX_ERROR
|
||||
@@ -1,201 +0,0 @@
|
||||
/* -*- 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) 2002
|
||||
* 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 ***** */
|
||||
|
||||
#include "txExpandedNameMap.h"
|
||||
#include "string.h"
|
||||
|
||||
const int kTxExpandedNameMapAllocSize = 16;
|
||||
|
||||
txExpandedNameMap::txExpandedNameMap(MBool aOwnsValues) :
|
||||
mItems(0), mItemCount(0), mBufferCount(0), mOwnsValues(aOwnsValues)
|
||||
{
|
||||
}
|
||||
|
||||
txExpandedNameMap::~txExpandedNameMap()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an item, if an item with this key already exists an error is
|
||||
* returned
|
||||
* @param aKey key for item to add
|
||||
* @param aValue value of item to add
|
||||
* @return errorcode
|
||||
*/
|
||||
nsresult txExpandedNameMap::add(const txExpandedName& aKey, TxObject* aValue)
|
||||
{
|
||||
int i;
|
||||
// Check if there already is an item with this key
|
||||
for (i = 0; i < mItemCount; ++i) {
|
||||
if (mItems[i].mLocalName == aKey.mLocalName &&
|
||||
mItems[i].mNamespaceID == aKey.mNamespaceID) {
|
||||
return NS_ERROR_XSLT_ALREADY_SET;
|
||||
}
|
||||
}
|
||||
|
||||
// Allocate a new array if needed
|
||||
if (mBufferCount == mItemCount) {
|
||||
MapItem* newItems = new MapItem[mItemCount +
|
||||
kTxExpandedNameMapAllocSize];
|
||||
if (!newItems) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
mBufferCount += kTxExpandedNameMapAllocSize;
|
||||
memcpy(newItems, mItems, mItemCount * sizeof(MapItem));
|
||||
delete [] mItems;
|
||||
mItems = newItems;
|
||||
}
|
||||
|
||||
mItems[mItemCount].mNamespaceID = aKey.mNamespaceID;
|
||||
mItems[mItemCount].mLocalName = aKey.mLocalName;
|
||||
NS_IF_ADDREF(mItems[mItemCount].mLocalName);
|
||||
mItems[mItemCount].mValue = aValue;
|
||||
++mItemCount;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an item, if an item with this key already exists it is overwritten
|
||||
* with the new value
|
||||
* @param aKey key for item to set
|
||||
* @param aValue value of item to set
|
||||
* @return errorcode
|
||||
*/
|
||||
nsresult txExpandedNameMap::set(const txExpandedName& aKey, TxObject* aValue)
|
||||
{
|
||||
int i;
|
||||
// Check if there already is an item with this key
|
||||
for (i = 0; i < mItemCount; ++i) {
|
||||
if (mItems[i].mLocalName == aKey.mLocalName &&
|
||||
mItems[i].mNamespaceID == aKey.mNamespaceID) {
|
||||
if (mOwnsValues) {
|
||||
delete mItems[i].mValue;
|
||||
}
|
||||
mItems[i].mValue = aValue;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Allocate a new array if needed
|
||||
if (mBufferCount == mItemCount) {
|
||||
MapItem* newItems = new MapItem[mItemCount +
|
||||
kTxExpandedNameMapAllocSize];
|
||||
if (!newItems) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
mBufferCount += kTxExpandedNameMapAllocSize;
|
||||
memcpy(newItems, mItems, mItemCount * sizeof(MapItem));
|
||||
delete [] mItems;
|
||||
mItems = newItems;
|
||||
}
|
||||
|
||||
mItems[mItemCount].mNamespaceID = aKey.mNamespaceID;
|
||||
mItems[mItemCount].mLocalName = aKey.mLocalName;
|
||||
NS_IF_ADDREF(mItems[mItemCount].mLocalName);
|
||||
mItems[mItemCount].mValue = aValue;
|
||||
++mItemCount;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an item
|
||||
* @param aKey key for item to get
|
||||
* @return item with specified key, or null if no such item exists
|
||||
*/
|
||||
TxObject* txExpandedNameMap::get(const txExpandedName& aKey) const
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < mItemCount; ++i) {
|
||||
if (mItems[i].mLocalName == aKey.mLocalName &&
|
||||
mItems[i].mNamespaceID == aKey.mNamespaceID) {
|
||||
return mItems[i].mValue;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an item, deleting it if the map owns the values
|
||||
* @param aKey key for item to remove
|
||||
* @return item with specified key, or null if it has been deleted
|
||||
* or no such item exists
|
||||
*/
|
||||
TxObject* txExpandedNameMap::remove(const txExpandedName& aKey)
|
||||
{
|
||||
TxObject* value = 0;
|
||||
int i;
|
||||
for (i = 0; i < mItemCount; ++i) {
|
||||
if (mItems[i].mLocalName == aKey.mLocalName &&
|
||||
mItems[i].mNamespaceID == aKey.mNamespaceID) {
|
||||
NS_IF_RELEASE(mItems[i].mLocalName);
|
||||
if (mOwnsValues) {
|
||||
delete mItems[i].mValue;
|
||||
}
|
||||
else {
|
||||
value = mItems[i].mValue;
|
||||
}
|
||||
--mItemCount;
|
||||
if (i != mItemCount) {
|
||||
memcpy(&mItems[i], &mItems[mItemCount], sizeof(MapItem));
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the items
|
||||
*/
|
||||
void txExpandedNameMap::clear()
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < mItemCount; ++i) {
|
||||
NS_IF_RELEASE(mItems[i].mLocalName);
|
||||
if (mOwnsValues) {
|
||||
delete mItems[i].mValue;
|
||||
}
|
||||
}
|
||||
delete [] mItems;
|
||||
mItemCount = 0;
|
||||
mBufferCount = 0;
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
/* -*- 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) 2002
|
||||
* 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 ***** */
|
||||
|
||||
#ifndef TRANSFRMX_EXPANDEDNAMEMAP_H
|
||||
#define TRANSFRMX_EXPANDEDNAMEMAP_H
|
||||
|
||||
#include "txError.h"
|
||||
#include "XMLUtils.h"
|
||||
|
||||
class TxObject;
|
||||
|
||||
class txExpandedNameMap {
|
||||
public:
|
||||
txExpandedNameMap(MBool aOwnsValues);
|
||||
|
||||
~txExpandedNameMap();
|
||||
|
||||
/**
|
||||
* Adds an item, if an item with this key already exists an error is
|
||||
* returned
|
||||
* @param aKey key for item to add
|
||||
* @param aValue value of item to add
|
||||
* @return errorcode
|
||||
*/
|
||||
nsresult add(const txExpandedName& aKey, TxObject* aValue);
|
||||
|
||||
/**
|
||||
* Sets an item, if an item with this key already exists it is overwritten
|
||||
* with the new value
|
||||
* @param aKey key for item to set
|
||||
* @param aValue value of item to set
|
||||
* @return errorcode
|
||||
*/
|
||||
nsresult set(const txExpandedName& aKey, TxObject* aValue);
|
||||
|
||||
/**
|
||||
* Gets an item
|
||||
* @param aKey key for item to get
|
||||
* @return item with specified key, or null if no such item exists
|
||||
*/
|
||||
TxObject* get(const txExpandedName& aKey) const;
|
||||
|
||||
/**
|
||||
* Removes an item, deleting it if the map owns the values
|
||||
* @param aKey key for item to remove
|
||||
* @return item with specified key, or null if it has been deleted
|
||||
* or no such item exists
|
||||
*/
|
||||
TxObject* remove(const txExpandedName& aKey);
|
||||
|
||||
/**
|
||||
* Clears the items
|
||||
*/
|
||||
void clear();
|
||||
|
||||
class iterator {
|
||||
public:
|
||||
iterator(txExpandedNameMap& aMap) : mMap(aMap),
|
||||
mCurrentPos(-1)
|
||||
{
|
||||
}
|
||||
|
||||
MBool next()
|
||||
{
|
||||
return ++mCurrentPos < mMap.mItemCount;
|
||||
}
|
||||
|
||||
const txExpandedName key()
|
||||
{
|
||||
NS_ASSERTION(mCurrentPos >= 0 && mCurrentPos < mMap.mItemCount,
|
||||
"invalid position in txExpandedNameMap::iterator");
|
||||
return txExpandedName(mMap.mItems[mCurrentPos].mNamespaceID,
|
||||
mMap.mItems[mCurrentPos].mLocalName);
|
||||
}
|
||||
|
||||
TxObject* value()
|
||||
{
|
||||
NS_ASSERTION(mCurrentPos >= 0 && mCurrentPos < mMap.mItemCount,
|
||||
"invalid position in txExpandedNameMap::iterator");
|
||||
return mMap.mItems[mCurrentPos].mValue;
|
||||
}
|
||||
|
||||
private:
|
||||
txExpandedNameMap& mMap;
|
||||
int mCurrentPos;
|
||||
};
|
||||
|
||||
friend class iterator;
|
||||
|
||||
private:
|
||||
struct MapItem {
|
||||
PRInt32 mNamespaceID;
|
||||
nsIAtom* mLocalName;
|
||||
TxObject* mValue;
|
||||
};
|
||||
|
||||
MapItem* mItems;
|
||||
int mItemCount, mBufferCount;
|
||||
MBool mOwnsValues;
|
||||
};
|
||||
|
||||
#endif //TRANSFRMX_EXPANDEDNAMEMAP_H
|
||||
@@ -1,131 +0,0 @@
|
||||
/* -*- 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) 2002
|
||||
* Jonas Sicking. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Jonas Sicking <jonas@sicking.cc>
|
||||
*
|
||||
* 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 "txNamespaceMap.h"
|
||||
#include "dom.h"
|
||||
#include "txAtoms.h"
|
||||
|
||||
txNamespaceMap::txNamespaceMap()
|
||||
{
|
||||
}
|
||||
|
||||
txNamespaceMap::txNamespaceMap(const txNamespaceMap& aOther)
|
||||
: mPrefixes(aOther.mPrefixes)
|
||||
{
|
||||
mNamespaces = aOther.mNamespaces; //bah! I want a copy-constructor!
|
||||
}
|
||||
|
||||
nsresult
|
||||
txNamespaceMap::addNamespace(nsIAtom* aPrefix, const nsAString& aNamespaceURI)
|
||||
{
|
||||
nsIAtom* prefix = aPrefix == txXMLAtoms::_empty ? 0 : aPrefix;
|
||||
|
||||
PRInt32 nsId;
|
||||
if (!prefix && aNamespaceURI.IsEmpty()) {
|
||||
nsId = kNameSpaceID_None;
|
||||
}
|
||||
else {
|
||||
#ifdef TX_EXE
|
||||
nsId = txNamespaceManager::getNamespaceID(aNamespaceURI);
|
||||
#else
|
||||
NS_ASSERTION(gTxNameSpaceManager, "No namespace manager");
|
||||
gTxNameSpaceManager->RegisterNameSpace(aNamespaceURI, nsId);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Check if the mapping already exists
|
||||
PRInt32 index = mPrefixes.IndexOf(prefix);
|
||||
if (index >= 0) {
|
||||
mNamespaces.ReplaceElementAt(NS_INT32_TO_PTR(nsId), index);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// New mapping
|
||||
if (!mPrefixes.AppendObject(prefix)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (!mNamespaces.AppendElement(NS_INT32_TO_PTR(nsId))) {
|
||||
mPrefixes.RemoveObjectAt(mPrefixes.Count() - 1);
|
||||
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
txNamespaceMap::lookupNamespace(nsIAtom* aPrefix)
|
||||
{
|
||||
if (aPrefix == txXMLAtoms::xml) {
|
||||
return kNameSpaceID_XML;
|
||||
}
|
||||
|
||||
nsIAtom* prefix = aPrefix == txXMLAtoms::_empty ? 0 : aPrefix;
|
||||
|
||||
PRInt32 index = mPrefixes.IndexOf(prefix);
|
||||
if (index >= 0) {
|
||||
return NS_PTR_TO_INT32(mNamespaces.SafeElementAt(index));
|
||||
}
|
||||
|
||||
if (!prefix) {
|
||||
return kNameSpaceID_None;
|
||||
}
|
||||
|
||||
return kNameSpaceID_Unknown;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
txNamespaceMap::lookupNamespace(const nsAString& aPrefix)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> prefix = do_GetAtom(aPrefix);
|
||||
|
||||
return lookupNamespace(prefix);
|
||||
}
|
||||
|
||||
PRInt32
|
||||
txNamespaceMap::lookupNamespaceWithDefault(const nsAString& aPrefix)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> prefix = do_GetAtom(aPrefix);
|
||||
if (prefix != txXSLTAtoms::_poundDefault) {
|
||||
return lookupNamespace(prefix);
|
||||
}
|
||||
|
||||
return lookupNamespace(nsnull);
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/* -*- 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) 2002
|
||||
* 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 ***** */
|
||||
|
||||
#ifndef TRANSFRMX_TXNAMESPACEMAP_H
|
||||
#define TRANSFRMX_TXNAMESPACEMAP_H
|
||||
|
||||
#include "txError.h"
|
||||
#include "baseutils.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsCOMArray.h"
|
||||
|
||||
class txNamespaceMap
|
||||
{
|
||||
public:
|
||||
txNamespaceMap();
|
||||
txNamespaceMap(const txNamespaceMap& aOther);
|
||||
|
||||
nsrefcnt AddRef()
|
||||
{
|
||||
return ++mRefCnt;
|
||||
}
|
||||
nsrefcnt Release()
|
||||
{
|
||||
if (--mRefCnt == 0) {
|
||||
mRefCnt = 1; //stabilize
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
nsresult addNamespace(nsIAtom* aPrefix, const nsAString& aNamespaceURI);
|
||||
PRInt32 lookupNamespace(nsIAtom* aPrefix);
|
||||
PRInt32 lookupNamespace(const nsAString& aPrefix);
|
||||
PRInt32 lookupNamespaceWithDefault(const nsAString& aPrefix);
|
||||
|
||||
private:
|
||||
nsAutoRefCnt mRefCnt;
|
||||
nsCOMArray<nsIAtom> mPrefixes;
|
||||
nsVoidArray mNamespaces;
|
||||
};
|
||||
|
||||
#endif //TRANSFRMX_TXNAMESPACEMAP_H
|
||||
@@ -1,154 +0,0 @@
|
||||
//* -*- 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;
|
||||
PRInt32 mPosition;
|
||||
};
|
||||
|
||||
#endif /* txStack_h___ */
|
||||
@@ -1,153 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** 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):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
* 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 "txStringUtils.h"
|
||||
|
||||
int
|
||||
txCaseInsensitiveStringComparator::operator()(const char_type* lhs,
|
||||
const char_type* rhs,
|
||||
PRUint32 aLength ) const
|
||||
{
|
||||
PRUnichar thisChar, otherChar;
|
||||
PRUint32 compLoop = 0;
|
||||
while (compLoop < aLength) {
|
||||
thisChar = lhs[compLoop];
|
||||
if ((thisChar >= 'A') && (thisChar <= 'Z')) {
|
||||
thisChar += 32;
|
||||
}
|
||||
otherChar = rhs[compLoop];
|
||||
if ((otherChar >= 'A') && (otherChar <= 'Z')) {
|
||||
otherChar += 32;
|
||||
}
|
||||
if (thisChar != otherChar) {
|
||||
return thisChar - otherChar;
|
||||
}
|
||||
++compLoop;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
txCaseInsensitiveStringComparator::operator()(char_type lhs,
|
||||
char_type rhs) const
|
||||
{
|
||||
if (lhs >= 'A' && lhs <= 'Z') {
|
||||
lhs += 32;
|
||||
}
|
||||
if (rhs >= 'A' && rhs <= 'Z') {
|
||||
rhs += 32;
|
||||
}
|
||||
return lhs - rhs;
|
||||
}
|
||||
|
||||
/**
|
||||
* A character sink for case conversion.
|
||||
*/
|
||||
class ConvertToLowerCase
|
||||
{
|
||||
public:
|
||||
typedef PRUnichar value_type;
|
||||
|
||||
PRUint32 write( const PRUnichar* aSource, PRUint32 aSourceLength)
|
||||
{
|
||||
PRUnichar* cp = NS_CONST_CAST(PRUnichar*, aSource);
|
||||
const PRUnichar* end = aSource + aSourceLength;
|
||||
while (cp != end) {
|
||||
PRUnichar ch = *cp;
|
||||
if ((ch >= 'A') && (ch <= 'Z'))
|
||||
*cp = ch + ('a' - 'A');
|
||||
++cp;
|
||||
}
|
||||
return aSourceLength;
|
||||
}
|
||||
};
|
||||
|
||||
void TX_ToLowerCase(nsAString& aString)
|
||||
{
|
||||
nsAString::iterator fromBegin, fromEnd;
|
||||
ConvertToLowerCase converter;
|
||||
copy_string(aString.BeginWriting(fromBegin), aString.EndWriting(fromEnd),
|
||||
converter);
|
||||
}
|
||||
|
||||
/**
|
||||
* A character sink for copying with case conversion.
|
||||
*/
|
||||
class CopyToLowerCase
|
||||
{
|
||||
public:
|
||||
typedef PRUnichar value_type;
|
||||
|
||||
CopyToLowerCase(nsAString::iterator& aDestIter) : mIter(aDestIter)
|
||||
{
|
||||
}
|
||||
|
||||
PRUint32 write(const PRUnichar* aSource, PRUint32 aSourceLength)
|
||||
{
|
||||
PRUint32 len = PR_MIN(PRUint32(mIter.size_forward()), aSourceLength);
|
||||
PRUnichar* cp = mIter.get();
|
||||
const PRUnichar* end = aSource + len;
|
||||
while (aSource != end) {
|
||||
PRUnichar ch = *aSource;
|
||||
if ((ch >= 'A') && (ch <= 'Z'))
|
||||
*cp = ch + ('a' - 'A');
|
||||
else
|
||||
*cp = ch;
|
||||
++aSource;
|
||||
++cp;
|
||||
}
|
||||
mIter.advance(len);
|
||||
return len;
|
||||
}
|
||||
|
||||
protected:
|
||||
nsAString::iterator& mIter;
|
||||
};
|
||||
|
||||
void TX_ToLowerCase(const nsAString& aSource, nsAString& aDest)
|
||||
{
|
||||
nsAString::const_iterator fromBegin, fromEnd;
|
||||
nsAString::iterator toBegin;
|
||||
aDest.SetLength(aSource.Length());
|
||||
CopyToLowerCase converter(aDest.BeginWriting(toBegin));
|
||||
copy_string(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd),
|
||||
converter);
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** 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):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
* 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 txStringUtils_h__
|
||||
#define txStringUtils_h__
|
||||
|
||||
#include "nsAString.h"
|
||||
#include "nsIAtom.h"
|
||||
|
||||
#ifndef TX_EXE
|
||||
|
||||
#include "nsUnicharUtils.h"
|
||||
typedef nsCaseInsensitiveStringComparator txCaseInsensitiveStringComparator;
|
||||
|
||||
#define TX_ToLowerCase ToLowerCase
|
||||
|
||||
#else
|
||||
|
||||
// These only work for ASCII ranges!
|
||||
|
||||
class txCaseInsensitiveStringComparator
|
||||
: public nsStringComparator
|
||||
{
|
||||
public:
|
||||
virtual int operator()(const char_type*, const char_type*, PRUint32 aLength) const;
|
||||
virtual int operator()(char_type, char_type) const;
|
||||
};
|
||||
|
||||
void TX_ToLowerCase(nsAString& aString);
|
||||
void TX_ToLowerCase(const nsAString& aSource, nsAString& aDest);
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Check equality between a string and an atom.
|
||||
*/
|
||||
static PRBool TX_StringEqualsAtom(const nsAString& aString, nsIAtom* aAtom)
|
||||
{
|
||||
const PRUnichar* atom;
|
||||
aAtom->GetUnicode(&atom);
|
||||
return aString.Equals(atom);
|
||||
};
|
||||
|
||||
#endif // txStringUtils_h__
|
||||
@@ -1,91 +0,0 @@
|
||||
/* -*- 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 txTokenizer_h___
|
||||
#define txTokenizer_h___
|
||||
|
||||
#include "nsDependentSubstring.h"
|
||||
#include "XMLUtils.h"
|
||||
|
||||
class txTokenizer
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Creates a new txTokenizer using the given source string.
|
||||
*/
|
||||
txTokenizer(const nsAFlatString& aSource)
|
||||
{
|
||||
aSource.BeginReading(mIter);
|
||||
aSource.EndReading(mEnd);
|
||||
|
||||
while (mIter != mEnd && XMLUtils::isWhitespace(*mIter)) {
|
||||
++mIter;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if any more tokens are available.
|
||||
*/
|
||||
PRBool hasMoreTokens()
|
||||
{
|
||||
return (mIter != mEnd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next token.
|
||||
*/
|
||||
const nsDependentSingleFragmentSubstring nextToken()
|
||||
{
|
||||
nsAFlatString::const_char_iterator begin = mIter;
|
||||
while (mIter != mEnd && !XMLUtils::isWhitespace(*mIter)) {
|
||||
++mIter;
|
||||
}
|
||||
nsAFlatString::const_char_iterator end = mIter;
|
||||
while (mIter != mEnd && XMLUtils::isWhitespace(*mIter)) {
|
||||
++mIter;
|
||||
}
|
||||
return Substring(begin, end);
|
||||
}
|
||||
|
||||
private:
|
||||
nsAFlatString::const_char_iterator mIter, mEnd;
|
||||
};
|
||||
|
||||
#endif /* txTokenizer_h___ */
|
||||
|
||||
@@ -1,228 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
* Larry Fitzpatrick, OpenText, lef@opentext.com
|
||||
* -- 19990806
|
||||
* -- moved initialization of constant shorts and chars from
|
||||
* URIUtils.cpp to here
|
||||
*
|
||||
* Peter Van der Beken
|
||||
*
|
||||
*/
|
||||
|
||||
#include "txURIUtils.h"
|
||||
|
||||
#ifndef TX_EXE
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIAttribute.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsINodeInfo.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* URIUtils
|
||||
* A set of utilities for handling URIs
|
||||
**/
|
||||
|
||||
#ifdef TX_EXE
|
||||
//- Constants -/
|
||||
|
||||
const char URIUtils::HREF_PATH_SEP = '/';
|
||||
|
||||
/**
|
||||
* Returns an InputStream for the file represented by the href
|
||||
* argument
|
||||
* @param href the href of the file to get the input stream for.
|
||||
* @return an InputStream to the desired resource
|
||||
* @exception java.io.FileNotFoundException when the file could not be
|
||||
* found
|
||||
**/
|
||||
istream* URIUtils::getInputStream(const nsAString& href, nsAString& errMsg)
|
||||
{
|
||||
return new ifstream(NS_LossyConvertUCS2toASCII(href).get(), ios::in);
|
||||
} //-- getInputStream
|
||||
|
||||
/**
|
||||
* Returns the document base of the href argument
|
||||
* @return the document base of the given href
|
||||
**/
|
||||
void URIUtils::getDocumentBase(const nsAFlatString& href, nsAString& dest)
|
||||
{
|
||||
if (href.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsAFlatString::const_char_iterator temp;
|
||||
href.BeginReading(temp);
|
||||
PRUint32 iter = href.Length();
|
||||
while (iter > 0) {
|
||||
if (temp[--iter] == HREF_PATH_SEP) {
|
||||
dest.Append(Substring(href, 0, iter));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Resolves the given href argument, using the given documentBase
|
||||
* if necessary.
|
||||
* The new resolved href will be appended to the given dest String
|
||||
**/
|
||||
void URIUtils::resolveHref(const nsAString& href, const nsAString& base,
|
||||
nsAString& dest) {
|
||||
if (base.IsEmpty()) {
|
||||
dest.Append(href);
|
||||
return;
|
||||
}
|
||||
if (href.IsEmpty()) {
|
||||
dest.Append(base);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef TX_EXE
|
||||
nsCOMPtr<nsIURI> pURL;
|
||||
nsAutoString resultHref;
|
||||
nsresult result = NS_NewURI(getter_AddRefs(pURL), base);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
NS_MakeAbsoluteURI(resultHref, href, pURL);
|
||||
dest.Append(resultHref);
|
||||
}
|
||||
#else
|
||||
nsAutoString documentBase;
|
||||
getDocumentBase(PromiseFlatString(base), documentBase);
|
||||
|
||||
//-- join document base + href
|
||||
if (!documentBase.IsEmpty()) {
|
||||
dest.Append(documentBase);
|
||||
if (documentBase.CharAt(documentBase.Length()-1) != HREF_PATH_SEP)
|
||||
dest.Append(PRUnichar(HREF_PATH_SEP));
|
||||
}
|
||||
dest.Append(href);
|
||||
|
||||
#endif
|
||||
} //-- resolveHref
|
||||
|
||||
#ifndef TX_EXE
|
||||
|
||||
nsIScriptSecurityManager *gTxSecurityManager = 0;
|
||||
|
||||
// static
|
||||
PRBool URIUtils::CanCallerAccess(nsIDOMNode *aNode)
|
||||
{
|
||||
if (!gTxSecurityManager) {
|
||||
// No security manager available, let any calls go through...
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> subjectPrincipal;
|
||||
gTxSecurityManager->GetSubjectPrincipal(getter_AddRefs(subjectPrincipal));
|
||||
|
||||
if (!subjectPrincipal) {
|
||||
// we're running as system, grant access to the node.
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// Make sure that this is a real node. We do this by first QI'ing to
|
||||
// nsIContent (which is important performance wise) and if that QI
|
||||
// fails we QI to nsIDocument. If both those QI's fail we won't let
|
||||
// the caller access this unknown node.
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
||||
nsCOMPtr<nsIAttribute> attr;
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
|
||||
if (!content) {
|
||||
doc = do_QueryInterface(aNode);
|
||||
|
||||
if (!doc) {
|
||||
attr = do_QueryInterface(aNode);
|
||||
if (!attr) {
|
||||
// aNode is not a nsIContent, a nsIAttribute or a nsIDocument,
|
||||
// something weird is going on...
|
||||
|
||||
NS_ERROR("aNode is not a nsIContent, a nsIAttribute or a nsIDocument!");
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!doc) {
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
aNode->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
if (!domDoc) {
|
||||
nsCOMPtr<nsINodeInfo> ni;
|
||||
if (content) {
|
||||
content->GetNodeInfo(*getter_AddRefs(ni));
|
||||
}
|
||||
else {
|
||||
attr->GetNodeInfo(*getter_AddRefs(ni));
|
||||
}
|
||||
|
||||
if (!ni) {
|
||||
// aNode is not part of a document, let any caller access it.
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
ni->GetDocumentPrincipal(getter_AddRefs(principal));
|
||||
|
||||
if (!principal) {
|
||||
// we can't get to the principal so we'll give up and give the
|
||||
// caller access
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
doc = do_QueryInterface(domDoc);
|
||||
NS_ASSERTION(doc, "QI to nsIDocument failed");
|
||||
}
|
||||
}
|
||||
|
||||
if (!principal) {
|
||||
doc->GetPrincipal(getter_AddRefs(principal));
|
||||
}
|
||||
|
||||
if (!principal) {
|
||||
// We can't get hold of the principal for this node. This should happen
|
||||
// very rarely, like for textnodes out of the tree and <option>s created
|
||||
// using 'new Option'.
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsresult rv = gTxSecurityManager->CheckSameOriginPrincipal(subjectPrincipal,
|
||||
principal);
|
||||
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
||||
#endif /* TX_EXE */
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* Larry Fitzpatrick, OpenText, lef@opentext.com
|
||||
* -- 19990806
|
||||
* -- moved initialization of constant shorts and chars to
|
||||
* URIUtils.cpp
|
||||
*
|
||||
* Peter Van der Beken
|
||||
* -- 20000326
|
||||
* -- added Mozilla integration code
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TRANSFRMX_URIUTILS_H
|
||||
#define TRANSFRMX_URIUTILS_H
|
||||
|
||||
#include "baseutils.h"
|
||||
#ifdef TX_EXE
|
||||
#include <fstream.h>
|
||||
#include <iostream.h>
|
||||
#include "nsString.h"
|
||||
#else
|
||||
#include "nsIDOMNode.h"
|
||||
|
||||
class nsIScriptSecurityManager;
|
||||
extern nsIScriptSecurityManager *gTxSecurityManager;
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A utility class for URI handling
|
||||
* Not yet finished, only handles file URI at this point
|
||||
**/
|
||||
|
||||
class URIUtils {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
#ifdef TX_EXE
|
||||
/**
|
||||
* the path separator for an URI
|
||||
**/
|
||||
static const char HREF_PATH_SEP;
|
||||
|
||||
static istream* getInputStream
|
||||
(const nsAString& href, nsAString& errMsg);
|
||||
|
||||
/**
|
||||
* Returns the document base of the href argument
|
||||
* The document base will be appended to the given dest String
|
||||
**/
|
||||
static void getDocumentBase(const nsAFlatString& href, nsAString& dest);
|
||||
|
||||
#else /* TX_EXE */
|
||||
|
||||
/*
|
||||
* Checks if a caller is allowed to access a given node
|
||||
*/
|
||||
static PRBool CanCallerAccess(nsIDOMNode *aNode);
|
||||
|
||||
#endif /* TX_EXE */
|
||||
|
||||
/**
|
||||
* Resolves the given href argument, using the given documentBase
|
||||
* if necessary.
|
||||
* The new resolved href will be appended to the given dest String
|
||||
**/
|
||||
static void resolveHref(const nsAString& href, const nsAString& base,
|
||||
nsAString& dest);
|
||||
}; //-- URIUtils
|
||||
|
||||
/* */
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/xsl" href="functions.xsl"?>
|
||||
<!-- this is a test document -->
|
||||
<document>
|
||||
<!-- test comment -->
|
||||
<x name="x">x</x>
|
||||
<y name="y">y</y>
|
||||
<z name="z">z</z>
|
||||
<names xmlns:abc="foo">
|
||||
<abc:test-name/>
|
||||
</names>
|
||||
</document>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/xsl" href="identity.xsl"?>
|
||||
<document>
|
||||
|
||||
<x name="x">x</x>
|
||||
<y name="y">y</y>
|
||||
<z name="z">z</z>
|
||||
</document>
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/xsl" href="identity.xsl"?>
|
||||
<!-- this is a test document -->
|
||||
<document>
|
||||
<!-- test comment -->
|
||||
<x name="x">x</x>
|
||||
<y name="y">y</y>
|
||||
<z name="z">z</z>
|
||||
</document>
|
||||
@@ -1,44 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a test stylesheet used for testing MITRE's XSL processor
|
||||
**/
|
||||
-->
|
||||
<xsl:stylesheet
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
version="1.0">
|
||||
|
||||
<!-- root rule -->
|
||||
<xsl:template match="/">
|
||||
<xsl:apply-templates select="node()"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@* | node()">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@* | node()"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a test stylesheet used for testing MITRE's XSL processor
|
||||
**/
|
||||
-->
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
<!-- match document element -->
|
||||
<xsl:template match="document">
|
||||
This rule comes from an included xsl:stylesheet!
|
||||
<BR/>
|
||||
<B>
|
||||
<xsl:apply-templates/>
|
||||
</B>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -1,12 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>TransforMiiX include test</TITLE>
|
||||
</HEAD>
|
||||
<BODY>This rule comes from an included xsl:stylesheet!<BR>
|
||||
<B>
|
||||
This is a simple test document for TransforMiiX.
|
||||
</B>
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/xsl" href="include.xsl"?>
|
||||
<!-- this is a test document -->
|
||||
<document>
|
||||
This is a simple test document for TransforMiiX.
|
||||
</document>
|
||||
@@ -1,49 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a test stylesheet used for testing MITRE's XSL processor
|
||||
**/
|
||||
-->
|
||||
<xsl:stylesheet
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
indent-result="yes"
|
||||
result-ns="http://www.w3.org/1999/xhtml"
|
||||
version="1.0">
|
||||
|
||||
<xsl:include href="include-helper.xsl"/>
|
||||
|
||||
<!-- root rule -->
|
||||
<xsl:template match="/">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>TransforMiiX include test</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<xsl:apply-templates/>
|
||||
</BODY>
|
||||
</HTML>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>A simple sorting example</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<P ALIGN="CENTER">
|
||||
<B>
|
||||
<FONT SIZE="+2">A simple sorting example</FONT>
|
||||
<HR SIZE="1">
|
||||
</B>
|
||||
</P>
|
||||
<TABLE BORDER="0">
|
||||
<TR>
|
||||
<TD>Sorting in ascending order</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<OL>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<LI>Dream Theatre</LI>
|
||||
<LI>Gilbert, Paul</LI>
|
||||
<LI>Royal Hunt</LI>
|
||||
<LI>Satriani, Joe</LI>
|
||||
</OL>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>Sorting in descending order</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<OL>
|
||||
<LI>Satriani, Joe</LI>
|
||||
<LI>Royal Hunt</LI>
|
||||
<LI>Gilbert, Paul</LI>
|
||||
<LI>Dream Theatre</LI>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</OL>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="sort.xsl" type="text/xsl"?>
|
||||
<!--
|
||||
This is a sample XML document supplied with TransforMiiX
|
||||
author: Keith Visco, kvisc@ziplink.net
|
||||
-->
|
||||
<sort>
|
||||
|
||||
<entry>Satriani, Joe</entry>
|
||||
<entry>Dream Theatre</entry>
|
||||
<entry>Royal Hunt</entry>
|
||||
<entry>Gilbert, Paul</entry>
|
||||
|
||||
</sort>
|
||||
@@ -1,60 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<xsl:stylesheet
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
<!-- for read-ability use HTML output and enable indenting -->
|
||||
<xsl:output method="html" indent="yes"/>
|
||||
|
||||
<!-- matches document node -->
|
||||
<xsl:template match="/">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>A simple sorting example</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<P ALIGN="CENTER">
|
||||
<B>
|
||||
<FONT SIZE="+2">A simple sorting example</FONT>
|
||||
<HR SIZE="1"/>
|
||||
</B>
|
||||
</P>
|
||||
<!-- select and apply templates to remaining document -->
|
||||
<xsl:apply-templates/>
|
||||
</BODY>
|
||||
</HTML>
|
||||
</xsl:template>
|
||||
|
||||
<!-- matches root element -->
|
||||
<xsl:template match="/*">
|
||||
<TABLE BORDER="0">
|
||||
<TR><TD>Sorting in ascending order</TD></TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<OL>
|
||||
<xsl:apply-templates>
|
||||
<!-- sort using the value of the selected node -->
|
||||
<xsl:sort select="."/>
|
||||
</xsl:apply-templates>
|
||||
</OL>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR><TD>Sorting in descending order</TD></TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<OL>
|
||||
<xsl:apply-templates>
|
||||
<!-- sort using the value of the selected node -->
|
||||
<xsl:sort select="." order="descending"/>
|
||||
</xsl:apply-templates>
|
||||
</OL>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</xsl:template>
|
||||
|
||||
<!-- matches only entry elements -->
|
||||
<xsl:template match="entry">
|
||||
<LI><xsl:apply-templates/></LI>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
@@ -1,746 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<?foo this is a test processing instruction?>
|
||||
<!-- TransforMiiX Test cases, written by Keith Visco. -->
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>TransforMiiX Test Cases</TITLE>
|
||||
<SCRIPT Language="JavaScript">
|
||||
|
||||
// This is a test for properly printing SCRIPT elements
|
||||
// currently there is a bug, so use xsl:text as a wrapper as I
|
||||
// have done here
|
||||
function foo() {
|
||||
var x = 1;
|
||||
var y = 2;
|
||||
return (x < y);
|
||||
}
|
||||
//
|
||||
|
||||
</SCRIPT>
|
||||
</HEAD>
|
||||
<BODY BGColor="#FFFFFF" Text="#000000">
|
||||
<CENTER>
|
||||
<FONT COLOR="BLUE" FACE="Arial" SIZE="+1">
|
||||
<B>Mozilla XSLT</B>
|
||||
</FONT>
|
||||
<BR>
|
||||
<B>Transfor<FONT COLOR="blue">Mii</FONT>X Test Cases</B>
|
||||
</CENTER>
|
||||
<P>This document serves to test basic XSL expressions.</P>
|
||||
<P>
|
||||
<B>Testing xsl:variable and xsl:copy-of</B>
|
||||
<BR>
|
||||
<B>Test:</B><xsl:copy-of select="$product-name"/><BR>
|
||||
<B>Desired Result:</B>Transfor<FONT COLOR="blue">Mii</FONT>X<BR>
|
||||
<B>Result:</B>Transfor<FONT COLOR="blue">Mii</FONT>X</P>
|
||||
<P>
|
||||
<B>Testing xsl:if</B>
|
||||
<BR>
|
||||
<B>Test:</B><xsl:if test="x | y | z">true</xsl:if><BR>
|
||||
<B>Desired Result:</B>true<BR>
|
||||
<B>Result:</B>true</P>
|
||||
<P>
|
||||
<B>Testing xsl:if</B>
|
||||
<BR>
|
||||
<B>Test:</B><xsl:if test="true()">true</xsl:if><BR>
|
||||
<B>Desired Result:</B>true<BR>
|
||||
<B>Result:</B>true</P>
|
||||
<P>
|
||||
<B>Testing xsl:if</B>
|
||||
<BR>
|
||||
<B>Test:</B><xsl:if test="'a'='b'">a equals b</xsl:if><BR>
|
||||
<B></B><xsl:if test="'a'!='b'">a does not equal b</xsl:if><BR>
|
||||
<B>Desired Result:</B>a does not equal to b<BR>
|
||||
<B>Result:</B>a does not equal b</P>
|
||||
<P>
|
||||
<B>Testing xsl:if</B>
|
||||
<BR>
|
||||
<B>Test:</B><xsl:if test="2+1-3">2+1-3 is true</xsl:if><BR>
|
||||
<B> </B><xsl:if test="not(2+1-3)">not(2+1-3) is true</xsl:if><BR>
|
||||
<B>Desired Result:</B>not(2+1-3) is true<BR>
|
||||
<B>Result:</B>not(2+1-3) is true</P>
|
||||
<P>
|
||||
<B>Testing xsl:choose</B>
|
||||
<BR>
|
||||
<B>Test:</B>see source<BR>
|
||||
<B>Desired Result:</B>true<BR>
|
||||
<B>Result:</B>true</P>
|
||||
<P>
|
||||
<B>Testing parent and ancestor ops</B>
|
||||
<BR>
|
||||
<B>Test:</B>see source<BR>
|
||||
<B>Desired Result:</B>true<BR>
|
||||
<B>Result:</B>true<BR>
|
||||
</P>
|
||||
<P>
|
||||
<B>Testing basic xsl:apply-templates</B>
|
||||
<BR>
|
||||
<B>Test:</B><xsl:apply-templates/><BR>
|
||||
<B>Desired Result:</B>element x, element y, element z<BR>
|
||||
<B>Result:</B>
|
||||
|
||||
,element<B> x</B>
|
||||
,element<B> y</B>
|
||||
,element<B> z</B>
|
||||
|
||||
|
||||
</P>
|
||||
<P>
|
||||
<B>Testing basic xsl:apply-templates with mode</B>
|
||||
<BR>
|
||||
<B>Test:</B><xsl:apply-templates mode="mode-test"/><BR>
|
||||
<B>Desired Result:</B>x, y, z<BR>
|
||||
<B>Result:</B>, x, y, z</P>
|
||||
<P>
|
||||
<B>Testing predicates</B>
|
||||
<BR>
|
||||
<B>Test:</B>see source<BR>
|
||||
<B>Desired Result:</B>
|
||||
<B>z</B>
|
||||
<BR>
|
||||
<B>Result:</B>
|
||||
<B>z</B>
|
||||
</P>
|
||||
<P>
|
||||
<B>Testing predicates</B>
|
||||
<BR>
|
||||
<B>Test:</B>see source<BR>
|
||||
<B>Desired Result:</B>
|
||||
<BR>
|
||||
<B>Result:</B>
|
||||
</P>
|
||||
<P>
|
||||
<B>Named Template/Call Template</B>
|
||||
<P>
|
||||
<B>Test:</B><xsl:call-template name="named-template-test"/><BR>
|
||||
<B>Desired Result:</B>named template processed with default value!<BR>
|
||||
<B>Result:</B>named template processed with default value!</P>
|
||||
<P>
|
||||
<B>Test:</B>- passing arguments to named templates (see xsl source)<BR>
|
||||
<B>Desired Result:</B>named template processed with passed value!<BR>
|
||||
<B>Result:</B>named template processed with passed value!</P>
|
||||
</P>
|
||||
<P>
|
||||
<B>Attribute Value Templates and variables</B>
|
||||
<BR>
|
||||
<B>Test:</B>
|
||||
<UL><xsl:variable name="color">red</xsl:variable><BR><FONT COLOR="{$color}">Red Text</FONT></UL>
|
||||
<B>Desired Result:</B>
|
||||
<FONT COLOR="red">Red Text</FONT>
|
||||
<BR>
|
||||
<B>Result:</B>
|
||||
<FONT COLOR="red">Red Text</FONT>
|
||||
</P>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR BGColor="#E0E0FF">
|
||||
<TD Colspan="2" ALIGN="CENTER">
|
||||
<B>Axis Identifiers (these should work, I need more test cases though)</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:if test="descendant::z">true</xsl:if><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">true</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">true</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:if test="not(descendant-or-self::no-element)">true</xsl:if><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">true</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">true</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR BGColor="#E0E0FF">
|
||||
<TD Colspan="2" ALIGN="CENTER">
|
||||
<B>Creating Elements with xsl:element and xsl:attribute</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:element name="FONT"><BR><xsl:attribute name="COLOR">blue</xsl:attribute><BR>Passed<BR></xsl:element></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">Passed</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">Passed</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR BGCOLOR="#E0E0FF" ALIGN="CENTER">
|
||||
<TD COLSPAN="2">
|
||||
<B>Using Attribute Sets</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><FONT xsl:use-attribute-sets="style1"><BR>Passed<BR></FONT></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">Passed</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue" SIZE="+0">Passed</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:element name="FONT" use-attribute-sets="style1 style2"><BR>Passed<BR></xsl:element></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="red">Passed</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="red" SIZE="+0">Passed</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR BGColor="#E0E0FF">
|
||||
<TD Colspan="2" ALIGN="CENTER">
|
||||
<B>Numbering (only simple numbering currently implemented)</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:number value="4"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">4</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">4</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD>see source<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">1. x<BR>1. y<BR>1. z</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">1. x<BR>1. y<BR>1. z<BR>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR BGColor="#E0E0FF">
|
||||
<TD Colspan="2" ALIGN="CENTER">
|
||||
<B>Additive Expressions</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:value-of select="70+4"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">74</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">74</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:value-of select="-70+4"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">-66</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">-66</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:value-of select="1900+70+8-4"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">1974</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">1974</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:value-of select="(4+5)-(9+9)"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">-9</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">-9</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<HR>
|
||||
<TABLE>
|
||||
<TR BGColor="#E0E0FF">
|
||||
<TD Colspan="2" ALIGN="CENTER">
|
||||
<B>Multiplicative Expressions</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:value-of select="7*4"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">28</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">28</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:value-of select="7mod4"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">3</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">3</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:value-of select="7div4"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">1.75</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">1.75</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:value-of select="7div0"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">Infinity</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">Infinity</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:value-of select="0 div 0"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">NaN</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">NaN</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:variable name="x" select="7*3"/><BR><xsl:variable name="y" select="3"/><BR><xsl:value-of select="$x div $y"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">7</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">7<BR>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<TABLE>
|
||||
<TR BGColor="#E0E0FF">
|
||||
<TD Colspan="2" ALIGN="CENTER">
|
||||
<B>Precedence tests</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:value-of select="2 mod 2 = 0"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">true</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">true</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:value-of select="5 mod 2<5 and 2*6>= 12"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">true</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">true</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:value-of select="5 mod 2<5 and 2*6>12"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">false</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">false</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:value-of select="4+5*3"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">19</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">19</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:value-of select="4+5*3+(6-4)*7"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">33</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">33</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<TABLE>
|
||||
<TR BGColor="#E0E0FF">
|
||||
<TD Colspan="2" ALIGN="CENTER">
|
||||
<B>Automatic Result Type Conversion</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP">
|
||||
<B>Test:</B>
|
||||
</TD>
|
||||
<TD><xsl:value-of select="'747' + 8"/><BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Desired Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">755</FONT>
|
||||
<BR>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<B>Result:</B>
|
||||
</TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">755</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
|
||||
<!-- this is a test document -->
|
||||
<document>
|
||||
<!-- test comment -->
|
||||
<x name="x">x</x>
|
||||
<y name="y">y</y>
|
||||
<z name="z">z</z>
|
||||
|
||||
<abc>
|
||||
<def>def</def>
|
||||
</abc>
|
||||
</document>
|
||||
@@ -1,847 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/*
|
||||
* 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 XSL:P XSLT processor.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Keith Visco.
|
||||
* Portions created by Keith Visco (C) 1999 Keith Visco.
|
||||
* All Rights Reserved..
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* - original author.
|
||||
*
|
||||
*/
|
||||
-->
|
||||
|
||||
<!--
|
||||
This is a test stylesheet used for testing the XSL processor
|
||||
-->
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
|
||||
<!-- set the output properties -->
|
||||
<xsl:output method="html"/>
|
||||
|
||||
<!-- AttributeSet -->
|
||||
<xsl:attribute-set name="style1">
|
||||
<xsl:attribute name="COLOR">blue</xsl:attribute>
|
||||
<xsl:attribute name="SIZE">+0</xsl:attribute>
|
||||
</xsl:attribute-set>
|
||||
|
||||
<xsl:attribute-set name="style2">
|
||||
<xsl:attribute name="COLOR">red</xsl:attribute>
|
||||
<xsl:attribute name="SIZE">+0</xsl:attribute>
|
||||
</xsl:attribute-set>
|
||||
|
||||
<!-- root rule -->
|
||||
<xsl:template match="/">
|
||||
<xsl:processing-instruction name="foo">
|
||||
this is a test processing instruction
|
||||
</xsl:processing-instruction>
|
||||
<xsl:comment>TransforMiiX Test cases, written by Keith Visco.</xsl:comment>
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
|
||||
<!-- named template -->
|
||||
<xsl:template name="named-template-test">
|
||||
<xsl:param name="my-param" select="'default value'"/>
|
||||
named template processed with <xsl:text> </xsl:text>
|
||||
<xsl:value-of select="$my-param"/>!
|
||||
<xsl:if test="$dummy-param">
|
||||
<BR/>
|
||||
<FONT COLOR="red">
|
||||
Error, undeclared parameters should be ignored!
|
||||
</FONT>
|
||||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<!-- empty variable for named template test -->
|
||||
<xsl:variable name="dummy-param" />
|
||||
|
||||
<!-- supress non-selected nodes-->
|
||||
<xsl:template match="*"/>
|
||||
|
||||
<!-- variable tests -->
|
||||
<xsl:variable name="product-name">
|
||||
Transfor<FONT COLOR="blue">Mii</FONT>X
|
||||
</xsl:variable>
|
||||
<!-- main rule for document element -->
|
||||
<xsl:template match="document">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>TransforMiiX Test Cases</TITLE>
|
||||
<SCRIPT Language="JavaScript">
|
||||
// This is a test for properly printing SCRIPT elements
|
||||
function foo() {
|
||||
var x = 1;
|
||||
var y = 2;
|
||||
return (x < y);
|
||||
}
|
||||
//
|
||||
</SCRIPT>
|
||||
</HEAD>
|
||||
<BODY BGColor="#FFFFFF" Text="#000000">
|
||||
<CENTER>
|
||||
<FONT COLOR="BLUE" FACE="Arial" SIZE="+1">
|
||||
<B>Mozilla XSLT</B>
|
||||
</FONT>
|
||||
<BR/>
|
||||
<B>Transfor<FONT COLOR="blue">Mii</FONT>X Test Cases</B>
|
||||
</CENTER>
|
||||
<P>
|
||||
This document serves to test basic XSL expressions.
|
||||
</P>
|
||||
<!-- new test -->
|
||||
<P>
|
||||
<B>Testing xsl:variable and xsl:copy-of</B><BR/>
|
||||
<B>Test:</B> <xsl:copy-of select="$product-name"/><BR/>
|
||||
<B>Desired Result:</B>Transfor<FONT COLOR="blue">Mii</FONT>X<BR/>
|
||||
<B>Result:</B><xsl:copy-of select="$product-name"/>
|
||||
</P>
|
||||
<!-- new test -->
|
||||
<P>
|
||||
<B>Testing xsl:if</B><BR/>
|
||||
<B>Test:</B> <xsl:if test="x | y | z">true</xsl:if><BR/>
|
||||
<B>Desired Result:</B> true<BR/>
|
||||
<B>Result:</B> <xsl:if test="x | y | z">true</xsl:if>
|
||||
</P>
|
||||
|
||||
<!-- new test -->
|
||||
<P>
|
||||
<B>Testing xsl:if</B><BR/>
|
||||
<B>Test:</B> <xsl:if test="true()">true</xsl:if><BR/>
|
||||
<B>Desired Result:</B> true<BR/>
|
||||
<B>Result:</B> <xsl:if test="true()">true</xsl:if>
|
||||
</P>
|
||||
|
||||
<!-- new test -->
|
||||
<P>
|
||||
<B>Testing xsl:if</B><BR/>
|
||||
<B>Test:</B> <xsl:if test="'a'='b'">a equals b</xsl:if><BR/>
|
||||
<B></B> <xsl:if test="'a'!='b'">a does not equal b</xsl:if>
|
||||
<BR/>
|
||||
<B>Desired Result:</B> a does not equal to b<BR/>
|
||||
<B>Result:</B>
|
||||
<xsl:if test="'a'='b'">a equals b<BR/></xsl:if>
|
||||
<xsl:if test="'a'!='b'">a does not equal b</xsl:if>
|
||||
</P>
|
||||
|
||||
<!-- new test -->
|
||||
<P>
|
||||
<B>Testing xsl:if</B><BR/>
|
||||
<B>Test:</B> <xsl:if test="2+1-3"> 2+1-3 is true</xsl:if><BR/>
|
||||
<B> </B><xsl:if test="not(2+1-3)"> not(2+1-3) is true</xsl:if><BR/>
|
||||
<B>Desired Result:</B>not(2+1-3) is true <BR/>
|
||||
<B>Result:</B>
|
||||
<xsl:if test="2+1-3">2+1-3 is true</xsl:if>
|
||||
<xsl:if test="not(2+1-3)">not(2+1-3) is true</xsl:if>
|
||||
</P>
|
||||
|
||||
<!-- new test -->
|
||||
<P>
|
||||
<B>Testing xsl:choose</B><BR/>
|
||||
<B>Test:</B>see source<BR/>
|
||||
<B>Desired Result:</B> true<BR/>
|
||||
<B>Result:</B>
|
||||
<xsl:choose>
|
||||
<xsl:when test="a">error - a</xsl:when>
|
||||
<xsl:when test="abc/def">true</xsl:when>
|
||||
<xsl:when test="b">error - b</xsl:when>
|
||||
<xsl:otherwise>false</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</P>
|
||||
<!-- new test -->
|
||||
<P>
|
||||
<B>Testing parent and ancestor ops</B><BR/>
|
||||
<B>Test:</B>see source<BR/>
|
||||
<B>Desired Result:</B> true<BR/>
|
||||
<B>Result:</B><xsl:if test="//def">true</xsl:if><BR/>
|
||||
|
||||
</P>
|
||||
<!-- new test -->
|
||||
|
||||
<P>
|
||||
<B>Testing basic xsl:apply-templates</B><BR/>
|
||||
<B>Test:</B><xsl:apply-templates/><BR/>
|
||||
<B>Desired Result:</B>element <B>x</B>, element <B>y</B>, element <B>z</B><BR/>
|
||||
<B>Result:</B><xsl:apply-templates select="x|y|z"/>
|
||||
</P>
|
||||
<!-- new test -->
|
||||
|
||||
<P>
|
||||
<B>Testing basic xsl:apply-templates with mode</B><BR/>
|
||||
<B>Test:</B><xsl:apply-templates mode="mode-test"/><BR/>
|
||||
<B>Desired Result:</B>x, y, z<BR/>
|
||||
<B>Result:</B><xsl:apply-templates select="x|y|z" mode="mode-test"/>
|
||||
</P>
|
||||
<!-- new test -->
|
||||
<P>
|
||||
<B>Testing predicates</B><BR/>
|
||||
<B>Test:</B>see source<BR/>
|
||||
<B>Desired Result:</B> <B>z</B><BR/>
|
||||
<B>Result:</B>
|
||||
<xsl:for-each select="*[position()=3]">
|
||||
<B><xsl:value-of select="."/></B>
|
||||
</xsl:for-each>
|
||||
</P>
|
||||
<!-- new test -->
|
||||
<P>
|
||||
<B>Testing predicates</B><BR/>
|
||||
<B>Test:</B>see source<BR/>
|
||||
<B>Desired Result:</B><BR/>
|
||||
<B>Result:</B>
|
||||
<xsl:for-each select="*[false()]">
|
||||
<B><xsl:value-of select="."/></B>
|
||||
</xsl:for-each>
|
||||
</P>
|
||||
<!-- new test -->
|
||||
<P>
|
||||
<B>Named Template/Call Template</B>
|
||||
<P>
|
||||
<B>Test:</B><xsl:call-template name="named-template-test"/><BR/>
|
||||
<B>Desired Result:</B>named template processed with default value!<BR/>
|
||||
<B>Result:</B><xsl:call-template name="named-template-test"/>
|
||||
</P>
|
||||
<P>
|
||||
<B>Test:</B> - passing arguments to named templates (see xsl source)<BR/>
|
||||
<B>Desired Result:</B>named template processed with passed value!<BR/>
|
||||
<B>Result:</B>
|
||||
<xsl:call-template name="named-template-test">
|
||||
<xsl:with-param name="my-param" select="'passed value'"/>
|
||||
<xsl:with-param name="dummy-param" select="'test'"/>
|
||||
</xsl:call-template>
|
||||
</P>
|
||||
</P>
|
||||
<!-- new test -->
|
||||
<P>
|
||||
<B>Attribute Value Templates and variables</B><BR/>
|
||||
<B>Test:</B>
|
||||
<UL>
|
||||
<xsl:variable name="color">red</xsl:variable><BR/>
|
||||
<FONT COLOR="{$color}">Red Text</FONT>
|
||||
</UL>
|
||||
<B>Desired Result:</B>
|
||||
<FONT COLOR="red">Red Text</FONT><BR/>
|
||||
<B>Result:</B>
|
||||
<xsl:variable name="color">red</xsl:variable>
|
||||
<FONT COLOR="{$color}">Red Text</FONT>
|
||||
</P>
|
||||
<HR/>
|
||||
<!-- AXIS IDENTIFIER TESTS -->
|
||||
<TABLE>
|
||||
<TR BGColor="#E0E0FF">
|
||||
<TD Colspan="2" ALIGN="CENTER">
|
||||
<B>Axis Identifiers (these should work, I need more test cases though)</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:if test="descendant::z">true</xsl:if><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">true</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<xsl:if test="descendant::z">
|
||||
<FONT COLOR="blue">true</FONT>
|
||||
</xsl:if>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:if test="not(descendant-or-self::no-element)">true</xsl:if><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">true</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<xsl:if test="not(descendant-or-self::no-element)">
|
||||
<FONT COLOR="blue">true</FONT>
|
||||
</xsl:if>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:value-of select="count(x/attribute::*)"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">1</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue"><xsl:value-of select="count(x/attribute::*)"/></FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<HR/>
|
||||
<TABLE>
|
||||
<TR BGColor="#E0E0FF">
|
||||
<TD Colspan="2" ALIGN="CENTER">
|
||||
<B>Creating Elements with xsl:element and xsl:attribute</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:element name="FONT"><BR />
|
||||
<xsl:attribute name="COLOR">blue</xsl:attribute> <BR/>
|
||||
Passed <BR/>
|
||||
</xsl:element>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">Passed</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<xsl:element name="FONT">
|
||||
<xsl:attribute name="COLOR">blue</xsl:attribute>
|
||||
Passed
|
||||
</xsl:element>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR BGCOLOR="#E0E0FF" ALIGN="CENTER">
|
||||
<TD COLSPAN="2"><B>Using Attribute Sets</B></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<FONT xsl:use-attribute-sets="style1"><BR />
|
||||
Passed <BR/>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">Passed</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT xsl:use-attribute-sets="style1">
|
||||
Passed
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:element name="FONT" use-attribute-sets="style1 style2"><BR />
|
||||
Passed <BR/>
|
||||
</xsl:element>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="red">Passed</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<xsl:element name="FONT" use-attribute-sets="style1 style2">
|
||||
Passed
|
||||
</xsl:element>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<HR/>
|
||||
<!-- NUMBERING Examples -->
|
||||
<TABLE>
|
||||
<TR BGColor="#E0E0FF">
|
||||
<TD Colspan="2" ALIGN="CENTER">
|
||||
<B>Numbering (only simple numbering currently implemented)</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:number value="4"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">4</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue"><xsl:number value="4"/></FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
see source<BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
1. x <BR/>1. y<BR/>1. z
|
||||
</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:for-each select="x | y | z">
|
||||
<xsl:number/>
|
||||
<xsl:text>. </xsl:text><xsl:value-of select="."/><BR/>
|
||||
</xsl:for-each>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
|
||||
<HR/>
|
||||
<!-- ADDITIVE EXPRESSION TESTS -->
|
||||
<TABLE>
|
||||
<TR BGColor="#E0E0FF">
|
||||
<TD Colspan="2" ALIGN="CENTER">
|
||||
<B>Additive Expressions</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:value-of select="70+4"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">74</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:value-of select="70+4"/>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:value-of select="-70+4"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">-66</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:value-of select="-70+4"/>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:value-of select="1900+70+8-4"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">1974</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:value-of select="1900+70+8-4"/>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:value-of select="(4+5)-(9+9)"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">-9</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:value-of select="(4+5)-(9+9)"/>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
</TABLE>
|
||||
<HR/>
|
||||
<!-- MULTIPLICATIVE EXPRESSION TESTS -->
|
||||
<TABLE>
|
||||
<TR BGColor="#E0E0FF">
|
||||
<TD Colspan="2" ALIGN="CENTER">
|
||||
<B>Multiplicative Expressions</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:value-of select="7*4"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">28</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:value-of select="7*4"/>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:value-of select="7mod 4"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">3</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:value-of select="7mod 4"/>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:value-of select="7div 4"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">1.75</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:value-of select="7div 4"/>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:value-of select="7div 0"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">Infinity</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:value-of select="7div 0"/>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:value-of select="0 div 0"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">NaN</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:value-of select="0 div 0"/>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:variable name="x" select="7*3"/><BR />
|
||||
<xsl:variable name="y" select="3"/><BR />
|
||||
<xsl:value-of select="$x div $y"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">7</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:variable name="x" select="7*3"/>
|
||||
<xsl:variable name="y" select="3"/>
|
||||
<xsl:value-of select="$x div $y"/>
|
||||
<BR/>
|
||||
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<!-- PRECEDENCE TESTS -->
|
||||
<TABLE>
|
||||
<TR BGColor="#E0E0FF">
|
||||
<TD Colspan="2" ALIGN="CENTER">
|
||||
<B>Precedence tests</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:value-of select="2 mod 2 = 0"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">true</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:value-of select="2 mod 2 = 0"/>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:value-of select="5 mod 2 < 5 and 2*6 >= 12"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">true</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:value-of select="5 mod 2 < 5 and 2*6>=12"/>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:value-of select="5 mod 2 < 5 and 2*6>12"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">false</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:value-of select="5 mod 2 < 5 and 2*6>12"/>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:value-of select="4+5*3"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">19</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:value-of select="4+5*3"/>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:value-of select="4+5*3+(6-4)*7"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">33</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:value-of select="4+5*3+(6-4)*7"/>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<!-- Result Type conversion tests -->
|
||||
<TABLE>
|
||||
<TR BGColor="#E0E0FF">
|
||||
<TD Colspan="2" ALIGN="CENTER">
|
||||
<B>Automatic Result Type Conversion</B>
|
||||
</TD>
|
||||
</TR>
|
||||
<!-- new test -->
|
||||
<TR>
|
||||
<TD VALIGN="TOP"><B>Test:</B></TD>
|
||||
<TD>
|
||||
<xsl:value-of select="'747' + 8"/><BR />
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Desired Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">755</FONT><BR/>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD><B>Result:</B></TD>
|
||||
<TD>
|
||||
<FONT COLOR="blue">
|
||||
<xsl:value-of select="'747' + 8"/>
|
||||
</FONT>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</BODY>
|
||||
</HTML>
|
||||
</xsl:template>
|
||||
|
||||
<!-- simple union expressions -->
|
||||
<xsl:template match="x | y | z" priority="1.0">
|
||||
element<B><xsl:text> </xsl:text><xsl:value-of select="@*"/></B>
|
||||
<xsl:if test="not(position()=3)">,</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="x | y | z" mode="mode-test">
|
||||
<xsl:value-of select="@*"/>
|
||||
<xsl:if test="not(position()=3)"><xsl:text>, </xsl:text></xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="z">
|
||||
element (z): <B><xsl:value-of select="."/></B>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE xsl:stylesheet [
|
||||
<!ENTITY cr "
">
|
||||
]>
|
||||
|
||||
<!--
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* Portions created by Keith Visco (C) 2000 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* - original author.
|
||||
*
|
||||
*
|
||||
*
|
||||
* This is a test stylesheet used for testing TransforMiiX
|
||||
**/
|
||||
-->
|
||||
<xsl:stylesheet
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
version="1.0">
|
||||
|
||||
<!-- root template -->
|
||||
<xsl:template match="/">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>View Source:</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<!-- Add XML Declaration (as long as we have child nodes!) -->
|
||||
<xsl:if test="node()">
|
||||
<B><?xml version="1.0"?></B><BR/>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates select="node()"/>
|
||||
</BODY>
|
||||
</HTML>
|
||||
</xsl:template>
|
||||
|
||||
<!-- comment template -->
|
||||
<xsl:template match="comment()">
|
||||
<I><!--<xsl:value-of select="."/>--></I>
|
||||
</xsl:template>
|
||||
|
||||
<!-- generic element template -->
|
||||
<xsl:template match="*">
|
||||
|
||||
<!-- open element tag -->
|
||||
<FONT COLOR="blue"><</FONT><FONT COLOR="red"><xsl:value-of select="name(.)"/></FONT>
|
||||
<xsl:apply-templates select="@*"/><FONT COLOR="blue">></FONT>
|
||||
|
||||
<!-- add break if we have element children -->
|
||||
<xsl:if test="*"><BR/></xsl:if>
|
||||
|
||||
<!-- recursively apply templates to children of this element -->
|
||||
<xsl:apply-templates/>
|
||||
|
||||
<!-- close element tag -->
|
||||
<FONT COLOR="blue"></</FONT>
|
||||
<FONT COLOR="red"><xsl:value-of select="name(.)"/></FONT>
|
||||
<FONT COLOR="blue">></FONT>
|
||||
<BR/>
|
||||
</xsl:template>
|
||||
|
||||
<!-- generic attribute template -->
|
||||
<xsl:template match="@*">
|
||||
 <B><xsl:value-of select="name(.)"/></B>
|
||||
<FONT COLOR="green">="<xsl:value-of select="."/>"</FONT>
|
||||
</xsl:template>
|
||||
|
||||
<!-- processing instruction template -->
|
||||
<xsl:template match="processing-instruction()">
|
||||
<I><?<xsl:value-of select="name(.)"/> <xsl:value-of select="."/>?></I><BR/>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
#
|
||||
# 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 Axel Hecht.
|
||||
# Portions created by Axel Hecht are Copyright (C) Axel Hecht.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <axel@pike.org>
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
LIBRARY_NAME = tx
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
expat \
|
||||
$(NULL)
|
||||
|
||||
OBJS = ../base/Double.$(OBJ_SUFFIX) \
|
||||
../base/List.$(OBJ_SUFFIX) \
|
||||
../base/SimpleErrorObserver.$(OBJ_SUFFIX) \
|
||||
../base/txAtoms.$(OBJ_SUFFIX) \
|
||||
../base/txExpandedNameMap.$(OBJ_SUFFIX) \
|
||||
../base/txNamespaceMap.$(OBJ_SUFFIX) \
|
||||
../base/txStringUtils.$(OBJ_SUFFIX) \
|
||||
../base/txURIUtils.$(OBJ_SUFFIX) \
|
||||
../xml/dom/standalone/Attr.$(OBJ_SUFFIX) \
|
||||
../xml/dom/standalone/NodeListDefinition.$(OBJ_SUFFIX) \
|
||||
../xml/dom/standalone/NodeDefinition.$(OBJ_SUFFIX) \
|
||||
../xml/dom/standalone/Element.$(OBJ_SUFFIX) \
|
||||
../xml/dom/standalone/NamedNodeMap.$(OBJ_SUFFIX) \
|
||||
../xml/dom/standalone/Document.$(OBJ_SUFFIX) \
|
||||
../xml/dom/standalone/ProcessingInstruction.$(OBJ_SUFFIX) \
|
||||
../xpath/AdditiveExpr.$(OBJ_SUFFIX) \
|
||||
../xpath/AttributeValueTemplate.$(OBJ_SUFFIX) \
|
||||
../xpath/BooleanExpr.$(OBJ_SUFFIX) \
|
||||
../xpath/BooleanFunctionCall.$(OBJ_SUFFIX) \
|
||||
../xpath/BooleanResult.$(OBJ_SUFFIX) \
|
||||
../xpath/ExprLexer.$(OBJ_SUFFIX) \
|
||||
../xpath/ExprParser.$(OBJ_SUFFIX) \
|
||||
../xpath/FilterExpr.$(OBJ_SUFFIX) \
|
||||
../xpath/FunctionCall.$(OBJ_SUFFIX) \
|
||||
../xpath/LocationStep.$(OBJ_SUFFIX) \
|
||||
../xpath/MultiplicativeExpr.$(OBJ_SUFFIX) \
|
||||
../xpath/NodeSet.$(OBJ_SUFFIX) \
|
||||
../xpath/NodeSetFunctionCall.$(OBJ_SUFFIX) \
|
||||
../xpath/NumberExpr.$(OBJ_SUFFIX) \
|
||||
../xpath/NumberFunctionCall.$(OBJ_SUFFIX) \
|
||||
../xpath/NumberResult.$(OBJ_SUFFIX) \
|
||||
../xpath/PathExpr.$(OBJ_SUFFIX) \
|
||||
../xpath/PredicateList.$(OBJ_SUFFIX) \
|
||||
../xpath/RelationalExpr.$(OBJ_SUFFIX) \
|
||||
../xpath/RootExpr.$(OBJ_SUFFIX) \
|
||||
../xpath/StringExpr.$(OBJ_SUFFIX) \
|
||||
../xpath/StringFunctionCall.$(OBJ_SUFFIX) \
|
||||
../xpath/StringResult.$(OBJ_SUFFIX) \
|
||||
../xpath/txNameTest.$(OBJ_SUFFIX) \
|
||||
../xpath/txNodeTypeTest.$(OBJ_SUFFIX) \
|
||||
../xpath/txForwardContext.$(OBJ_SUFFIX) \
|
||||
../xpath/txNodeSetContext.$(OBJ_SUFFIX) \
|
||||
../xpath/UnionExpr.$(OBJ_SUFFIX) \
|
||||
../xpath/UnaryExpr.$(OBJ_SUFFIX) \
|
||||
../xpath/VariableRefExpr.$(OBJ_SUFFIX) \
|
||||
../xml/XMLUtils.$(OBJ_SUFFIX) \
|
||||
../xml/XMLDOMUtils.$(OBJ_SUFFIX) \
|
||||
../xml/parser/txXMLParser.$(OBJ_SUFFIX) \
|
||||
../xslt/txBufferingHandler.$(OBJ_SUFFIX) \
|
||||
../xslt/txExecutionState.$(OBJ_SUFFIX) \
|
||||
../xslt/txHTMLOutput.$(OBJ_SUFFIX) \
|
||||
../xslt/txInstructions.$(OBJ_SUFFIX) \
|
||||
../xslt/txOutputFormat.$(OBJ_SUFFIX) \
|
||||
../xslt/txRtfHandler.$(OBJ_SUFFIX) \
|
||||
../xslt/txStandaloneXSLTProcessor.$(OBJ_SUFFIX) \
|
||||
../xslt/txStandaloneStylesheetCompiler.$(OBJ_SUFFIX) \
|
||||
../xslt/txStylesheet.$(OBJ_SUFFIX) \
|
||||
../xslt/txStylesheetCompileHandlers.$(OBJ_SUFFIX) \
|
||||
../xslt/txStylesheetCompiler.$(OBJ_SUFFIX) \
|
||||
../xslt/txTextHandler.$(OBJ_SUFFIX) \
|
||||
../xslt/txTextOutput.$(OBJ_SUFFIX) \
|
||||
../xslt/txToplevelItems.$(OBJ_SUFFIX) \
|
||||
../xslt/txUnknownHandler.$(OBJ_SUFFIX) \
|
||||
../xslt/txXMLOutput.$(OBJ_SUFFIX) \
|
||||
../xslt/txXSLTNumber.$(OBJ_SUFFIX) \
|
||||
../xslt/txXSLTNumberCounters.$(OBJ_SUFFIX) \
|
||||
../xslt/txXSLTPatterns.$(OBJ_SUFFIX) \
|
||||
../xslt/txPatternParser.$(OBJ_SUFFIX) \
|
||||
../xslt/txXSLTProcessor.$(OBJ_SUFFIX) \
|
||||
../xslt/functions/CurrentFunctionCall.$(OBJ_SUFFIX) \
|
||||
../xslt/functions/DocumentFunctionCall.$(OBJ_SUFFIX) \
|
||||
../xslt/functions/ElementAvailableFnCall.$(OBJ_SUFFIX) \
|
||||
../xslt/functions/FunctionAvailableFnCall.$(OBJ_SUFFIX) \
|
||||
../xslt/functions/GenerateIdFunctionCall.$(OBJ_SUFFIX) \
|
||||
../xslt/functions/SystemPropertyFunctionCall.$(OBJ_SUFFIX) \
|
||||
../xslt/functions/txFormatNumberFunctionCall.$(OBJ_SUFFIX) \
|
||||
../xslt/functions/txKeyFunctionCall.$(OBJ_SUFFIX) \
|
||||
../xslt/util/txNodeSorter.$(OBJ_SUFFIX) \
|
||||
../xslt/util/txXPathResultComparator.$(OBJ_SUFFIX)
|
||||
CPP_PROG_LINK = 1
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DIST)/lib/$(LIB_PREFIX)expat_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)xmltok_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir)/../xslt -I$(srcdir)/../base -I$(srcdir)/../net \
|
||||
-I$(srcdir)/../xml -I$(srcdir)/../xml/dom \
|
||||
-I$(srcdir)/../xml/parser \
|
||||
-I$(srcdir)/../xpath -I$(srcdir)/../xslt/util \
|
||||
-I$(srcdir)/../xslt/functions $(MARK_INC)
|
||||
DEFINES += -DXML_DTD -DXML_UNICODE
|
||||
@@ -1,56 +0,0 @@
|
||||
#
|
||||
# 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 Axel Hecht.
|
||||
# Portions created by Axel Hecht are Copyright (C) Axel Hecht.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <axel@pike.org>
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
SIMPLE_PROGRAMS = transformiix$(BIN_SUFFIX) testXalan$(BIN_SUFFIX)
|
||||
ifdef MARK_INC
|
||||
SIMPLE_PROGRAMS += txXSLTMarkDriver$(BIN_SUFFIX)
|
||||
endif
|
||||
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
expat \
|
||||
$(NULL)
|
||||
|
||||
CPP_PROG_LINK = 1
|
||||
|
||||
EXTRA_DEPS = \
|
||||
$(DIST)/lib/$(LIB_PREFIX)tx.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_LIBS = \
|
||||
$(DIST)/lib/$(LIB_PREFIX)tx.$(LIB_SUFFIX) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir)/../xslt -I$(srcdir)/../base -I$(srcdir)/../net \
|
||||
-I$(srcdir)/../xml -I$(srcdir)/../xml/dom \
|
||||
-I$(srcdir)/../xml/parser \
|
||||
-I$(srcdir)/../xpath -I$(srcdir)/../xslt/util \
|
||||
-I$(srcdir)/../xslt/functions $(MARK_INC)
|
||||
@@ -1,418 +0,0 @@
|
||||
/* -*- 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
|
||||
* Axel Hecht.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Axel Hecht <axel@pike.org>
|
||||
*
|
||||
* 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 "txStandaloneXSLTProcessor.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include <fstream.h>
|
||||
#include "nsDoubleHashtable.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "prenv.h"
|
||||
#include "prsystem.h"
|
||||
#include "nsDirectoryServiceUtils.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
|
||||
#ifdef NS_TRACE_MALLOC
|
||||
#include "nsTraceMalloc.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Prints the command line help screen to the console
|
||||
*/
|
||||
void printHelp()
|
||||
{
|
||||
cerr << "testXalan [-o output-file] [category]*" << endl << endl;
|
||||
cerr << "Options:";
|
||||
cerr << endl << endl;
|
||||
cerr << "\t-o specify output file (default: write to stdout)";
|
||||
cerr << endl << endl;
|
||||
cerr << "\t Specify XALAN_DIR in your environement." << endl;
|
||||
cerr << endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class to report success and failure to RDF
|
||||
*/
|
||||
class txRDFOut
|
||||
{
|
||||
public:
|
||||
explicit txRDFOut(ostream* aOut)
|
||||
: mOut(aOut), mSuccess(0), mFail(0), mParent(nsnull)
|
||||
{
|
||||
}
|
||||
explicit txRDFOut(const nsACString& aName, txRDFOut* aParent)
|
||||
: mName(aName), mOut(aParent->mOut), mSuccess(0), mFail(0),
|
||||
mParent(aParent)
|
||||
{
|
||||
}
|
||||
~txRDFOut()
|
||||
{
|
||||
*mOut << " <RDF:Description about=\"urn:x-buster:conf" <<
|
||||
mName.get() <<
|
||||
"\">\n" <<
|
||||
" <NC:orig_succCount NC:parseType=\"Integer\">" <<
|
||||
mSuccess <<
|
||||
"</NC:orig_succCount>\n" <<
|
||||
" <NC:orig_failCount NC:parseType=\"Integer\">" <<
|
||||
mFail <<
|
||||
"</NC:orig_failCount>\n" <<
|
||||
" </RDF:Description>" << endl;
|
||||
}
|
||||
|
||||
void feed(const nsACString& aTest, PRBool aSuccess)
|
||||
{
|
||||
*mOut << " <RDF:Description about=\"urn:x-buster:" <<
|
||||
PromiseFlatCString(aTest).get() <<
|
||||
"\"\n NC:orig_succ=\"";
|
||||
if (aSuccess) {
|
||||
*mOut << "yes";
|
||||
succeeded();
|
||||
}
|
||||
else {
|
||||
*mOut << "no";
|
||||
failed();
|
||||
}
|
||||
*mOut << "\" />\n";
|
||||
}
|
||||
|
||||
void succeeded()
|
||||
{
|
||||
if (mParent)
|
||||
mParent->succeeded();
|
||||
++mSuccess;
|
||||
}
|
||||
void failed()
|
||||
{
|
||||
if (mParent)
|
||||
mParent->failed();
|
||||
++mFail;
|
||||
}
|
||||
private:
|
||||
nsCAutoString mName;
|
||||
ostream* mOut;
|
||||
PRUint32 mSuccess, mFail;
|
||||
txRDFOut* mParent;
|
||||
};
|
||||
|
||||
static void
|
||||
readToString(istream& aIstream, nsACString& aString)
|
||||
{
|
||||
static char buffer[1024];
|
||||
int read = 0;
|
||||
do {
|
||||
aIstream.read(buffer, 1024);
|
||||
read = aIstream.gcount();
|
||||
aString.Append(Substring(buffer, buffer + read));
|
||||
} while (!aIstream.eof());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the XALAN_DIR environment variable and return a nsIFile for
|
||||
* the conf and the conf-gold subdirectory. Create a TEMP file, too.
|
||||
* Return an error if either does not exist.
|
||||
*/
|
||||
static nsresult
|
||||
setupXalan(const char* aPath, nsIFile** aConf, nsIFile** aConfGold,
|
||||
nsIFile** aTemp)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILocalFile> conf(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID,
|
||||
&rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr <nsIFile> tmpFile;
|
||||
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tmpFile));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
tmpFile->Append(NS_LITERAL_STRING("xalan.out"));
|
||||
rv = tmpFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
|
||||
rv = conf->InitWithNativePath(nsDependentCString(aPath));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIFile> gold;
|
||||
rv = conf->Clone(getter_AddRefs(gold));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = conf->Append(NS_LITERAL_STRING("conf"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
PRBool isDir;
|
||||
rv = conf->IsDirectory(&isDir);
|
||||
if (NS_FAILED(rv) || !isDir) {
|
||||
return NS_ERROR_FILE_NOT_DIRECTORY;
|
||||
}
|
||||
rv = gold->Append(NS_LITERAL_STRING("conf-gold"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = gold->IsDirectory(&isDir);
|
||||
if (NS_FAILED(rv) || !isDir || !conf || !gold) {
|
||||
return NS_ERROR_FILE_NOT_DIRECTORY;
|
||||
}
|
||||
// got conf and conf-gold subdirectories
|
||||
*aConf = conf;
|
||||
NS_ADDREF(*aConf);
|
||||
*aConfGold = gold;
|
||||
NS_ADDREF(*aConfGold);
|
||||
*aTemp = tmpFile;
|
||||
NS_ADDREF(*aTemp);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a category of Xalan tests
|
||||
*/
|
||||
void runCategory(nsIFile* aConfCat, nsIFile* aGoldCat, nsIFile* aRefTmp,
|
||||
txRDFOut* aOut)
|
||||
{
|
||||
nsresult rv;
|
||||
//clone the nsIFiles, so that we can return easily
|
||||
nsCOMPtr<nsIFile> conf, gold;
|
||||
aConfCat->Clone(getter_AddRefs(conf));
|
||||
aGoldCat->Clone(getter_AddRefs(gold));
|
||||
nsCAutoString catName, refTmp;
|
||||
conf->GetNativeLeafName(catName);
|
||||
aRefTmp->GetNativePath(refTmp);
|
||||
txRDFOut results(catName, aOut);
|
||||
nsCOMPtr<nsISimpleEnumerator> tests;
|
||||
rv = conf->GetDirectoryEntries(getter_AddRefs(tests));
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
PRBool hasMore, isFile;
|
||||
nsCAutoString leaf;
|
||||
NS_NAMED_LITERAL_CSTRING(xsl, ".xsl");
|
||||
while (NS_SUCCEEDED(tests->HasMoreElements(&hasMore)) && hasMore) {
|
||||
nsCOMPtr<nsILocalFile> test;
|
||||
tests->GetNext(getter_AddRefs(test));
|
||||
test->GetNativeLeafName(leaf);
|
||||
if (xsl.Equals(Substring(leaf, leaf.Length()-4, 4))) {
|
||||
// we have a stylesheet, let's look for source and reference
|
||||
nsAFlatCString::char_iterator start, ext;
|
||||
leaf.BeginWriting(start);
|
||||
leaf.EndWriting(ext);
|
||||
ext -= 2;
|
||||
// overwrite extension with .xml
|
||||
*ext = 'm'; // this one was easy
|
||||
nsCOMPtr<nsIFile> source;
|
||||
conf->Clone(getter_AddRefs(source));
|
||||
rv = source->AppendNative(leaf);
|
||||
if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(source->IsFile(&isFile)) &&
|
||||
isFile) {
|
||||
nsCOMPtr<nsIFile> reference;
|
||||
gold->Clone(getter_AddRefs(reference));
|
||||
// overwrite extension with .out
|
||||
--ext;
|
||||
nsCharTraits<char>::copy(ext, "out", 3);
|
||||
rv = reference->AppendNative(leaf);
|
||||
if (NS_SUCCEEDED(rv) &&
|
||||
NS_SUCCEEDED(reference->IsFile(&isFile)) &&
|
||||
isFile) {
|
||||
nsCAutoString src, style, refPath;
|
||||
test->GetNativePath(style);
|
||||
source->GetNativePath(src);
|
||||
reference->GetNativePath(refPath);
|
||||
if (PR_GetDirectorySeparator() =='\\') {
|
||||
src.ReplaceChar('\\','/');
|
||||
style.ReplaceChar('\\','/');
|
||||
refPath.ReplaceChar('\\','/');
|
||||
}
|
||||
SimpleErrorObserver obs;
|
||||
txStandaloneXSLTProcessor proc;
|
||||
fstream result(refTmp.get(),
|
||||
ios::in | ios::out | ios::trunc);
|
||||
rv = proc.transform(src, style, result, obs);
|
||||
PRBool success = PR_FALSE;
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
result.flush();
|
||||
PRInt64 resultSize, refSize;
|
||||
aRefTmp->GetFileSize(&resultSize);
|
||||
reference->GetFileSize(&refSize);
|
||||
result.seekg(0);
|
||||
int toread = (int)resultSize;
|
||||
nsCString resContent, refContent;
|
||||
resContent.SetCapacity(toread);
|
||||
readToString(result, resContent);
|
||||
result.close();
|
||||
ifstream refStream(refPath.get());
|
||||
toread = (int)refSize;
|
||||
refContent.SetCapacity(toread);
|
||||
readToString(refStream, refContent);
|
||||
refStream.close();
|
||||
success = resContent.Equals(refContent);
|
||||
}
|
||||
ext--;
|
||||
results.feed(Substring(start, ext), success);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The Xalan testcases app
|
||||
*/
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
#ifdef NS_TRACE_MALLOC
|
||||
NS_TraceMallocStartupArgs(argc, argv);
|
||||
#endif
|
||||
char* xalan = PR_GetEnv("XALAN_DIR");
|
||||
if (!xalan) {
|
||||
printHelp();
|
||||
return 1;
|
||||
}
|
||||
nsresult rv;
|
||||
rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIFile> conf, gold, resFile;
|
||||
rv = setupXalan(xalan, getter_AddRefs(conf), getter_AddRefs(gold),
|
||||
getter_AddRefs(resFile));
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ShutdownXPCOM(nsnull);
|
||||
printHelp();
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-- handle output stream
|
||||
ostream* resultOutput = &cout;
|
||||
ofstream resultFileStream;
|
||||
|
||||
int argn = 1;
|
||||
// skip -- gnu style options
|
||||
while (argn < argc) {
|
||||
nsDependentCString opt(argv[argn]);
|
||||
if (!Substring(opt, 0, 2).Equals(NS_LITERAL_CSTRING("--"))) {
|
||||
break;
|
||||
}
|
||||
++argn;
|
||||
}
|
||||
if (argn < argc) {
|
||||
nsDependentCString opt(argv[argn]);
|
||||
if (Substring(opt, 0, 2).Equals(NS_LITERAL_CSTRING("-o"))) {
|
||||
if (opt.Length() > 2) {
|
||||
const nsAFlatCString& fname =
|
||||
PromiseFlatCString(Substring(opt, 2, opt.Length()-2));
|
||||
resultFileStream.open(fname.get(), ios::out);
|
||||
}
|
||||
else {
|
||||
++argn;
|
||||
if (argn < argc) {
|
||||
resultFileStream.open(argv[argn], ios::out);
|
||||
}
|
||||
}
|
||||
if (!resultFileStream) {
|
||||
cerr << "error opening output file" << endl;
|
||||
PRBool exists;
|
||||
if (NS_SUCCEEDED(resFile->Exists(&exists)) && exists)
|
||||
resFile->Remove(PR_FALSE);
|
||||
NS_ShutdownXPCOM(nsnull);
|
||||
return -1;
|
||||
}
|
||||
++argn;
|
||||
resultOutput = &resultFileStream;
|
||||
}
|
||||
}
|
||||
|
||||
if (!txXSLTProcessor::init()) {
|
||||
PRBool exists;
|
||||
if (NS_SUCCEEDED(resFile->Exists(&exists)) && exists)
|
||||
resFile->Remove(PR_FALSE);
|
||||
NS_ShutdownXPCOM(nsnull);
|
||||
return 1;
|
||||
}
|
||||
|
||||
*resultOutput << "<?xml version=\"1.0\"?>\n" <<
|
||||
"<RDF:RDF xmlns:NC=\"http://home.netscape.com/NC-rdf#\"\n" <<
|
||||
" xmlns:RDF=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">" << endl;
|
||||
|
||||
txRDFOut* rdfOut = new txRDFOut(resultOutput);
|
||||
nsCOMPtr<nsIFile> tempFile;
|
||||
if (argn < argc) {
|
||||
// categories are specified
|
||||
while (argn < argc) {
|
||||
nsDependentCString cat(argv[argn++]);
|
||||
rv = conf->AppendNative(cat);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = gold->AppendNative(cat);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
runCategory(conf, gold, resFile, rdfOut);
|
||||
rv = gold->GetParent(getter_AddRefs(tempFile));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "can't go back?");
|
||||
gold = tempFile;
|
||||
}
|
||||
rv = conf->GetParent(getter_AddRefs(tempFile));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "can't go back?");
|
||||
conf = tempFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// no category specified, do everything
|
||||
nsCOMPtr<nsISimpleEnumerator> cats;
|
||||
rv = conf->GetDirectoryEntries(getter_AddRefs(cats));
|
||||
PRBool hasMore, isDir;
|
||||
nsCAutoString leaf;
|
||||
while (NS_SUCCEEDED(cats->HasMoreElements(&hasMore)) && hasMore) {
|
||||
nsCOMPtr<nsILocalFile> cat;
|
||||
cats->GetNext(getter_AddRefs(cat));
|
||||
rv = cat->IsDirectory(&isDir);
|
||||
if (NS_SUCCEEDED(rv) && isDir) {
|
||||
rv = cat->GetNativeLeafName(leaf);
|
||||
if (NS_SUCCEEDED(rv) &&
|
||||
!leaf.Equals(NS_LITERAL_CSTRING("CVS"))) {
|
||||
rv = gold->AppendNative(leaf);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
runCategory(cat, gold, resFile, rdfOut);
|
||||
rv = gold->GetParent(getter_AddRefs(tempFile));
|
||||
gold = tempFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
delete rdfOut;
|
||||
rdfOut = nsnull;
|
||||
*resultOutput << "</RDF:RDF>" << endl;
|
||||
PRBool exists;
|
||||
if (NS_SUCCEEDED(resFile->Exists(&exists)) && exists)
|
||||
resFile->Remove(PR_FALSE);
|
||||
resultFileStream.close();
|
||||
txXSLTProcessor::shutdown();
|
||||
rv = NS_ShutdownXPCOM(nsnull);
|
||||
#ifdef NS_TRACE_MALLOC
|
||||
NS_TraceMallocShutdown();
|
||||
#endif
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
* Nathan Pride, npride@wavo.com
|
||||
* -- fixed document base when stylesheet is specified,
|
||||
* it was defaulting to the XML document.
|
||||
*
|
||||
* Olivier Gerardin, ogerardin@vo.lu
|
||||
* -- redirect non-data output (banner, errors) to stderr
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "txStandaloneXSLTProcessor.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include <fstream.h>
|
||||
#include "nsDoubleHashtable.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
/**
|
||||
* Prints the command line help screen to the console
|
||||
*/
|
||||
void printHelp()
|
||||
{
|
||||
cerr << "transfrmx [-h] [-i xml-file] [-s xslt-file] [-o output-file]" << endl << endl;
|
||||
cerr << "Options:";
|
||||
cerr << endl << endl;
|
||||
cerr << "\t-i specify XML file to process" << endl;
|
||||
cerr << "\t-s specify XSLT file to use for processing (default: use stylesheet" << endl
|
||||
<< "\t\tspecified in XML file)" << endl;
|
||||
cerr << "\t-o specify output file (default: write to stdout)" << endl;
|
||||
cerr << "\t-h this help screen" << endl;
|
||||
cerr << endl;
|
||||
cerr << "You may use '-' in place of the output-file to explicitly specify" << endl;
|
||||
cerr << "standard output." << endl;
|
||||
cerr << endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the command line usage information to the console
|
||||
*/
|
||||
void printUsage()
|
||||
{
|
||||
cerr << "transfrmx [-h] [-i xml-file] [-s xslt-file] [-o output-file]" << endl << endl;
|
||||
cerr << "For more infomation use the -h flag" << endl;
|
||||
}
|
||||
|
||||
class txOptionEntry : public PLDHashCStringEntry
|
||||
{
|
||||
public:
|
||||
txOptionEntry(const void* aKey) : PLDHashCStringEntry(aKey)
|
||||
{
|
||||
}
|
||||
~txOptionEntry()
|
||||
{
|
||||
}
|
||||
nsCStringArray mValues;
|
||||
};
|
||||
|
||||
DECL_DHASH_WRAPPER(txOptions, txOptionEntry, nsACString&)
|
||||
DHASH_WRAPPER(txOptions, txOptionEntry, nsACString&)
|
||||
|
||||
/**
|
||||
* Parses the command line
|
||||
*/
|
||||
void parseCommandLine(int argc, char** argv, txOptions& aOptions)
|
||||
{
|
||||
nsCAutoString flag;
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
nsDependentCString arg(argv[i]);
|
||||
if (*argv[i] == '-' && arg.Length() > 1) {
|
||||
// clean up previous flag
|
||||
if (!flag.IsEmpty()) {
|
||||
aOptions.AddEntry(flag);
|
||||
flag.Truncate();
|
||||
}
|
||||
|
||||
// get next flag
|
||||
flag = Substring(arg, 1, arg.Length() - 1);
|
||||
}
|
||||
else {
|
||||
txOptionEntry* option = aOptions.AddEntry(flag);
|
||||
if (option) {
|
||||
option->mValues.AppendCString(nsCString(arg));
|
||||
}
|
||||
flag.Truncate();
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag.IsEmpty()) {
|
||||
aOptions.AddEntry(flag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The TransforMiiX command line interface
|
||||
*/
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!txXSLTProcessor::init())
|
||||
return 1;
|
||||
|
||||
txOptions options;
|
||||
if (NS_FAILED(options.Init(4))) {
|
||||
return 1;
|
||||
}
|
||||
parseCommandLine(argc, argv, options);
|
||||
|
||||
if (!options.GetEntry(NS_LITERAL_CSTRING("q"))) {
|
||||
NS_NAMED_LITERAL_CSTRING(copyright, "(C) 1999 The MITRE Corporation, Keith Visco, and contributors");
|
||||
cerr << "TransforMiiX ";
|
||||
cerr << MOZILLA_VERSION << endl;
|
||||
cerr << copyright.get() << endl;
|
||||
//-- print banner line
|
||||
PRUint32 fillSize = copyright.Length() + 1;
|
||||
PRUint32 counter;
|
||||
for (counter = 0; counter < fillSize; ++counter)
|
||||
cerr << '-';
|
||||
cerr << endl << endl;
|
||||
}
|
||||
|
||||
if (options.GetEntry(NS_LITERAL_CSTRING("h"))) {
|
||||
printHelp();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-- handle output stream
|
||||
ostream* resultOutput = &cout;
|
||||
ofstream resultFileStream;
|
||||
|
||||
txOptionEntry* option = options.GetEntry(NS_LITERAL_CSTRING("o"));
|
||||
if (option &&
|
||||
option->mValues.Count() > 0 &&
|
||||
!option->mValues[0]->Equals(NS_LITERAL_CSTRING("-"))) {
|
||||
resultFileStream.open(option->mValues[0]->get(), ios::out);
|
||||
if (!resultFileStream) {
|
||||
cerr << "error opening output file: ";
|
||||
cerr << option->mValues[0]->get() << endl;
|
||||
return -1;
|
||||
}
|
||||
resultOutput = &resultFileStream;
|
||||
}
|
||||
|
||||
option = options.GetEntry(NS_LITERAL_CSTRING("i"));
|
||||
if (!option || option->mValues.Count() == 0) {
|
||||
cerr << "you must specify at least a source XML path" << endl;
|
||||
printUsage();
|
||||
return -1;
|
||||
}
|
||||
|
||||
SimpleErrorObserver obs;
|
||||
txStandaloneXSLTProcessor proc;
|
||||
|
||||
txOptionEntry* styleOption = options.GetEntry(NS_LITERAL_CSTRING("s"));
|
||||
if (!styleOption || styleOption->mValues.Count() == 0) {
|
||||
rv = proc.transform(*option->mValues[0], *resultOutput, obs);
|
||||
}
|
||||
else {
|
||||
// XXX TODO: Handle multiple stylesheets
|
||||
rv = proc.transform(*option->mValues[0], *styleOption->mValues[0],
|
||||
*resultOutput, obs);
|
||||
}
|
||||
|
||||
resultFileStream.close();
|
||||
txXSLTProcessor::shutdown();
|
||||
rv = NS_ShutdownXPCOM(nsnull);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
/* -*- 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):
|
||||
* Axel Hecht <axel@pike.org> (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 ***** */
|
||||
|
||||
/**
|
||||
* Driver for running XSLTMark on standalone
|
||||
*
|
||||
* See http://www.datapower.com/XSLTMark/
|
||||
*/
|
||||
|
||||
#include "txStandaloneStylesheetCompiler.h"
|
||||
#include "txStandaloneXSLTProcessor.h"
|
||||
#include "nsXPCOM.h"
|
||||
#include "xmExternalDriver.hpp"
|
||||
|
||||
class txDriverProcessor : public txStandaloneXSLTProcessor,
|
||||
public xmExternalDriver
|
||||
{
|
||||
public:
|
||||
txDriverProcessor() : mXML(0), mOut(0)
|
||||
{
|
||||
}
|
||||
|
||||
int loadStylesheet (char * filename)
|
||||
{
|
||||
NS_ConvertASCIItoUCS2 path(filename);
|
||||
nsresult rv =
|
||||
TX_CompileStylesheetPath(path, getter_AddRefs(mStylesheet));
|
||||
return NS_SUCCEEDED(rv) ? 0 : 1;
|
||||
}
|
||||
int setInputDocument (char * filename)
|
||||
{
|
||||
delete mXML;
|
||||
mXML = parsePath(nsDependentCString(filename), mObserver);
|
||||
return mXML ? 0 : 1;
|
||||
}
|
||||
int openOutput (char * outputFilename)
|
||||
{
|
||||
mOut = new ofstream(outputFilename);
|
||||
return mXML ? 0 : 1;
|
||||
}
|
||||
int runTransform ()
|
||||
{
|
||||
if (!mXML || !mStylesheet || !mOut)
|
||||
return 1;
|
||||
nsresult rv = transform(mXML, mStylesheet, *mOut, mObserver);
|
||||
return NS_FAILED(rv);
|
||||
}
|
||||
int closeOutput ()
|
||||
{
|
||||
if (mOut)
|
||||
mOut->close();
|
||||
delete mOut;
|
||||
mOut = 0;
|
||||
return 0;
|
||||
}
|
||||
int terminate()
|
||||
{
|
||||
delete mXML;
|
||||
mXML = 0;
|
||||
if (mOut && mOut->is_open())
|
||||
mOut->close();
|
||||
delete mOut;
|
||||
mOut = 0;
|
||||
return 0;
|
||||
}
|
||||
~txDriverProcessor()
|
||||
{
|
||||
delete mXML;
|
||||
delete mOut;
|
||||
}
|
||||
private:
|
||||
Document *mXML;
|
||||
nsRefPtr<txStylesheet> mStylesheet;
|
||||
SimpleErrorObserver mObserver;
|
||||
ofstream* mOut;
|
||||
};
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
txDriverProcessor driver;
|
||||
NS_InitXPCOM2(nsnull, nsnull, nsnull);
|
||||
if (!txDriverProcessor::init())
|
||||
return 1;
|
||||
driver.main (argc, argv);
|
||||
txDriverProcessor::shutdown();
|
||||
NS_ShutdownXPCOM(nsnull);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
#
|
||||
# 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 Axel Hecht.
|
||||
# Portions created by Axel Hecht are Copyright (C) Axel Hecht.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <axel@pike.org>
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = transformiix
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
$(NULL)
|
||||
ifndef TX_EXE
|
||||
REQUIRES += dom \
|
||||
content \
|
||||
widget \
|
||||
unicharutil \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
DIRS = dom parser
|
||||
|
||||
CPPSRCS = XMLDOMUtils.cpp XMLUtils.cpp
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir)/../base -I$(srcdir)/dom -I$(srcdir)/../xpath \
|
||||
-I$(srcdir)/../xslt
|
||||
|
||||
libs:: $(OBJS)
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco
|
||||
* -- original author.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "XMLDOMUtils.h"
|
||||
#include "dom.h"
|
||||
#include "nsString.h"
|
||||
|
||||
void XMLDOMUtils::getNodeValue(Node* aNode, nsAString& aResult)
|
||||
{
|
||||
if (!aNode)
|
||||
return;
|
||||
|
||||
unsigned short nodeType = aNode->getNodeType();
|
||||
|
||||
switch (nodeType) {
|
||||
case Node::ATTRIBUTE_NODE:
|
||||
case Node::CDATA_SECTION_NODE:
|
||||
case Node::COMMENT_NODE:
|
||||
case Node::PROCESSING_INSTRUCTION_NODE:
|
||||
case Node::TEXT_NODE:
|
||||
{
|
||||
nsAutoString nodeValue;
|
||||
aNode->getNodeValue(nodeValue);
|
||||
aResult.Append(nodeValue);
|
||||
break;
|
||||
}
|
||||
case Node::DOCUMENT_NODE:
|
||||
{
|
||||
getNodeValue(((Document*)aNode)->getDocumentElement(),
|
||||
aResult);
|
||||
break;
|
||||
}
|
||||
case Node::DOCUMENT_FRAGMENT_NODE:
|
||||
case Node::ELEMENT_NODE:
|
||||
{
|
||||
Node* tmpNode = aNode->getFirstChild();
|
||||
while (tmpNode) {
|
||||
nodeType = tmpNode->getNodeType();
|
||||
if ((nodeType == Node::TEXT_NODE) ||
|
||||
(nodeType == Node::CDATA_SECTION_NODE)) {
|
||||
nsAutoString nodeValue;
|
||||
tmpNode->getNodeValue(nodeValue);
|
||||
aResult.Append(nodeValue);
|
||||
}
|
||||
else if (nodeType == Node::ELEMENT_NODE) {
|
||||
getNodeValue(tmpNode, aResult);
|
||||
}
|
||||
tmpNode = tmpNode->getNextSibling();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco
|
||||
* -- original author.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TRANSFRMX_XMLDOMUTILS_H
|
||||
#define TRANSFRMX_XMLDOMUTILS_H
|
||||
|
||||
#include "baseutils.h"
|
||||
|
||||
class Node;
|
||||
class nsAString;
|
||||
|
||||
/*
|
||||
* A utility class for use with XML DOM implementations
|
||||
*/
|
||||
class XMLDOMUtils
|
||||
{
|
||||
public:
|
||||
/*
|
||||
* Appends the value of the given node to aResult.
|
||||
*/
|
||||
static void getNodeValue(Node* aNode, nsAString& aResult);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,661 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
* Lidong, lidong520@263.net
|
||||
* -- unicode bug fix
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* XML utility classes
|
||||
*/
|
||||
|
||||
#include "XMLUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "txAtoms.h"
|
||||
#include "txStringUtils.h"
|
||||
#include "txNamespaceMap.h"
|
||||
|
||||
/**
|
||||
* Helper class for checking and partioning of QNames
|
||||
*/
|
||||
class txQNameParser
|
||||
{
|
||||
public:
|
||||
enum QResult {
|
||||
eBrokenName,
|
||||
eOneName,
|
||||
eTwoNames
|
||||
};
|
||||
QResult parse(const nsAString::const_iterator& aStart,
|
||||
const nsAString::const_iterator& aEnd);
|
||||
nsAString::const_iterator mColon;
|
||||
private:
|
||||
enum {
|
||||
eInitial,
|
||||
ePrefixNC,
|
||||
eColon,
|
||||
eNameNC,
|
||||
eBroken
|
||||
} mState;
|
||||
};
|
||||
|
||||
txQNameParser::QResult
|
||||
txQNameParser::parse(const nsAString::const_iterator& aStart,
|
||||
const nsAString::const_iterator& aEnd)
|
||||
{
|
||||
nsAString::const_iterator chunk(aStart);
|
||||
mState = eInitial;
|
||||
|
||||
PRUint32 size = 0, i = 0;
|
||||
for ( ; chunk != aEnd; chunk.advance(size)) {
|
||||
const PRUnichar* buf = chunk.get();
|
||||
size = chunk.size_forward();
|
||||
|
||||
// fragment at 'buf' is 'size' characters long
|
||||
for (i = 0; i < size; ++i) {
|
||||
const PRUnichar ch = buf[i];
|
||||
switch(mState) {
|
||||
case eInitial:
|
||||
mState = XMLUtils::isLetter(ch) ? ePrefixNC : eBroken;
|
||||
break;
|
||||
case ePrefixNC:
|
||||
if (ch == ':') {
|
||||
mState = eColon;
|
||||
mColon = chunk;
|
||||
mColon.advance(i);
|
||||
}
|
||||
else if (!XMLUtils::isNCNameChar(ch)) {
|
||||
mState = eBroken;
|
||||
}
|
||||
break;
|
||||
case eColon:
|
||||
mState = XMLUtils::isLetter(ch) ? eNameNC : eBroken;
|
||||
break;
|
||||
case eNameNC:
|
||||
if (!XMLUtils::isNCNameChar(ch)) {
|
||||
mState = eBroken;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
NS_WARNING("Should not happen");
|
||||
}
|
||||
if (mState == eBroken) {
|
||||
return eBrokenName;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mState == eNameNC) {
|
||||
return eTwoNames;
|
||||
}
|
||||
if (mState == ePrefixNC) {
|
||||
return eOneName;
|
||||
}
|
||||
return eBrokenName;
|
||||
}
|
||||
|
||||
nsresult
|
||||
txExpandedName::init(const nsAString& aQName, txNamespaceMap* aResolver,
|
||||
MBool aUseDefault)
|
||||
{
|
||||
nsAString::const_iterator start, end;
|
||||
aQName.BeginReading(start);
|
||||
aQName.EndReading(end);
|
||||
txQNameParser p;
|
||||
txQNameParser::QResult qr = p.parse(start, end);
|
||||
|
||||
if (qr == txQNameParser::eBrokenName) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (qr == txQNameParser::eTwoNames) {
|
||||
nsCOMPtr<nsIAtom> prefix =
|
||||
do_GetAtom(Substring(start, p.mColon));
|
||||
PRInt32 namespaceID = aResolver->lookupNamespace(prefix);
|
||||
if (namespaceID == kNameSpaceID_Unknown)
|
||||
return NS_ERROR_FAILURE;
|
||||
mNamespaceID = namespaceID;
|
||||
|
||||
mLocalName = do_GetAtom(Substring(++p.mColon, end));
|
||||
}
|
||||
else {
|
||||
mLocalName = do_GetAtom(aQName);
|
||||
if (aUseDefault)
|
||||
mNamespaceID = aResolver->lookupNamespace(0);
|
||||
else
|
||||
mNamespaceID = kNameSpaceID_None;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//------------------------------/
|
||||
//- Implementation of XMLUtils -/
|
||||
//------------------------------/
|
||||
|
||||
nsresult
|
||||
XMLUtils::splitXMLName(const nsAString& aName, nsIAtom** aPrefix,
|
||||
nsIAtom** aLocalName)
|
||||
{
|
||||
nsAString::const_iterator start, end;
|
||||
aName.BeginReading(start);
|
||||
aName.EndReading(end);
|
||||
txQNameParser p;
|
||||
txQNameParser::QResult qr = p.parse(start, end);
|
||||
|
||||
if (qr == txQNameParser::eBrokenName) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (qr == txQNameParser::eTwoNames) {
|
||||
*aPrefix = NS_NewAtom(Substring(start, p.mColon));
|
||||
*aLocalName = NS_NewAtom(Substring(++p.mColon, end));
|
||||
}
|
||||
else {
|
||||
*aPrefix = nsnull;
|
||||
*aLocalName = NS_NewAtom(aName);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void XMLUtils::getPrefix(const nsAString& src, nsIAtom** dest)
|
||||
{
|
||||
// Anything preceding ':' is the namespace part of the name
|
||||
PRInt32 idx = src.FindChar(':');
|
||||
if (idx == kNotFound) {
|
||||
*dest = nsnull;
|
||||
return;
|
||||
}
|
||||
|
||||
NS_ASSERTION(idx > 0, "This QName looks invalid.");
|
||||
*dest = NS_NewAtom(Substring(src, 0, idx));
|
||||
}
|
||||
|
||||
const nsDependentSubstring XMLUtils::getLocalPart(const nsAString& src)
|
||||
{
|
||||
// Anything after ':' is the local part of the name
|
||||
PRInt32 idx = src.FindChar(':');
|
||||
if (idx == kNotFound) {
|
||||
return Substring(src, 0, src.Length());
|
||||
}
|
||||
|
||||
NS_ASSERTION(idx > 0, "This QName looks invalid.");
|
||||
return Substring(src, idx + 1, src.Length() - (idx + 1));
|
||||
}
|
||||
|
||||
void XMLUtils::getLocalPart(const nsAString& src, nsIAtom** dest)
|
||||
{
|
||||
*dest = NS_NewAtom(getLocalPart(src));
|
||||
}
|
||||
|
||||
MBool XMLUtils::isValidQName(const nsAString& aName)
|
||||
{
|
||||
nsAString::const_iterator start, end;
|
||||
aName.BeginReading(start);
|
||||
aName.EndReading(end);
|
||||
txQNameParser p;
|
||||
txQNameParser::QResult qr = p.parse(start, end);
|
||||
|
||||
return qr != txQNameParser::eBrokenName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given string has only whitespace characters
|
||||
*/
|
||||
PRBool XMLUtils::isWhitespace(const nsAFlatString& aText)
|
||||
{
|
||||
nsAFlatString::const_char_iterator start, end;
|
||||
aText.BeginReading(start);
|
||||
aText.EndReading(end);
|
||||
for ( ; start != end; ++start) {
|
||||
if (!isWhitespace(*start)) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given node's value has only whitespace characters
|
||||
*/
|
||||
PRBool XMLUtils::isWhitespace(Node* aNode)
|
||||
{
|
||||
nsAutoString text;
|
||||
aNode->getNodeValue(text);
|
||||
return isWhitespace(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the value of a XML processing instruction
|
||||
**/
|
||||
void XMLUtils::normalizePIValue(nsAString& piValue)
|
||||
{
|
||||
nsAutoString origValue(piValue);
|
||||
PRUint32 origLength = origValue.Length();
|
||||
PRUint32 conversionLoop = 0;
|
||||
PRUnichar prevCh = 0;
|
||||
piValue.Truncate();
|
||||
|
||||
while (conversionLoop < origLength) {
|
||||
PRUnichar ch = origValue.CharAt(conversionLoop);
|
||||
switch (ch) {
|
||||
case '>':
|
||||
{
|
||||
if (prevCh == '?') {
|
||||
piValue.Append(PRUnichar(' '));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
piValue.Append(ch);
|
||||
prevCh = ch;
|
||||
++conversionLoop;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Walks up the document tree and returns true if the closest xml:space
|
||||
* attribute is "preserve"
|
||||
*/
|
||||
//static
|
||||
MBool XMLUtils::getXMLSpacePreserve(Node* aNode)
|
||||
{
|
||||
NS_ASSERTION(aNode, "Calling preserveXMLSpace with NULL node!");
|
||||
|
||||
nsAutoString value;
|
||||
Node* parent = aNode;
|
||||
while (parent) {
|
||||
if (parent->getNodeType() == Node::ELEMENT_NODE) {
|
||||
Element* elem = (Element*)parent;
|
||||
if (elem->getAttr(txXMLAtoms::space, kNameSpaceID_XML, value)) {
|
||||
if (TX_StringEqualsAtom(value, txXMLAtoms::preserve)) {
|
||||
return MB_TRUE;
|
||||
}
|
||||
if (TX_StringEqualsAtom(value, txXMLAtoms::_default)) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
parent = parent->getParentNode();
|
||||
}
|
||||
return MB_FALSE;
|
||||
}
|
||||
|
||||
// macros for inclusion of char range headers
|
||||
#define TX_CHAR_RANGE(ch, a, b) if (ch < a) return MB_FALSE; \
|
||||
if (ch <= b) return MB_TRUE
|
||||
#define TX_MATCH_CHAR(ch, a) if (ch < a) return MB_FALSE; \
|
||||
if (ch == a) return MB_TRUE
|
||||
|
||||
MBool XMLUtils::isDigit(PRUnichar ch)
|
||||
{
|
||||
TX_CHAR_RANGE(ch, 0x0030, 0x0039); /* '0'-'9' */
|
||||
TX_CHAR_RANGE(ch, 0x0660, 0x0669);
|
||||
TX_CHAR_RANGE(ch, 0x06F0, 0x06F9);
|
||||
TX_CHAR_RANGE(ch, 0x0966, 0x096F);
|
||||
TX_CHAR_RANGE(ch, 0x09E6, 0x09EF);
|
||||
TX_CHAR_RANGE(ch, 0x0A66, 0x0A6F);
|
||||
TX_CHAR_RANGE(ch, 0x0AE6, 0x0AEF);
|
||||
TX_CHAR_RANGE(ch, 0x0B66, 0x0B6F);
|
||||
TX_CHAR_RANGE(ch, 0x0BE7, 0x0BEF);
|
||||
TX_CHAR_RANGE(ch, 0x0C66, 0x0C6F);
|
||||
TX_CHAR_RANGE(ch, 0x0CE6, 0x0CEF);
|
||||
TX_CHAR_RANGE(ch, 0x0D66, 0x0D6F);
|
||||
TX_CHAR_RANGE(ch, 0x0E50, 0x0E59);
|
||||
TX_CHAR_RANGE(ch, 0x0ED0, 0x0ED9);
|
||||
TX_CHAR_RANGE(ch, 0x0F20, 0x0F29);
|
||||
return MB_FALSE;
|
||||
}
|
||||
|
||||
MBool XMLUtils::isLetter(PRUnichar ch)
|
||||
{
|
||||
/* Letter = BaseChar | Ideographic; and _ */
|
||||
TX_CHAR_RANGE(ch, 0x0041, 0x005A);
|
||||
TX_MATCH_CHAR(ch, 0x005F); /* '_' */
|
||||
TX_CHAR_RANGE(ch, 0x0061, 0x007A);
|
||||
TX_CHAR_RANGE(ch, 0x00C0, 0x00D6);
|
||||
TX_CHAR_RANGE(ch, 0x00D8, 0x00F6);
|
||||
TX_CHAR_RANGE(ch, 0x00F8, 0x00FF);
|
||||
TX_CHAR_RANGE(ch, 0x0100, 0x0131);
|
||||
TX_CHAR_RANGE(ch, 0x0134, 0x013E);
|
||||
TX_CHAR_RANGE(ch, 0x0141, 0x0148);
|
||||
TX_CHAR_RANGE(ch, 0x014A, 0x017E);
|
||||
TX_CHAR_RANGE(ch, 0x0180, 0x01C3);
|
||||
TX_CHAR_RANGE(ch, 0x01CD, 0x01F0);
|
||||
TX_CHAR_RANGE(ch, 0x01F4, 0x01F5);
|
||||
TX_CHAR_RANGE(ch, 0x01FA, 0x0217);
|
||||
TX_CHAR_RANGE(ch, 0x0250, 0x02A8);
|
||||
TX_CHAR_RANGE(ch, 0x02BB, 0x02C1);
|
||||
TX_MATCH_CHAR(ch, 0x0386);
|
||||
TX_CHAR_RANGE(ch, 0x0388, 0x038A);
|
||||
TX_MATCH_CHAR(ch, 0x038C);
|
||||
TX_CHAR_RANGE(ch, 0x038E, 0x03A1);
|
||||
TX_CHAR_RANGE(ch, 0x03A3, 0x03CE);
|
||||
TX_CHAR_RANGE(ch, 0x03D0, 0x03D6);
|
||||
TX_MATCH_CHAR(ch, 0x03DA);
|
||||
TX_MATCH_CHAR(ch, 0x03DC);
|
||||
TX_MATCH_CHAR(ch, 0x03DE);
|
||||
TX_MATCH_CHAR(ch, 0x03E0);
|
||||
TX_CHAR_RANGE(ch, 0x03E2, 0x03F3);
|
||||
TX_CHAR_RANGE(ch, 0x0401, 0x040C);
|
||||
TX_CHAR_RANGE(ch, 0x040E, 0x044F);
|
||||
TX_CHAR_RANGE(ch, 0x0451, 0x045C);
|
||||
TX_CHAR_RANGE(ch, 0x045E, 0x0481);
|
||||
TX_CHAR_RANGE(ch, 0x0490, 0x04C4);
|
||||
TX_CHAR_RANGE(ch, 0x04C7, 0x04C8);
|
||||
TX_CHAR_RANGE(ch, 0x04CB, 0x04CC);
|
||||
TX_CHAR_RANGE(ch, 0x04D0, 0x04EB);
|
||||
TX_CHAR_RANGE(ch, 0x04EE, 0x04F5);
|
||||
TX_CHAR_RANGE(ch, 0x04F8, 0x04F9);
|
||||
TX_CHAR_RANGE(ch, 0x0531, 0x0556);
|
||||
TX_MATCH_CHAR(ch, 0x0559);
|
||||
TX_CHAR_RANGE(ch, 0x0561, 0x0586);
|
||||
TX_CHAR_RANGE(ch, 0x05D0, 0x05EA);
|
||||
TX_CHAR_RANGE(ch, 0x05F0, 0x05F2);
|
||||
TX_CHAR_RANGE(ch, 0x0621, 0x063A);
|
||||
TX_CHAR_RANGE(ch, 0x0641, 0x064A);
|
||||
TX_CHAR_RANGE(ch, 0x0671, 0x06B7);
|
||||
TX_CHAR_RANGE(ch, 0x06BA, 0x06BE);
|
||||
TX_CHAR_RANGE(ch, 0x06C0, 0x06CE);
|
||||
TX_CHAR_RANGE(ch, 0x06D0, 0x06D3);
|
||||
TX_MATCH_CHAR(ch, 0x06D5);
|
||||
TX_CHAR_RANGE(ch, 0x06E5, 0x06E6);
|
||||
TX_CHAR_RANGE(ch, 0x0905, 0x0939);
|
||||
TX_MATCH_CHAR(ch, 0x093D);
|
||||
TX_CHAR_RANGE(ch, 0x0958, 0x0961);
|
||||
TX_CHAR_RANGE(ch, 0x0985, 0x098C);
|
||||
TX_CHAR_RANGE(ch, 0x098F, 0x0990);
|
||||
TX_CHAR_RANGE(ch, 0x0993, 0x09A8);
|
||||
TX_CHAR_RANGE(ch, 0x09AA, 0x09B0);
|
||||
TX_MATCH_CHAR(ch, 0x09B2);
|
||||
TX_CHAR_RANGE(ch, 0x09B6, 0x09B9);
|
||||
TX_CHAR_RANGE(ch, 0x09DC, 0x09DD);
|
||||
TX_CHAR_RANGE(ch, 0x09DF, 0x09E1);
|
||||
TX_CHAR_RANGE(ch, 0x09F0, 0x09F1);
|
||||
TX_CHAR_RANGE(ch, 0x0A05, 0x0A0A);
|
||||
TX_CHAR_RANGE(ch, 0x0A0F, 0x0A10);
|
||||
TX_CHAR_RANGE(ch, 0x0A13, 0x0A28);
|
||||
TX_CHAR_RANGE(ch, 0x0A2A, 0x0A30);
|
||||
TX_CHAR_RANGE(ch, 0x0A32, 0x0A33);
|
||||
TX_CHAR_RANGE(ch, 0x0A35, 0x0A36);
|
||||
TX_CHAR_RANGE(ch, 0x0A38, 0x0A39);
|
||||
TX_CHAR_RANGE(ch, 0x0A59, 0x0A5C);
|
||||
TX_MATCH_CHAR(ch, 0x0A5E);
|
||||
TX_CHAR_RANGE(ch, 0x0A72, 0x0A74);
|
||||
TX_CHAR_RANGE(ch, 0x0A85, 0x0A8B);
|
||||
TX_MATCH_CHAR(ch, 0x0A8D);
|
||||
TX_CHAR_RANGE(ch, 0x0A8F, 0x0A91);
|
||||
TX_CHAR_RANGE(ch, 0x0A93, 0x0AA8);
|
||||
TX_CHAR_RANGE(ch, 0x0AAA, 0x0AB0);
|
||||
TX_CHAR_RANGE(ch, 0x0AB2, 0x0AB3);
|
||||
TX_CHAR_RANGE(ch, 0x0AB5, 0x0AB9);
|
||||
TX_MATCH_CHAR(ch, 0x0ABD);
|
||||
TX_MATCH_CHAR(ch, 0x0AE0);
|
||||
TX_CHAR_RANGE(ch, 0x0B05, 0x0B0C);
|
||||
TX_CHAR_RANGE(ch, 0x0B0F, 0x0B10);
|
||||
TX_CHAR_RANGE(ch, 0x0B13, 0x0B28);
|
||||
TX_CHAR_RANGE(ch, 0x0B2A, 0x0B30);
|
||||
TX_CHAR_RANGE(ch, 0x0B32, 0x0B33);
|
||||
TX_CHAR_RANGE(ch, 0x0B36, 0x0B39);
|
||||
TX_MATCH_CHAR(ch, 0x0B3D);
|
||||
TX_CHAR_RANGE(ch, 0x0B5C, 0x0B5D);
|
||||
TX_CHAR_RANGE(ch, 0x0B5F, 0x0B61);
|
||||
TX_CHAR_RANGE(ch, 0x0B85, 0x0B8A);
|
||||
TX_CHAR_RANGE(ch, 0x0B8E, 0x0B90);
|
||||
TX_CHAR_RANGE(ch, 0x0B92, 0x0B95);
|
||||
TX_CHAR_RANGE(ch, 0x0B99, 0x0B9A);
|
||||
TX_MATCH_CHAR(ch, 0x0B9C);
|
||||
TX_CHAR_RANGE(ch, 0x0B9E, 0x0B9F);
|
||||
TX_CHAR_RANGE(ch, 0x0BA3, 0x0BA4);
|
||||
TX_CHAR_RANGE(ch, 0x0BA8, 0x0BAA);
|
||||
TX_CHAR_RANGE(ch, 0x0BAE, 0x0BB5);
|
||||
TX_CHAR_RANGE(ch, 0x0BB7, 0x0BB9);
|
||||
TX_CHAR_RANGE(ch, 0x0C05, 0x0C0C);
|
||||
TX_CHAR_RANGE(ch, 0x0C0E, 0x0C10);
|
||||
TX_CHAR_RANGE(ch, 0x0C12, 0x0C28);
|
||||
TX_CHAR_RANGE(ch, 0x0C2A, 0x0C33);
|
||||
TX_CHAR_RANGE(ch, 0x0C35, 0x0C39);
|
||||
TX_CHAR_RANGE(ch, 0x0C60, 0x0C61);
|
||||
TX_CHAR_RANGE(ch, 0x0C85, 0x0C8C);
|
||||
TX_CHAR_RANGE(ch, 0x0C8E, 0x0C90);
|
||||
TX_CHAR_RANGE(ch, 0x0C92, 0x0CA8);
|
||||
TX_CHAR_RANGE(ch, 0x0CAA, 0x0CB3);
|
||||
TX_CHAR_RANGE(ch, 0x0CB5, 0x0CB9);
|
||||
TX_MATCH_CHAR(ch, 0x0CDE);
|
||||
TX_CHAR_RANGE(ch, 0x0CE0, 0x0CE1);
|
||||
TX_CHAR_RANGE(ch, 0x0D05, 0x0D0C);
|
||||
TX_CHAR_RANGE(ch, 0x0D0E, 0x0D10);
|
||||
TX_CHAR_RANGE(ch, 0x0D12, 0x0D28);
|
||||
TX_CHAR_RANGE(ch, 0x0D2A, 0x0D39);
|
||||
TX_CHAR_RANGE(ch, 0x0D60, 0x0D61);
|
||||
TX_CHAR_RANGE(ch, 0x0E01, 0x0E2E);
|
||||
TX_MATCH_CHAR(ch, 0x0E30);
|
||||
TX_CHAR_RANGE(ch, 0x0E32, 0x0E33);
|
||||
TX_CHAR_RANGE(ch, 0x0E40, 0x0E45);
|
||||
TX_CHAR_RANGE(ch, 0x0E81, 0x0E82);
|
||||
TX_MATCH_CHAR(ch, 0x0E84);
|
||||
TX_CHAR_RANGE(ch, 0x0E87, 0x0E88);
|
||||
TX_MATCH_CHAR(ch, 0x0E8A);
|
||||
TX_MATCH_CHAR(ch, 0x0E8D);
|
||||
TX_CHAR_RANGE(ch, 0x0E94, 0x0E97);
|
||||
TX_CHAR_RANGE(ch, 0x0E99, 0x0E9F);
|
||||
TX_CHAR_RANGE(ch, 0x0EA1, 0x0EA3);
|
||||
TX_MATCH_CHAR(ch, 0x0EA5);
|
||||
TX_MATCH_CHAR(ch, 0x0EA7);
|
||||
TX_CHAR_RANGE(ch, 0x0EAA, 0x0EAB);
|
||||
TX_CHAR_RANGE(ch, 0x0EAD, 0x0EAE);
|
||||
TX_MATCH_CHAR(ch, 0x0EB0);
|
||||
TX_CHAR_RANGE(ch, 0x0EB2, 0x0EB3);
|
||||
TX_MATCH_CHAR(ch, 0x0EBD);
|
||||
TX_CHAR_RANGE(ch, 0x0EC0, 0x0EC4);
|
||||
TX_CHAR_RANGE(ch, 0x0F40, 0x0F47);
|
||||
TX_CHAR_RANGE(ch, 0x0F49, 0x0F69);
|
||||
TX_CHAR_RANGE(ch, 0x10A0, 0x10C5);
|
||||
TX_CHAR_RANGE(ch, 0x10D0, 0x10F6);
|
||||
TX_MATCH_CHAR(ch, 0x1100);
|
||||
TX_CHAR_RANGE(ch, 0x1102, 0x1103);
|
||||
TX_CHAR_RANGE(ch, 0x1105, 0x1107);
|
||||
TX_MATCH_CHAR(ch, 0x1109);
|
||||
TX_CHAR_RANGE(ch, 0x110B, 0x110C);
|
||||
TX_CHAR_RANGE(ch, 0x110E, 0x1112);
|
||||
TX_MATCH_CHAR(ch, 0x113C);
|
||||
TX_MATCH_CHAR(ch, 0x113E);
|
||||
TX_MATCH_CHAR(ch, 0x1140);
|
||||
TX_MATCH_CHAR(ch, 0x114C);
|
||||
TX_MATCH_CHAR(ch, 0x114E);
|
||||
TX_MATCH_CHAR(ch, 0x1150);
|
||||
TX_CHAR_RANGE(ch, 0x1154, 0x1155);
|
||||
TX_MATCH_CHAR(ch, 0x1159);
|
||||
TX_CHAR_RANGE(ch, 0x115F, 0x1161);
|
||||
TX_MATCH_CHAR(ch, 0x1163);
|
||||
TX_MATCH_CHAR(ch, 0x1165);
|
||||
TX_MATCH_CHAR(ch, 0x1167);
|
||||
TX_MATCH_CHAR(ch, 0x1169);
|
||||
TX_CHAR_RANGE(ch, 0x116D, 0x116E);
|
||||
TX_CHAR_RANGE(ch, 0x1172, 0x1173);
|
||||
TX_MATCH_CHAR(ch, 0x1175);
|
||||
TX_MATCH_CHAR(ch, 0x119E);
|
||||
TX_MATCH_CHAR(ch, 0x11A8);
|
||||
TX_MATCH_CHAR(ch, 0x11AB);
|
||||
TX_CHAR_RANGE(ch, 0x11AE, 0x11AF);
|
||||
TX_CHAR_RANGE(ch, 0x11B7, 0x11B8);
|
||||
TX_MATCH_CHAR(ch, 0x11BA);
|
||||
TX_CHAR_RANGE(ch, 0x11BC, 0x11C2);
|
||||
TX_MATCH_CHAR(ch, 0x11EB);
|
||||
TX_MATCH_CHAR(ch, 0x11F0);
|
||||
TX_MATCH_CHAR(ch, 0x11F9);
|
||||
TX_CHAR_RANGE(ch, 0x1E00, 0x1E9B);
|
||||
TX_CHAR_RANGE(ch, 0x1EA0, 0x1EF9);
|
||||
TX_CHAR_RANGE(ch, 0x1F00, 0x1F15);
|
||||
TX_CHAR_RANGE(ch, 0x1F18, 0x1F1D);
|
||||
TX_CHAR_RANGE(ch, 0x1F20, 0x1F45);
|
||||
TX_CHAR_RANGE(ch, 0x1F48, 0x1F4D);
|
||||
TX_CHAR_RANGE(ch, 0x1F50, 0x1F57);
|
||||
TX_MATCH_CHAR(ch, 0x1F59);
|
||||
TX_MATCH_CHAR(ch, 0x1F5B);
|
||||
TX_MATCH_CHAR(ch, 0x1F5D);
|
||||
TX_CHAR_RANGE(ch, 0x1F5F, 0x1F7D);
|
||||
TX_CHAR_RANGE(ch, 0x1F80, 0x1FB4);
|
||||
TX_CHAR_RANGE(ch, 0x1FB6, 0x1FBC);
|
||||
TX_MATCH_CHAR(ch, 0x1FBE);
|
||||
TX_CHAR_RANGE(ch, 0x1FC2, 0x1FC4);
|
||||
TX_CHAR_RANGE(ch, 0x1FC6, 0x1FCC);
|
||||
TX_CHAR_RANGE(ch, 0x1FD0, 0x1FD3);
|
||||
TX_CHAR_RANGE(ch, 0x1FD6, 0x1FDB);
|
||||
TX_CHAR_RANGE(ch, 0x1FE0, 0x1FEC);
|
||||
TX_CHAR_RANGE(ch, 0x1FF2, 0x1FF4);
|
||||
TX_CHAR_RANGE(ch, 0x1FF6, 0x1FFC);
|
||||
TX_MATCH_CHAR(ch, 0x2126);
|
||||
TX_CHAR_RANGE(ch, 0x212A, 0x212B);
|
||||
TX_MATCH_CHAR(ch, 0x212E);
|
||||
TX_CHAR_RANGE(ch, 0x2180, 0x2182);
|
||||
TX_MATCH_CHAR(ch, 0x3007);
|
||||
TX_CHAR_RANGE(ch, 0x3021, 0x3029);
|
||||
TX_CHAR_RANGE(ch, 0x3041, 0x3094);
|
||||
TX_CHAR_RANGE(ch, 0x30A1, 0x30FA);
|
||||
TX_CHAR_RANGE(ch, 0x3105, 0x312C);
|
||||
TX_CHAR_RANGE(ch, 0x4E00, 0x9FA5);
|
||||
TX_CHAR_RANGE(ch, 0xAC00, 0xD7A3);
|
||||
return MB_FALSE;
|
||||
}
|
||||
|
||||
MBool XMLUtils::isNCNameChar(PRUnichar ch)
|
||||
{
|
||||
/* NCNameChar = Letter | Digit | '.' | '-' | '_' |
|
||||
CombiningChar | Extender */
|
||||
if (isLetter(ch)) return MB_TRUE; /* Letter | '_' */
|
||||
|
||||
TX_CHAR_RANGE(ch, 0x002D, 0x002E); /* '-' | '.' */
|
||||
|
||||
if (isDigit(ch)) return MB_TRUE; /* Digit */
|
||||
|
||||
TX_MATCH_CHAR(ch, 0x00B7);
|
||||
TX_MATCH_CHAR(ch, 0x02D0);
|
||||
TX_MATCH_CHAR(ch, 0x02D1);
|
||||
TX_CHAR_RANGE(ch, 0x0300, 0x0345);
|
||||
TX_CHAR_RANGE(ch, 0x0360, 0x0361);
|
||||
TX_MATCH_CHAR(ch, 0x0387);
|
||||
TX_CHAR_RANGE(ch, 0x0483, 0x0486);
|
||||
TX_CHAR_RANGE(ch, 0x0591, 0x05A1);
|
||||
TX_CHAR_RANGE(ch, 0x05A3, 0x05B9);
|
||||
TX_CHAR_RANGE(ch, 0x05BB, 0x05BD);
|
||||
TX_MATCH_CHAR(ch, 0x05BF);
|
||||
TX_CHAR_RANGE(ch, 0x05C1, 0x05C2);
|
||||
TX_MATCH_CHAR(ch, 0x05C4);
|
||||
TX_MATCH_CHAR(ch, 0x0640);
|
||||
TX_CHAR_RANGE(ch, 0x064B, 0x0652);
|
||||
TX_MATCH_CHAR(ch, 0x0670);
|
||||
TX_CHAR_RANGE(ch, 0x06D6, 0x06DC);
|
||||
TX_CHAR_RANGE(ch, 0x06DD, 0x06DF);
|
||||
TX_CHAR_RANGE(ch, 0x06E0, 0x06E4);
|
||||
TX_CHAR_RANGE(ch, 0x06E7, 0x06E8);
|
||||
TX_CHAR_RANGE(ch, 0x06EA, 0x06ED);
|
||||
TX_CHAR_RANGE(ch, 0x0901, 0x0903);
|
||||
TX_MATCH_CHAR(ch, 0x093C);
|
||||
TX_CHAR_RANGE(ch, 0x093E, 0x094C);
|
||||
TX_MATCH_CHAR(ch, 0x094D);
|
||||
TX_CHAR_RANGE(ch, 0x0951, 0x0954);
|
||||
TX_CHAR_RANGE(ch, 0x0962, 0x0963);
|
||||
TX_CHAR_RANGE(ch, 0x0981, 0x0983);
|
||||
TX_MATCH_CHAR(ch, 0x09BC);
|
||||
TX_MATCH_CHAR(ch, 0x09BE);
|
||||
TX_MATCH_CHAR(ch, 0x09BF);
|
||||
TX_CHAR_RANGE(ch, 0x09C0, 0x09C4);
|
||||
TX_CHAR_RANGE(ch, 0x09C7, 0x09C8);
|
||||
TX_CHAR_RANGE(ch, 0x09CB, 0x09CD);
|
||||
TX_MATCH_CHAR(ch, 0x09D7);
|
||||
TX_CHAR_RANGE(ch, 0x09E2, 0x09E3);
|
||||
TX_MATCH_CHAR(ch, 0x0A02);
|
||||
TX_MATCH_CHAR(ch, 0x0A3C);
|
||||
TX_MATCH_CHAR(ch, 0x0A3E);
|
||||
TX_MATCH_CHAR(ch, 0x0A3F);
|
||||
TX_CHAR_RANGE(ch, 0x0A40, 0x0A42);
|
||||
TX_CHAR_RANGE(ch, 0x0A47, 0x0A48);
|
||||
TX_CHAR_RANGE(ch, 0x0A4B, 0x0A4D);
|
||||
TX_CHAR_RANGE(ch, 0x0A70, 0x0A71);
|
||||
TX_CHAR_RANGE(ch, 0x0A81, 0x0A83);
|
||||
TX_MATCH_CHAR(ch, 0x0ABC);
|
||||
TX_CHAR_RANGE(ch, 0x0ABE, 0x0AC5);
|
||||
TX_CHAR_RANGE(ch, 0x0AC7, 0x0AC9);
|
||||
TX_CHAR_RANGE(ch, 0x0ACB, 0x0ACD);
|
||||
TX_CHAR_RANGE(ch, 0x0B01, 0x0B03);
|
||||
TX_MATCH_CHAR(ch, 0x0B3C);
|
||||
TX_CHAR_RANGE(ch, 0x0B3E, 0x0B43);
|
||||
TX_CHAR_RANGE(ch, 0x0B47, 0x0B48);
|
||||
TX_CHAR_RANGE(ch, 0x0B4B, 0x0B4D);
|
||||
TX_CHAR_RANGE(ch, 0x0B56, 0x0B57);
|
||||
TX_CHAR_RANGE(ch, 0x0B82, 0x0B83);
|
||||
TX_CHAR_RANGE(ch, 0x0BBE, 0x0BC2);
|
||||
TX_CHAR_RANGE(ch, 0x0BC6, 0x0BC8);
|
||||
TX_CHAR_RANGE(ch, 0x0BCA, 0x0BCD);
|
||||
TX_MATCH_CHAR(ch, 0x0BD7);
|
||||
TX_CHAR_RANGE(ch, 0x0C01, 0x0C03);
|
||||
TX_CHAR_RANGE(ch, 0x0C3E, 0x0C44);
|
||||
TX_CHAR_RANGE(ch, 0x0C46, 0x0C48);
|
||||
TX_CHAR_RANGE(ch, 0x0C4A, 0x0C4D);
|
||||
TX_CHAR_RANGE(ch, 0x0C55, 0x0C56);
|
||||
TX_CHAR_RANGE(ch, 0x0C82, 0x0C83);
|
||||
TX_CHAR_RANGE(ch, 0x0CBE, 0x0CC4);
|
||||
TX_CHAR_RANGE(ch, 0x0CC6, 0x0CC8);
|
||||
TX_CHAR_RANGE(ch, 0x0CCA, 0x0CCD);
|
||||
TX_CHAR_RANGE(ch, 0x0CD5, 0x0CD6);
|
||||
TX_CHAR_RANGE(ch, 0x0D02, 0x0D03);
|
||||
TX_CHAR_RANGE(ch, 0x0D3E, 0x0D43);
|
||||
TX_CHAR_RANGE(ch, 0x0D46, 0x0D48);
|
||||
TX_CHAR_RANGE(ch, 0x0D4A, 0x0D4D);
|
||||
TX_MATCH_CHAR(ch, 0x0D57);
|
||||
TX_MATCH_CHAR(ch, 0x0E31);
|
||||
TX_CHAR_RANGE(ch, 0x0E34, 0x0E3A);
|
||||
TX_MATCH_CHAR(ch, 0x0E46);
|
||||
TX_CHAR_RANGE(ch, 0x0E47, 0x0E4E);
|
||||
TX_MATCH_CHAR(ch, 0x0EB1);
|
||||
TX_CHAR_RANGE(ch, 0x0EB4, 0x0EB9);
|
||||
TX_CHAR_RANGE(ch, 0x0EBB, 0x0EBC);
|
||||
TX_MATCH_CHAR(ch, 0x0EC6);
|
||||
TX_CHAR_RANGE(ch, 0x0EC8, 0x0ECD);
|
||||
TX_CHAR_RANGE(ch, 0x0F18, 0x0F19);
|
||||
TX_MATCH_CHAR(ch, 0x0F35);
|
||||
TX_MATCH_CHAR(ch, 0x0F37);
|
||||
TX_MATCH_CHAR(ch, 0x0F39);
|
||||
TX_MATCH_CHAR(ch, 0x0F3E);
|
||||
TX_MATCH_CHAR(ch, 0x0F3F);
|
||||
TX_CHAR_RANGE(ch, 0x0F71, 0x0F84);
|
||||
TX_CHAR_RANGE(ch, 0x0F86, 0x0F8B);
|
||||
TX_CHAR_RANGE(ch, 0x0F90, 0x0F95);
|
||||
TX_MATCH_CHAR(ch, 0x0F97);
|
||||
TX_CHAR_RANGE(ch, 0x0F99, 0x0FAD);
|
||||
TX_CHAR_RANGE(ch, 0x0FB1, 0x0FB7);
|
||||
TX_MATCH_CHAR(ch, 0x0FB9);
|
||||
TX_CHAR_RANGE(ch, 0x20D0, 0x20DC);
|
||||
TX_MATCH_CHAR(ch, 0x20E1);
|
||||
TX_MATCH_CHAR(ch, 0x3005);
|
||||
TX_CHAR_RANGE(ch, 0x302A, 0x302F);
|
||||
TX_CHAR_RANGE(ch, 0x3031, 0x3035);
|
||||
TX_MATCH_CHAR(ch, 0x3099);
|
||||
TX_MATCH_CHAR(ch, 0x309A);
|
||||
TX_CHAR_RANGE(ch, 0x309D, 0x309E);
|
||||
TX_CHAR_RANGE(ch, 0x30FC, 0x30FE);
|
||||
return MB_FALSE;
|
||||
}
|
||||
@@ -1,162 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* 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 The MITRE Corporation.
|
||||
* Portions created by MITRE are Copyright (C) 1999 The MITRE Corporation.
|
||||
*
|
||||
* Portions created by Keith Visco as a Non MITRE employee,
|
||||
* (C) 1999 Keith Visco. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Keith Visco, kvisco@ziplink.net
|
||||
* -- original author.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* An XML Utility class
|
||||
**/
|
||||
|
||||
#ifndef MITRE_XMLUTILS_H
|
||||
#define MITRE_XMLUTILS_H
|
||||
|
||||
#include "baseutils.h"
|
||||
#include "dom.h"
|
||||
#include "nsDependentSubstring.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "txError.h"
|
||||
|
||||
class txNamespaceMap;
|
||||
|
||||
class txExpandedName {
|
||||
public:
|
||||
txExpandedName() : mNamespaceID(kNameSpaceID_None)
|
||||
{
|
||||
}
|
||||
|
||||
txExpandedName(PRInt32 aNsID,
|
||||
nsIAtom* aLocalName) : mNamespaceID(aNsID),
|
||||
mLocalName(aLocalName)
|
||||
{
|
||||
}
|
||||
|
||||
txExpandedName(const txExpandedName& aOther) :
|
||||
mNamespaceID(aOther.mNamespaceID),
|
||||
mLocalName(aOther.mLocalName)
|
||||
{
|
||||
}
|
||||
|
||||
~txExpandedName()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult init(const nsAString& aQName, txNamespaceMap* aResolver,
|
||||
MBool aUseDefault);
|
||||
|
||||
void reset()
|
||||
{
|
||||
mNamespaceID = kNameSpaceID_None;
|
||||
mLocalName = nsnull;
|
||||
}
|
||||
|
||||
PRBool isNull()
|
||||
{
|
||||
return mNamespaceID == kNameSpaceID_None && !mLocalName;
|
||||
}
|
||||
|
||||
txExpandedName& operator = (const txExpandedName& rhs)
|
||||
{
|
||||
mNamespaceID = rhs.mNamespaceID;
|
||||
mLocalName = rhs.mLocalName;
|
||||
return *this;
|
||||
}
|
||||
|
||||
MBool operator == (const txExpandedName& rhs) const
|
||||
{
|
||||
return ((mLocalName == rhs.mLocalName) &&
|
||||
(mNamespaceID == rhs.mNamespaceID));
|
||||
}
|
||||
|
||||
MBool operator != (const txExpandedName& rhs) const
|
||||
{
|
||||
return ((mLocalName != rhs.mLocalName) ||
|
||||
(mNamespaceID != rhs.mNamespaceID));
|
||||
}
|
||||
|
||||
PRInt32 mNamespaceID;
|
||||
nsCOMPtr<nsIAtom> mLocalName;
|
||||
};
|
||||
|
||||
class XMLUtils {
|
||||
|
||||
public:
|
||||
static nsresult splitXMLName(const nsAString& aName, nsIAtom** aPrefix,
|
||||
nsIAtom** aLocalName);
|
||||
static void getPrefix(const nsAString& src, nsIAtom** dest);
|
||||
static const nsDependentSubstring getLocalPart(const nsAString& src);
|
||||
static void getLocalPart(const nsAString& src, nsIAtom** dest);
|
||||
|
||||
/**
|
||||
* Returns true if the given string is a valid XML QName
|
||||
*/
|
||||
static MBool isValidQName(const nsAString& aName);
|
||||
|
||||
/*
|
||||
* Returns true if the given character is whitespace.
|
||||
*/
|
||||
static MBool isWhitespace(const PRUnichar& aChar)
|
||||
{
|
||||
return (aChar <= ' ' &&
|
||||
(aChar == ' ' || aChar == '\r' ||
|
||||
aChar == '\n'|| aChar == '\t'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given string has only whitespace characters
|
||||
*/
|
||||
static PRBool isWhitespace(const nsAFlatString& aText);
|
||||
|
||||
/**
|
||||
* Returns true if the given node's DOM nodevalue has only whitespace
|
||||
* characters
|
||||
*/
|
||||
static PRBool isWhitespace(Node* aNode);
|
||||
|
||||
/**
|
||||
* Normalizes the value of a XML processingInstruction
|
||||
**/
|
||||
static void normalizePIValue(nsAString& attValue);
|
||||
|
||||
/*
|
||||
* Returns true if the given character represents a numeric letter (digit).
|
||||
*/
|
||||
static MBool isDigit(PRUnichar ch);
|
||||
|
||||
/*
|
||||
* Returns true if the given character represents an Alpha letter
|
||||
*/
|
||||
static MBool isLetter(PRUnichar ch);
|
||||
|
||||
/*
|
||||
* Returns true if the given character is an allowable NCName character
|
||||
*/
|
||||
static MBool isNCNameChar(PRUnichar ch);
|
||||
|
||||
/*
|
||||
* Walks up the document tree and returns true if the closest xml:space
|
||||
* attribute is "preserve"
|
||||
*/
|
||||
static MBool getXMLSpacePreserve(Node* aNode);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,35 +0,0 @@
|
||||
#
|
||||
# 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 Axel Hecht.
|
||||
# Portions created by Axel Hecht are Copyright (C) Axel Hecht.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <axel@pike.org>
|
||||
#
|
||||
|
||||
DEPTH = ../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
ifndef TX_EXE
|
||||
DIRS = mozImpl
|
||||
else
|
||||
DIRS = standalone
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Peter Van der Beken
|
||||
* -- original author
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __TX_DOM_WRAPPER__
|
||||
#define __TX_DOM_WRAPPER__
|
||||
|
||||
#ifdef TX_EXE
|
||||
#include "standalone/dom.h"
|
||||
#else
|
||||
#include "mozImpl/mozilladom.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,51 +0,0 @@
|
||||
#
|
||||
# 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 Axel Hecht.
|
||||
# Portions created by Axel Hecht are Copyright (C) Axel Hecht.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Axel Hecht <axel@pike.org>
|
||||
#
|
||||
|
||||
DEPTH = ../../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = transformiix
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
dom \
|
||||
content \
|
||||
widget \
|
||||
necko \
|
||||
unicharutil \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = MozillaAttr.cpp \
|
||||
MozillaDocument.cpp \
|
||||
MozillaElement.cpp \
|
||||
MozillaNamedNodeMap.cpp \
|
||||
MozillaNode.cpp \
|
||||
MozillaProcInstruction.cpp
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
INCLUDES += -I$(srcdir)/../../../base -I$(srcdir)/../../ \
|
||||
-I$(srcdir)/../../../xpath -I$(srcdir)/../../../xslt
|
||||
|
||||
libs:: $(OBJS)
|
||||
@@ -1,100 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
* Contributor(s): Tom Kneeland
|
||||
* Peter Van der Beken <peter.vanderbeken@pandora.be>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of the wrapper class to convert the Mozilla nsIDOMAttr
|
||||
* interface into a TransforMiiX Attr interface.
|
||||
*/
|
||||
|
||||
#include "mozilladom.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsString.h"
|
||||
|
||||
/**
|
||||
* Construct a wrapper with the specified Mozilla object and document owner.
|
||||
*
|
||||
* @param aAttr the nsIDOMAttr you want to wrap
|
||||
* @param aOwner the document that owns this object
|
||||
*/
|
||||
Attr::Attr(nsIDOMAttr* aAttr, Document* aOwner) : Node(aAttr, aOwner)
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> parent;
|
||||
aAttr->GetOwnerElement(getter_AddRefs(parent));
|
||||
mParent = do_QueryInterface(parent);
|
||||
|
||||
nsAutoString nameString;
|
||||
aAttr->GetLocalName(nameString);
|
||||
mLocalName = do_GetAtom(nameString);
|
||||
|
||||
nsAutoString ns;
|
||||
aAttr->GetNamespaceURI(ns);
|
||||
mNamespaceID = kNameSpaceID_None;
|
||||
if (!ns.IsEmpty()) {
|
||||
NS_ASSERTION(gTxNameSpaceManager,"No namespace manager");
|
||||
if (gTxNameSpaceManager) {
|
||||
gTxNameSpaceManager->GetNameSpaceID(ns, mNamespaceID);
|
||||
}
|
||||
}
|
||||
mNSId = mNamespaceID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
Attr::~Attr()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMAttr::GetOwnerElement to get the owning element
|
||||
*
|
||||
* @return the xpath parent
|
||||
*/
|
||||
Node* Attr::getXPathParent()
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> ownerElem =
|
||||
do_QueryInterface(mParent);
|
||||
if (!ownerElem) {
|
||||
return nsnull;
|
||||
}
|
||||
return mOwnerDocument->createElement(ownerElem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the local name atomized
|
||||
*
|
||||
* @return the node's localname atom
|
||||
*/
|
||||
MBool Attr::getLocalName(nsIAtom** aLocalName)
|
||||
{
|
||||
if (!aLocalName) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
*aLocalName = mLocalName;
|
||||
NS_ENSURE_TRUE(*aLocalName, MB_FALSE);
|
||||
NS_ADDREF(*aLocalName);
|
||||
return MB_TRUE;
|
||||
}
|
||||
@@ -1,492 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
* Contributor(s): Tom Kneeland
|
||||
* Peter Van der Beken <peter.vanderbeken@pandora.be>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of the wrapper class to convert the Mozilla nsIDOMDocument
|
||||
* interface into a TransforMIIX Document interface.
|
||||
*/
|
||||
|
||||
#include "mozilladom.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMProcessingInstruction.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMText.h"
|
||||
|
||||
// Need to determine if these are well-chosen.
|
||||
#define WRAPPER_INITIAL_SIZE 256
|
||||
#define ATTR_INITIAL_SIZE 128
|
||||
|
||||
struct txWrapperHashEntry : public PLDHashEntryHdr
|
||||
{
|
||||
MozillaObjectWrapper* mWrapper;
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(const void *)
|
||||
txWrapperHashGetKey(PLDHashTable *table, PLDHashEntryHdr *entry)
|
||||
{
|
||||
txWrapperHashEntry *e =
|
||||
NS_STATIC_CAST(txWrapperHashEntry *, entry);
|
||||
return e->mWrapper->getNSObj();
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
txWrapperHashClearEntry(PLDHashTable *table,
|
||||
PLDHashEntryHdr *entry)
|
||||
{
|
||||
txWrapperHashEntry *e = NS_STATIC_CAST(txWrapperHashEntry *, entry);
|
||||
// Don't delete the document wrapper, this is only called from its
|
||||
// destructor.
|
||||
if (e->mWrapper != table->data) {
|
||||
delete e->mWrapper;
|
||||
}
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PRBool)
|
||||
txWrapperHashMatchEntry(PLDHashTable *table,
|
||||
const PLDHashEntryHdr *entry,
|
||||
const void *key)
|
||||
{
|
||||
const txWrapperHashEntry *e =
|
||||
NS_STATIC_CAST(const txWrapperHashEntry *, entry);
|
||||
return e->mWrapper->getNSObj() == key;
|
||||
}
|
||||
|
||||
struct txAttributeHashEntry : public PLDHashEntryHdr
|
||||
{
|
||||
Attr* mAttribute;
|
||||
};
|
||||
|
||||
PR_STATIC_CALLBACK(const void *)
|
||||
txAttributeHashGetKey(PLDHashTable *table, PLDHashEntryHdr *entry)
|
||||
{
|
||||
txAttributeHashEntry *e =
|
||||
NS_STATIC_CAST(txAttributeHashEntry *, entry);
|
||||
return e->mAttribute->GetKey();
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PLDHashNumber)
|
||||
txAttributeHashHashKey(PLDHashTable *table, const void *key)
|
||||
{
|
||||
const txAttributeNodeKey* attrKey =
|
||||
NS_STATIC_CAST(const txAttributeNodeKey *, key);
|
||||
return attrKey->GetHash();
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(PRBool)
|
||||
txAttributeHashMatchEntry(PLDHashTable *table,
|
||||
const PLDHashEntryHdr *entry,
|
||||
const void *key)
|
||||
{
|
||||
const txAttributeHashEntry *e =
|
||||
NS_STATIC_CAST(const txAttributeHashEntry *, entry);
|
||||
const txAttributeNodeKey* key1 = e->mAttribute->GetKey();
|
||||
const txAttributeNodeKey* key2 =
|
||||
NS_STATIC_CAST(const txAttributeNodeKey *, key);
|
||||
|
||||
return key1->Equals(*key2);
|
||||
}
|
||||
|
||||
PR_STATIC_CALLBACK(void)
|
||||
txAttributeHashClearEntry(PLDHashTable *table,
|
||||
PLDHashEntryHdr *entry)
|
||||
{
|
||||
txAttributeHashEntry *e =
|
||||
NS_STATIC_CAST(txAttributeHashEntry *, entry);
|
||||
delete e->mAttribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a wrapper with the specified Mozilla object. The caller is
|
||||
* responsible for deleting the wrapper object!
|
||||
*
|
||||
* @param aDocument the nsIDOMDocument you want to wrap
|
||||
*/
|
||||
Document::Document(nsIDOMDocument* aDocument) : Node(aDocument, this)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mInHashTableDeletion = PR_FALSE;
|
||||
#endif
|
||||
|
||||
static PLDHashTableOps wrapper_hash_table_ops =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
txWrapperHashGetKey,
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
txWrapperHashMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
txWrapperHashClearEntry,
|
||||
PL_DHashFinalizeStub,
|
||||
};
|
||||
PRBool success = PL_DHashTableInit(&mWrapperHashTable,
|
||||
&wrapper_hash_table_ops,
|
||||
this,
|
||||
sizeof(txWrapperHashEntry),
|
||||
WRAPPER_INITIAL_SIZE);
|
||||
if (success) {
|
||||
txWrapperHashEntry* entry =
|
||||
NS_STATIC_CAST(txWrapperHashEntry *,
|
||||
PL_DHashTableOperate(&mWrapperHashTable,
|
||||
aDocument,
|
||||
PL_DHASH_ADD));
|
||||
|
||||
NS_ASSERTION(entry, "Out-of-memory creating an entry.");
|
||||
if (entry && !entry->mWrapper) {
|
||||
entry->mWrapper = this;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mWrapperHashTable.ops = nsnull;
|
||||
}
|
||||
|
||||
static PLDHashTableOps attribute_hash_table_ops =
|
||||
{
|
||||
PL_DHashAllocTable,
|
||||
PL_DHashFreeTable,
|
||||
txAttributeHashGetKey,
|
||||
txAttributeHashHashKey,
|
||||
txAttributeHashMatchEntry,
|
||||
PL_DHashMoveEntryStub,
|
||||
txAttributeHashClearEntry,
|
||||
PL_DHashFinalizeStub,
|
||||
};
|
||||
success = PL_DHashTableInit(&mAttributeNodes,
|
||||
&attribute_hash_table_ops,
|
||||
nsnull,
|
||||
sizeof(txAttributeHashEntry),
|
||||
ATTR_INITIAL_SIZE);
|
||||
if (!success) {
|
||||
mAttributeNodes.ops = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
Document::~Document()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
mInHashTableDeletion = PR_TRUE;
|
||||
#endif
|
||||
if (mAttributeNodes.ops) {
|
||||
PL_DHashTableFinish(&mAttributeNodes);
|
||||
}
|
||||
if (mWrapperHashTable.ops) {
|
||||
PL_DHashTableFinish(&mWrapperHashTable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This macro can be used to declare a createWrapper implementation
|
||||
* for the supplied wrapper class.
|
||||
*/
|
||||
#define IMPL_CREATE_WRAPPER(_txClass) \
|
||||
IMPL_CREATE_WRAPPER2(_txClass, create##_txClass)
|
||||
|
||||
/**
|
||||
* This macro can be used to declare a createWrapper implementation
|
||||
* for the supplied wrapper class. The function parameter defines
|
||||
* the function name for the implementation function.
|
||||
*/
|
||||
#define IMPL_CREATE_WRAPPER2(_txClass, _function) \
|
||||
_txClass* Document::_function(nsIDOM##_txClass* aNsObject) \
|
||||
{ \
|
||||
NS_ASSERTION(aNsObject, \
|
||||
"Need a Mozilla object to create a wrapper."); \
|
||||
if (!mWrapperHashTable.ops) { \
|
||||
return new _txClass(aNsObject, this); \
|
||||
} \
|
||||
\
|
||||
txWrapperHashEntry* entry = \
|
||||
NS_STATIC_CAST(txWrapperHashEntry *, \
|
||||
PL_DHashTableOperate(&mWrapperHashTable, \
|
||||
aNsObject, \
|
||||
PL_DHASH_ADD)); \
|
||||
\
|
||||
NS_ASSERTION(entry, "Out-of-memory creating an entry."); \
|
||||
if (!entry) { \
|
||||
return nsnull; \
|
||||
} \
|
||||
if (!entry->mWrapper) { \
|
||||
entry->mWrapper = new _txClass(aNsObject, this); \
|
||||
NS_ASSERTION(entry->mWrapper, \
|
||||
"Out-of-memory creating a wrapper."); \
|
||||
if (!entry->mWrapper) { \
|
||||
PL_DHashTableRawRemove(&mWrapperHashTable, entry); \
|
||||
return nsnull; \
|
||||
} \
|
||||
} \
|
||||
return NS_STATIC_CAST(_txClass*, entry->mWrapper); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMDocument::GetDocumentElement to get the document's
|
||||
* DocumentElement.
|
||||
*
|
||||
* @return the document element
|
||||
*/
|
||||
Element* Document::getDocumentElement()
|
||||
{
|
||||
NSI_FROM_TX(Document);
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
nsDocument->GetDocumentElement(getter_AddRefs(element));
|
||||
if (!element) {
|
||||
return nsnull;
|
||||
}
|
||||
return createElement(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMDocument::GetElementById to get Element with ID.
|
||||
*
|
||||
* @param aID the name of ID referencing the element
|
||||
*
|
||||
* @return the Element
|
||||
*/
|
||||
Element* Document::getElementById(const nsAString& aID)
|
||||
{
|
||||
NSI_FROM_TX(Document);
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
nsDocument->GetElementById(aID, getter_AddRefs(element));
|
||||
if (!element) {
|
||||
return nsnull;
|
||||
}
|
||||
return createElement(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a wrapper for a nsIDOMElement, reuses an existing wrapper if possible.
|
||||
*
|
||||
* @param aElement the nsIDOMElement you want to wrap
|
||||
*
|
||||
* @return the Element
|
||||
*/
|
||||
IMPL_CREATE_WRAPPER(Element)
|
||||
|
||||
/**
|
||||
* Create a wrapper for a nsIDOMAttr, reuses an existing wrapper if possible.
|
||||
*
|
||||
* @param aAttr the nsIDOMAttr you want to wrap
|
||||
*
|
||||
* @return the Attribute
|
||||
*/
|
||||
Attr* Document::createAttribute(nsIDOMAttr* aAttr)
|
||||
{
|
||||
NS_ASSERTION(aAttr,
|
||||
"Need a Mozilla object to create a wrapper.");
|
||||
if (!aAttr) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMElement> owner;
|
||||
aAttr->GetOwnerElement(getter_AddRefs(owner));
|
||||
nsCOMPtr<nsIContent> parent = do_QueryInterface(owner);
|
||||
|
||||
nsAutoString nameString;
|
||||
aAttr->GetLocalName(nameString);
|
||||
nsCOMPtr<nsIAtom> localName = do_GetAtom(nameString);
|
||||
|
||||
nsAutoString ns;
|
||||
aAttr->GetNamespaceURI(ns);
|
||||
PRInt32 namespaceID = kNameSpaceID_None;
|
||||
if (!ns.IsEmpty()) {
|
||||
NS_ASSERTION(gTxNameSpaceManager, "No namespace manager");
|
||||
if (gTxNameSpaceManager) {
|
||||
gTxNameSpaceManager->GetNameSpaceID(ns, namespaceID);
|
||||
}
|
||||
}
|
||||
|
||||
if (!mAttributeNodes.ops) {
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
txAttributeNodeKey hashKey(parent, localName, namespaceID);
|
||||
|
||||
txAttributeHashEntry* entry =
|
||||
NS_STATIC_CAST(txAttributeHashEntry *,
|
||||
PL_DHashTableOperate(&mAttributeNodes,
|
||||
&hashKey,
|
||||
PL_DHASH_ADD));
|
||||
|
||||
NS_ASSERTION(entry, "Out-of-memory creating an entry.");
|
||||
if (!entry) {
|
||||
return nsnull;
|
||||
}
|
||||
if (!entry->mAttribute) {
|
||||
entry->mAttribute = new Attr(aAttr, this);
|
||||
NS_ASSERTION(entry->mAttribute,
|
||||
"Out-of-memory creating an attribute wrapper.");
|
||||
if (!entry->mAttribute) {
|
||||
PL_DHashTableRawRemove(&mAttributeNodes, entry);
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
return entry->mAttribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a wrapper for a nsIDOMProcessingInstruction, reuses an existing
|
||||
* wrapper if possible.
|
||||
*
|
||||
* @param aPi the nsIDOMProcessingInstruction you want to wrap
|
||||
*
|
||||
* @return the ProcessingInstruction node
|
||||
*/
|
||||
IMPL_CREATE_WRAPPER(ProcessingInstruction)
|
||||
|
||||
/**
|
||||
* Create a wrapper for a nsIDOMNode, reuses an existing wrapper if possible.
|
||||
*
|
||||
* @param aNode the nsIDOMNode you want to wrap
|
||||
*
|
||||
* @return the Node
|
||||
*/
|
||||
IMPL_CREATE_WRAPPER(Node)
|
||||
|
||||
/**
|
||||
* Create a wrapper for a nsIDOMNamedNodeMap, reuses an existing wrapper if
|
||||
* possible.
|
||||
*
|
||||
* @param aMap the nsIDOMNamedNodeMap you want to wrap
|
||||
*
|
||||
* @return the NamedNodeMap
|
||||
*/
|
||||
IMPL_CREATE_WRAPPER(NamedNodeMap)
|
||||
|
||||
/**
|
||||
* Create a wrapper for a nsIDOMNode, reuses an existing wrapper if possible.
|
||||
* This function creates the right kind of wrapper depending on the type of
|
||||
* the node.
|
||||
*
|
||||
* @param aNode the nsIDOMNode you want to wrap
|
||||
*
|
||||
* @return the Node
|
||||
*/
|
||||
Node* Document::createWrapper(nsIDOMNode* aNode)
|
||||
{
|
||||
NS_ASSERTION(aNode,
|
||||
"Need a Mozilla object to create a wrapper.");
|
||||
|
||||
PRUint16 nodeType = 0;
|
||||
aNode->GetNodeType(&nodeType);
|
||||
|
||||
// Look up wrapper in the hash, except for attribute nodes since
|
||||
// they're in a separate attribute hash. Let them be handled in
|
||||
// createAttribute by falling through to the switch below.
|
||||
if (nodeType != nsIDOMNode::ATTRIBUTE_NODE &&
|
||||
mWrapperHashTable.ops) {
|
||||
txWrapperHashEntry* entry =
|
||||
NS_STATIC_CAST(txWrapperHashEntry *,
|
||||
PL_DHashTableOperate(&mWrapperHashTable,
|
||||
aNode,
|
||||
PL_DHASH_LOOKUP));
|
||||
if (entry->mWrapper) {
|
||||
return NS_STATIC_CAST(Node*, entry->mWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
switch (nodeType)
|
||||
{
|
||||
case nsIDOMNode::ELEMENT_NODE:
|
||||
{
|
||||
nsIDOMElement* element;
|
||||
CallQueryInterface(aNode, &element);
|
||||
Element* txElement = createElement(element);
|
||||
NS_RELEASE(element);
|
||||
return txElement;
|
||||
}
|
||||
case nsIDOMNode::ATTRIBUTE_NODE:
|
||||
{
|
||||
nsIDOMAttr* attr;
|
||||
CallQueryInterface(aNode, &attr);
|
||||
Attr* txAttr = createAttribute(attr);
|
||||
NS_RELEASE(attr);
|
||||
return txAttr;
|
||||
}
|
||||
case nsIDOMNode::CDATA_SECTION_NODE:
|
||||
case nsIDOMNode::COMMENT_NODE:
|
||||
case nsIDOMNode::DOCUMENT_FRAGMENT_NODE:
|
||||
case nsIDOMNode::DOCUMENT_TYPE_NODE:
|
||||
case nsIDOMNode::ENTITY_REFERENCE_NODE:
|
||||
case nsIDOMNode::ENTITY_NODE:
|
||||
case nsIDOMNode::NOTATION_NODE:
|
||||
case nsIDOMNode::TEXT_NODE:
|
||||
{
|
||||
return createNode(aNode);
|
||||
}
|
||||
case nsIDOMNode::PROCESSING_INSTRUCTION_NODE:
|
||||
{
|
||||
nsIDOMProcessingInstruction* pi;
|
||||
CallQueryInterface(aNode, &pi);
|
||||
ProcessingInstruction* txPi = createProcessingInstruction(pi);
|
||||
NS_RELEASE(pi);
|
||||
return txPi;
|
||||
}
|
||||
case nsIDOMNode::DOCUMENT_NODE:
|
||||
{
|
||||
if (aNode == mMozObject) {
|
||||
return this;
|
||||
}
|
||||
NS_ASSERTION(0, "We don't support creating new documents.");
|
||||
return nsnull;
|
||||
}
|
||||
default:
|
||||
{
|
||||
NS_WARNING("Don't know nodetype. This could be a failure.");
|
||||
return createNode(aNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 Document::namespaceURIToID(const nsAString& aNamespaceURI)
|
||||
{
|
||||
PRInt32 namesspaceID = kNameSpaceID_Unknown;
|
||||
if (gTxNameSpaceManager) {
|
||||
gTxNameSpaceManager->RegisterNameSpace(aNamespaceURI,
|
||||
namesspaceID);
|
||||
}
|
||||
return namesspaceID;
|
||||
}
|
||||
|
||||
void Document::namespaceIDToURI(PRInt32 aNamespaceID, nsAString& aNamespaceURI)
|
||||
{
|
||||
if (gTxNameSpaceManager) {
|
||||
gTxNameSpaceManager->GetNameSpaceURI(aNamespaceID,
|
||||
aNamespaceURI);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
PRBool MozillaObjectWrapper::inHashTableDeletion()
|
||||
{
|
||||
return mOwnerDocument->mInHashTableDeletion;
|
||||
}
|
||||
#endif
|
||||
@@ -1,121 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
* Contributor(s): Tom Kneeland
|
||||
* Peter Van der Beken <peter.vanderbeken@pandora.be>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of the wrapper class to convert the Mozilla nsIDOMElement
|
||||
* interface into a TransforMiiX Element interface.
|
||||
*/
|
||||
|
||||
#include "mozilladom.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsINodeInfo.h"
|
||||
|
||||
/**
|
||||
* Construct a wrapper with the specified Mozilla object and document owner.
|
||||
*
|
||||
* @param aElement the nsIDOMElement you want to wrap
|
||||
* @param aOwner the document that owns this object
|
||||
*/
|
||||
Element::Element(nsIDOMElement* aElement, Document* aOwner) :
|
||||
Node(aElement, aOwner)
|
||||
{
|
||||
nsCOMPtr<nsIContent> cont(do_QueryInterface(aElement));
|
||||
NS_ASSERTION(cont, "Element doesn't implement nsIContent");
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
cont->GetNodeInfo(*getter_AddRefs(nodeInfo));
|
||||
NS_ASSERTION(nodeInfo, "a element without nodeinfo");
|
||||
nodeInfo->GetNamespaceID(mNamespaceID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
Element::~Element()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMElement::SetAttributeNS to set an attribute to the specified
|
||||
* value.
|
||||
*
|
||||
* @param aNamespaceURI the URI of the namespace of the attribute
|
||||
* @param aName the name of the attribute you want to set
|
||||
* @param aValue the value you want to set the attribute to
|
||||
*/
|
||||
void Element::setAttributeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aName,
|
||||
const nsAString& aValue)
|
||||
{
|
||||
NSI_FROM_TX(Element);
|
||||
nsElement->SetAttributeNS(aNamespaceURI, aName, aValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIContent::GetAttr for the localname and nsID.
|
||||
*/
|
||||
MBool Element::getAttr(nsIAtom* aLocalName, PRInt32 aNSID,
|
||||
nsAString& aValue)
|
||||
{
|
||||
nsCOMPtr<nsIContent> cont(do_QueryInterface(mMozObject));
|
||||
NS_ASSERTION(cont, "Element doesn't implement nsIContent");
|
||||
if (!cont || !cont->HasAttr(aNSID, aLocalName)) {
|
||||
aValue.Truncate();
|
||||
return MB_FALSE;
|
||||
}
|
||||
nsresult rv;
|
||||
rv = cont->GetAttr(aNSID, aLocalName, aValue);
|
||||
NS_ENSURE_SUCCESS(rv, MB_FALSE);
|
||||
return MB_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIContent::GetAttr for the localname and nsID.
|
||||
*/
|
||||
MBool Element::hasAttr(nsIAtom* aLocalName, PRInt32 aNSID)
|
||||
{
|
||||
nsCOMPtr<nsIContent> cont(do_QueryInterface(mMozObject));
|
||||
NS_ASSERTION(cont, "Element doesn't implement nsIContent");
|
||||
if (!cont) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
return cont->HasAttr(aNSID, aLocalName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the local name atomized
|
||||
*
|
||||
* @return the node's localname atom
|
||||
*/
|
||||
MBool Element::getLocalName(nsIAtom** aLocalName)
|
||||
{
|
||||
NS_ENSURE_TRUE(aLocalName, MB_FALSE);
|
||||
nsCOMPtr<nsIContent> cont(do_QueryInterface(mMozObject));
|
||||
NS_ASSERTION(cont, "Element doesn't implement nsIContent");
|
||||
if (!cont) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
cont->GetTag(*aLocalName);
|
||||
return MB_TRUE;
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
* Contributor(s): Tom Kneeland
|
||||
* Peter Van der Beken <peter.vanderbeken@pandora.be>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of the wrapper class to convert the Mozilla
|
||||
* nsIDOMNamedNodeMap interface into a TransforMIIX NamedNodeMap interface.
|
||||
*/
|
||||
|
||||
#include "mozilladom.h"
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
||||
/**
|
||||
* Construct a wrapper with the specified Mozilla object and document owner.
|
||||
*
|
||||
* @param aNamedNodeMap the nsIDOMNamedNodeMap you want to wrap
|
||||
* @param aOwner the document that owns this object
|
||||
*/
|
||||
NamedNodeMap::NamedNodeMap(nsIDOMNamedNodeMap* aNamedNodeMap,
|
||||
Document* aOwner) :
|
||||
MozillaObjectWrapper(aNamedNodeMap, aOwner)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
NamedNodeMap::~NamedNodeMap()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMNamedNodeMap::GetNamedItem to get the node with the specified
|
||||
* name.
|
||||
*
|
||||
* @param aName the name to look for
|
||||
*
|
||||
* @return the node with the specified name
|
||||
*/
|
||||
Node* NamedNodeMap::getNamedItem(const nsAString& aName)
|
||||
{
|
||||
NSI_FROM_TX(NamedNodeMap);
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsNamedNodeMap->GetNamedItem(aName, getter_AddRefs(node));
|
||||
if (!node) {
|
||||
return nsnull;
|
||||
}
|
||||
return mOwnerDocument->createWrapper(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMNamedNodeMap::Item to retrieve the node at the given index.
|
||||
*
|
||||
* @param aIndex the index of the node you want to retrieve
|
||||
*
|
||||
* @return the node at the given index
|
||||
*/
|
||||
Node* NamedNodeMap::item(PRUint32 aIndex)
|
||||
{
|
||||
NSI_FROM_TX(NamedNodeMap);
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsNamedNodeMap->Item(aIndex, getter_AddRefs(node));
|
||||
if (!node) {
|
||||
return nsnull;
|
||||
}
|
||||
return mOwnerDocument->createWrapper(node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of nodes stored in this NamedNodeMap.
|
||||
*
|
||||
* @return the number of nodes stored in this NamedNodeMap
|
||||
*/
|
||||
PRUint32 NamedNodeMap::getLength()
|
||||
{
|
||||
NSI_FROM_TX(NamedNodeMap);
|
||||
PRUint32 length = 0;
|
||||
nsNamedNodeMap->GetLength(&length);
|
||||
return length;
|
||||
}
|
||||
@@ -1,540 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
* Contributor(s): Tom Kneeland
|
||||
* Peter Van der Beken <peter.vanderbeken@pandora.be>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of the wrapper class to convert the Mozilla nsIDOMNode
|
||||
* interface into a TransforMIIX Node interface.
|
||||
*/
|
||||
|
||||
#include "mozilladom.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMNamedNodeMap.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "txAtoms.h"
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(Node)
|
||||
|
||||
/**
|
||||
* Construct a wrapper with the specified Mozilla object and document owner.
|
||||
*
|
||||
* @param aNode the nsIDOMNode you want to wrap
|
||||
* @param aOwner the document that owns this object
|
||||
*/
|
||||
Node::Node(nsIDOMNode* aNode, Document* aOwner) :
|
||||
MozillaObjectWrapper(aNode, aOwner),
|
||||
mNamespaceID(0),
|
||||
mOrderInfo(0)
|
||||
{
|
||||
MOZ_COUNT_CTOR(Node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
Node::~Node()
|
||||
{
|
||||
MOZ_COUNT_DTOR(Node);
|
||||
delete mOrderInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMNode::GetNodeName to get the node's name.
|
||||
*
|
||||
* @return the node's name
|
||||
*/
|
||||
nsresult Node::getNodeName(nsAString& aName)
|
||||
{
|
||||
NSI_FROM_TX(Node);
|
||||
return nsNode->GetNodeName(aName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMNode::GetNodeValue to get the node's value.
|
||||
*
|
||||
* @return the node's name
|
||||
*/
|
||||
nsresult Node::getNodeValue(nsAString& aValue)
|
||||
{
|
||||
NSI_FROM_TX(Node);
|
||||
return nsNode->GetNodeValue(aValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMNode::GetNodeType to get the node's type.
|
||||
*
|
||||
* @return the node's type
|
||||
*/
|
||||
unsigned short Node::getNodeType() const
|
||||
{
|
||||
NSI_FROM_TX(Node);
|
||||
unsigned short nodeType = 0;
|
||||
nsNode->GetNodeType(&nodeType);
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMNode::GetParentNode to get the node's parent.
|
||||
*
|
||||
* @return the node's parent
|
||||
*/
|
||||
Node* Node::getParentNode()
|
||||
{
|
||||
NSI_FROM_TX(Node);
|
||||
nsCOMPtr<nsIDOMNode> tmpParent;
|
||||
nsNode->GetParentNode(getter_AddRefs(tmpParent));
|
||||
if (!tmpParent) {
|
||||
return nsnull;
|
||||
}
|
||||
return mOwnerDocument->createWrapper(tmpParent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMNode::GetFirstChild to get the node's first child.
|
||||
*
|
||||
* @return the node's first child
|
||||
*/
|
||||
Node* Node::getFirstChild()
|
||||
{
|
||||
NSI_FROM_TX(Node);
|
||||
nsCOMPtr<nsIDOMNode> tmpFirstChild;
|
||||
nsNode->GetFirstChild(getter_AddRefs(tmpFirstChild));
|
||||
if (!tmpFirstChild) {
|
||||
return nsnull;
|
||||
}
|
||||
return mOwnerDocument->createWrapper(tmpFirstChild);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMNode::GetLastChild to get the node's last child.
|
||||
*
|
||||
* @return the node's first child
|
||||
*/
|
||||
Node* Node::getLastChild()
|
||||
{
|
||||
NSI_FROM_TX(Node);
|
||||
nsCOMPtr<nsIDOMNode> tmpLastChild;
|
||||
nsNode->GetLastChild(getter_AddRefs(tmpLastChild));
|
||||
if (!tmpLastChild) {
|
||||
return nsnull;
|
||||
}
|
||||
return mOwnerDocument->createWrapper(tmpLastChild);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMNode::GetPreviousSibling to get the node's previous sibling.
|
||||
*
|
||||
* @return the node's previous sibling
|
||||
*/
|
||||
Node* Node::getPreviousSibling()
|
||||
{
|
||||
NSI_FROM_TX(Node);
|
||||
nsCOMPtr<nsIDOMNode> tmpPrevSib;
|
||||
nsNode->GetPreviousSibling(getter_AddRefs(tmpPrevSib));
|
||||
if (!tmpPrevSib) {
|
||||
return nsnull;
|
||||
}
|
||||
return mOwnerDocument->createWrapper(tmpPrevSib);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMNode::GetNextSibling to get the node's next sibling.
|
||||
*
|
||||
* @return the node's next sibling
|
||||
*/
|
||||
Node* Node::getNextSibling()
|
||||
{
|
||||
NSI_FROM_TX(Node);
|
||||
nsCOMPtr<nsIDOMNode> tmpNextSib;
|
||||
nsNode->GetNextSibling(getter_AddRefs(tmpNextSib));
|
||||
if (!tmpNextSib) {
|
||||
return nsnull;
|
||||
}
|
||||
return mOwnerDocument->createWrapper(tmpNextSib);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMNode::GetAttributes to get the node's attributes.
|
||||
*
|
||||
* @return the node's attributes
|
||||
*/
|
||||
NamedNodeMap* Node::getAttributes()
|
||||
{
|
||||
NSI_FROM_TX(Node);
|
||||
nsCOMPtr<nsIDOMNamedNodeMap> tmpAttributes;
|
||||
nsNode->GetAttributes(getter_AddRefs(tmpAttributes));
|
||||
if (!tmpAttributes) {
|
||||
return nsnull;
|
||||
}
|
||||
return mOwnerDocument->createNamedNodeMap(tmpAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this wrapper's owning document.
|
||||
*
|
||||
* @return the wrapper's owning document
|
||||
*/
|
||||
Document* Node::getOwnerDocument()
|
||||
{
|
||||
return mOwnerDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMNode::AppendChild to append a child to the current node.
|
||||
*
|
||||
* @param aNewChild the child to append
|
||||
*
|
||||
* @return the new child
|
||||
*/
|
||||
Node* Node::appendChild(Node* aNewChild)
|
||||
{
|
||||
if (!aNewChild) {
|
||||
return nsnull;
|
||||
}
|
||||
NSI_FROM_TX(Node);
|
||||
nsCOMPtr<nsIDOMNode> newChild(do_QueryInterface(aNewChild->getNSObj()));
|
||||
nsCOMPtr<nsIDOMNode> returnValue;
|
||||
nsNode->AppendChild(newChild, getter_AddRefs(returnValue));
|
||||
if (!returnValue) {
|
||||
return nsnull;
|
||||
}
|
||||
return mOwnerDocument->createWrapper(returnValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call nsIDOMNode::HasChildNodes to return if this node has children.
|
||||
*
|
||||
* @return boolean value that says if this node has children
|
||||
*/
|
||||
MBool Node::hasChildNodes() const
|
||||
{
|
||||
NSI_FROM_TX(Node);
|
||||
PRBool returnValue = MB_FALSE;
|
||||
nsNode->HasChildNodes(&returnValue);
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Namespace URI
|
||||
* uses the Mozilla dom
|
||||
* Intoduced in DOM2
|
||||
*/
|
||||
nsresult Node::getNamespaceURI(nsAString& aNSURI)
|
||||
{
|
||||
NSI_FROM_TX(Node);
|
||||
return nsNode->GetNamespaceURI(aNSURI);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the local name atomized
|
||||
*
|
||||
* @return the node's localname atom
|
||||
*/
|
||||
MBool Node::getLocalName(nsIAtom** aLocalName)
|
||||
{
|
||||
if (!aLocalName)
|
||||
return MB_FALSE;
|
||||
*aLocalName = 0;
|
||||
return MB_TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace ID of the node
|
||||
*
|
||||
* @return the node's namespace ID
|
||||
*/
|
||||
PRInt32 Node::getNamespaceID()
|
||||
{
|
||||
return mNamespaceID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent node according to the XPath datamodel
|
||||
*/
|
||||
Node* Node::getXPathParent()
|
||||
{
|
||||
return getParentNode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace ID associated with the given prefix in the context
|
||||
* of this node.
|
||||
*
|
||||
* Creating our own implementation until content provides us with a way
|
||||
* to do it, that is a way that jst doesn't want to kill.
|
||||
*
|
||||
* @param prefix atom for prefix to look up
|
||||
* @return namespace ID for prefix
|
||||
*/
|
||||
PRInt32 Node::lookupNamespaceID(nsIAtom* aPrefix)
|
||||
{
|
||||
NSI_FROM_TX(Node);
|
||||
nsresult rv;
|
||||
|
||||
if (aPrefix == txXMLAtoms::xmlns) {
|
||||
return kNameSpaceID_XMLNS;
|
||||
}
|
||||
if (aPrefix == txXMLAtoms::xml) {
|
||||
return kNameSpaceID_XML;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> elem;
|
||||
unsigned short nodeType = 0;
|
||||
nsNode->GetNodeType(&nodeType);
|
||||
switch(nodeType) {
|
||||
case Node::ATTRIBUTE_NODE:
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> owner;
|
||||
nsCOMPtr<nsIDOMAttr> attr(do_QueryInterface(nsNode));
|
||||
|
||||
rv = attr->GetOwnerElement(getter_AddRefs(owner));
|
||||
NS_ENSURE_SUCCESS(rv, kNameSpaceID_Unknown);
|
||||
|
||||
elem = do_QueryInterface(owner);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
//XXX Namespace: we have to handle namespace nodes here
|
||||
elem = do_QueryInterface(nsNode);
|
||||
}
|
||||
}
|
||||
|
||||
if (!aPrefix || aPrefix == txXMLAtoms::_empty) {
|
||||
aPrefix = txXMLAtoms::xmlns;
|
||||
}
|
||||
|
||||
while (elem) {
|
||||
nsAutoString uri;
|
||||
rv = elem->GetAttr(kNameSpaceID_XMLNS, aPrefix, uri);
|
||||
NS_ENSURE_SUCCESS(rv, kNameSpaceID_Unknown);
|
||||
if (rv != NS_CONTENT_ATTR_NOT_THERE) {
|
||||
PRInt32 nsId;
|
||||
NS_ASSERTION(gTxNameSpaceManager, "No namespace manager");
|
||||
if (!gTxNameSpaceManager) {
|
||||
return kNameSpaceID_Unknown;
|
||||
}
|
||||
gTxNameSpaceManager->RegisterNameSpace(uri, nsId);
|
||||
return nsId;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> temp(elem);
|
||||
rv = temp->GetParent(*getter_AddRefs(elem));
|
||||
NS_ENSURE_SUCCESS(rv, kNameSpaceID_Unknown);
|
||||
}
|
||||
|
||||
if (aPrefix == txXMLAtoms::xmlns) {
|
||||
// No default namespace
|
||||
return kNameSpaceID_None;
|
||||
}
|
||||
|
||||
// Error, namespace not found
|
||||
return kNameSpaceID_Unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base URI of the node. Acccounts for xml:base
|
||||
* attributes.
|
||||
*
|
||||
* @return base URI for the node
|
||||
*/
|
||||
nsresult Node::getBaseURI(nsAString& aURI)
|
||||
{
|
||||
NSI_FROM_TX(Node);
|
||||
nsCOMPtr<nsIDOM3Node> nsDOM3Node = do_QueryInterface(nsNode);
|
||||
if (nsDOM3Node) {
|
||||
return nsDOM3Node->GetBaseURI(aURI);
|
||||
}
|
||||
|
||||
aURI.Truncate();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares document position of this node relative to another node
|
||||
*/
|
||||
PRInt32 Node::compareDocumentPosition(Node* aOther)
|
||||
{
|
||||
OrderInfo* myOrder = getOrderInfo();
|
||||
OrderInfo* otherOrder = aOther->getOrderInfo();
|
||||
if (!myOrder || !otherOrder) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (myOrder->mRoot == otherOrder->mRoot) {
|
||||
int c = 0;
|
||||
while (c < myOrder->mSize && c < otherOrder->mSize) {
|
||||
if (myOrder->mOrder[c] < otherOrder->mOrder[c]) {
|
||||
return -1;
|
||||
}
|
||||
if (myOrder->mOrder[c] > otherOrder->mOrder[c]) {
|
||||
return 1;
|
||||
}
|
||||
++c;
|
||||
}
|
||||
if (c < myOrder->mSize) {
|
||||
return 1;
|
||||
}
|
||||
if (c < otherOrder->mSize) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (myOrder->mRoot < otherOrder->mRoot) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get order information for node
|
||||
*/
|
||||
Node::OrderInfo* Node::getOrderInfo()
|
||||
{
|
||||
if (mOrderInfo) {
|
||||
return mOrderInfo;
|
||||
}
|
||||
|
||||
mOrderInfo = new OrderInfo;
|
||||
if (!mOrderInfo) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Node* parent = getXPathParent();
|
||||
if (!parent) {
|
||||
mOrderInfo->mOrder = 0;
|
||||
mOrderInfo->mSize = 0;
|
||||
mOrderInfo->mRoot = this;
|
||||
return mOrderInfo;
|
||||
}
|
||||
|
||||
OrderInfo* parentOrder = parent->getOrderInfo();
|
||||
mOrderInfo->mSize = parentOrder->mSize + 1;
|
||||
mOrderInfo->mRoot = parentOrder->mRoot;
|
||||
mOrderInfo->mOrder = new PRUint32[mOrderInfo->mSize];
|
||||
if (!mOrderInfo->mOrder) {
|
||||
delete mOrderInfo;
|
||||
mOrderInfo = 0;
|
||||
return 0;
|
||||
}
|
||||
memcpy(mOrderInfo->mOrder,
|
||||
parentOrder->mOrder,
|
||||
parentOrder->mSize * sizeof(PRUint32*));
|
||||
|
||||
int lastElem = parentOrder->mSize;
|
||||
switch(getNodeType()) {
|
||||
case Node::ATTRIBUTE_NODE:
|
||||
{
|
||||
nsCOMPtr<nsIAtom> thisName;
|
||||
getLocalName(getter_AddRefs(thisName));
|
||||
PRInt32 thisNS = getNamespaceID();
|
||||
|
||||
// find this attribute in parents attrlist
|
||||
PRInt32 count, i;
|
||||
nsCOMPtr<nsIContent> owner = do_QueryInterface(parent->getNSObj());
|
||||
owner->GetAttrCount(count);
|
||||
for (i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsIAtom> attName;
|
||||
nsCOMPtr<nsIAtom> attPrefix;
|
||||
PRInt32 attNS;
|
||||
owner->GetAttrNameAt(i,
|
||||
attNS,
|
||||
*getter_AddRefs(attName),
|
||||
*getter_AddRefs(attPrefix));
|
||||
|
||||
if (attName == thisName && attNS == thisNS) {
|
||||
mOrderInfo->mOrder[lastElem] = i + kTxAttrIndexOffset;
|
||||
return mOrderInfo;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
// XXX Namespace: need to handle namespace nodes here
|
||||
default:
|
||||
{
|
||||
nsCOMPtr<nsIContent> cont(do_QueryInterface(mMozObject));
|
||||
|
||||
nsISupports* parentObj = parent->getNSObj();
|
||||
|
||||
nsCOMPtr<nsIContent> parentCont(do_QueryInterface(parentObj));
|
||||
// Is parent an nsIContent
|
||||
if (parentCont) {
|
||||
PRInt32 index;
|
||||
parentCont->IndexOf(cont, index);
|
||||
mOrderInfo->mOrder[lastElem] = index + kTxChildIndexOffset;
|
||||
return mOrderInfo;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> parentDoc(do_QueryInterface(parentObj));
|
||||
// Is parent an nsIDocument
|
||||
if (parentDoc) {
|
||||
PRInt32 index;
|
||||
parentDoc->IndexOf(cont, index);
|
||||
mOrderInfo->mOrder[lastElem] = index + kTxChildIndexOffset;
|
||||
return mOrderInfo;
|
||||
}
|
||||
|
||||
// Parent is something else, probably an attribute
|
||||
// This will happen next to never, only for expressions like
|
||||
// foo/@bar/text()
|
||||
PRUint32 i, len;
|
||||
nsCOMPtr<nsIDOMNodeList> childNodes;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parentNode = do_QueryInterface(parentObj);
|
||||
nsCOMPtr<nsIDOMNode> thisNode = do_QueryInterface(mMozObject);
|
||||
parentNode->GetChildNodes(getter_AddRefs(childNodes));
|
||||
NS_ENSURE_TRUE(childNodes, 0);
|
||||
|
||||
childNodes->GetLength(&len);
|
||||
for (i = 0; i < len; ++i) {
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
childNodes->Item(i, getter_AddRefs(node));
|
||||
|
||||
if (node == thisNode) {
|
||||
mOrderInfo->mOrder[lastElem] = i + kTxChildIndexOffset;
|
||||
return mOrderInfo;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ERROR("unable to get childindex for node");
|
||||
mOrderInfo->mOrder[lastElem] = 0;
|
||||
return mOrderInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* OrderInfo destructor
|
||||
*/
|
||||
Node::OrderInfo::~OrderInfo()
|
||||
{
|
||||
delete [] mOrder;
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
* Contributor(s): Tom Kneeland
|
||||
* Peter Van der Beken <peter.vanderbeken@pandora.be>
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of the wrapper class to convert the Mozilla
|
||||
* nsIDOMProcessingInstruction interface into a TransforMiiX
|
||||
* ProcessingInstruction interface.
|
||||
*/
|
||||
|
||||
#include "mozilladom.h"
|
||||
#include "nsIDOMProcessingInstruction.h"
|
||||
#include "nsString.h"
|
||||
|
||||
/**
|
||||
* Construct a wrapper with the specified Mozilla object and document owner.
|
||||
*
|
||||
* @param aProcInstr the nsIDOMProcessingInstruction you want to wrap
|
||||
* @param aOwner the document that owns this object
|
||||
*/
|
||||
ProcessingInstruction::ProcessingInstruction(
|
||||
nsIDOMProcessingInstruction* aProcInstr,
|
||||
Document* aOwner) :
|
||||
Node (aProcInstr, aOwner)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
ProcessingInstruction::~ProcessingInstruction()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the local name atomized
|
||||
*
|
||||
* @return the node's localname atom
|
||||
*/
|
||||
MBool ProcessingInstruction::getLocalName(nsIAtom** aLocalName)
|
||||
{
|
||||
if (!aLocalName) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
NSI_FROM_TX(ProcessingInstruction);
|
||||
nsAutoString target;
|
||||
nsProcessingInstruction->GetNodeName(target);
|
||||
*aLocalName = NS_NewAtom(target);
|
||||
NS_ENSURE_TRUE(*aLocalName, MB_FALSE);
|
||||
return MB_TRUE;
|
||||
}
|
||||
@@ -1,358 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Definition of the wrapper classes.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of the Mozilla Wrapper classes for the Mozilla DOM to
|
||||
* TransforMiiX DOM interface conversion. Note that these wrapper classes are
|
||||
* only interchangable with the TransforMiiX DOM at compile time. They are
|
||||
* merely a copy of the TransforMiiX interface/class structure wich then
|
||||
* deffer their processing to a Mozilla object. Complete interchangability
|
||||
* would require the use of multiple inherritance using virtual base classes
|
||||
* and RTTI which is not supported in Mozilla's cross platform domain.
|
||||
*
|
||||
* The wrappers "own" their Mozilla counterparts through an nsCOMPtr, releasing
|
||||
* them when they get deleted. The wrappers are kept in a hashtable, owned by
|
||||
* the document to keep us from creating new wrappers for the same Mozilla
|
||||
* objects over and over. The hashtable takes care of deleting all the wrappers
|
||||
* when their owning document is destroyed.
|
||||
*/
|
||||
|
||||
#ifndef MOZILLA_MITRE_DOM
|
||||
#define MOZILLA_MITRE_DOM
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "pldhash.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "TxObject.h"
|
||||
|
||||
#define kTxNsNodeIndexOffset 0x00000000;
|
||||
#define kTxAttrIndexOffset 0x40000000;
|
||||
#define kTxChildIndexOffset 0x80000000;
|
||||
|
||||
extern nsINameSpaceManager* gTxNameSpaceManager;
|
||||
|
||||
class nsIDOMAttr;
|
||||
class nsIDOMDocument;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNamedNodeMap;
|
||||
class nsIDOMNode;
|
||||
class nsIDOMProcessingInstruction;
|
||||
|
||||
class Attr;
|
||||
class Document;
|
||||
class Element;
|
||||
class NamedNodeMap;
|
||||
class Node;
|
||||
class ProcessingInstruction;
|
||||
|
||||
/**
|
||||
* This macro creates a nsCOMPtr to a specific interface for the
|
||||
* wrapper's Mozilla object. The nsCOMPtr will be named like the
|
||||
* supplied class with "ns" as a prefix.
|
||||
*/
|
||||
#define NSI_FROM_TX(_txClass) \
|
||||
nsCOMPtr<nsIDOM##_txClass> ns##_txClass(do_QueryInterface(mMozObject)); \
|
||||
NS_ASSERTION(ns##_txClass, "This wrapper's Mozilla object went away!")
|
||||
|
||||
/**
|
||||
* Base wrapper class for a Mozilla object. Owns the Mozilla object through an
|
||||
* nsCOMPtr<nsISupports>.
|
||||
*/
|
||||
class MozillaObjectWrapper : public TxObject
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct a wrapper with the specified Mozilla object and document owner.
|
||||
*
|
||||
* @param aMozObject the Mozilla object you want to wrap
|
||||
* @param aOwnerDocument the document that owns this wrapper
|
||||
*/
|
||||
MozillaObjectWrapper(nsISupports* aMozObject,
|
||||
Document* aOwnerDocument)
|
||||
: mMozObject(aMozObject),
|
||||
mOwnerDocument(aOwnerDocument)
|
||||
{
|
||||
MOZ_COUNT_CTOR(MozillaObjectWrapper);
|
||||
NS_ASSERTION(aMozObject, "Wrapper needs Mozilla object!");
|
||||
NS_ASSERTION(aOwnerDocument, "Wrapper needs owner document!");
|
||||
};
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~MozillaObjectWrapper()
|
||||
{
|
||||
MOZ_COUNT_DTOR(MozillaObjectWrapper);
|
||||
NS_ASSERTION(inHashTableDeletion(),
|
||||
"Never directly delete a DOM object, except a document!");
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the Mozilla object wrapped with this wrapper.
|
||||
*
|
||||
* @return the Mozilla object wrapped with this wrapper
|
||||
*/
|
||||
nsISupports* getNSObj() const
|
||||
{
|
||||
return mMozObject;
|
||||
};
|
||||
|
||||
protected:
|
||||
// We want to maintain a pointer back to the owner document for memory
|
||||
// management.
|
||||
nsCOMPtr<nsISupports> mMozObject;
|
||||
Document* mOwnerDocument;
|
||||
|
||||
#ifdef DEBUG
|
||||
private:
|
||||
// Defined in Document.cpp (debugging aid, needs access to
|
||||
// Document::mInHashTableDeletion).
|
||||
PRBool inHashTableDeletion();
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper class for nsIDOMNode. It provides the generic Node interface,
|
||||
* forwarding all functionality to its Mozilla counterpart.
|
||||
*/
|
||||
class Node : public MozillaObjectWrapper
|
||||
{
|
||||
public:
|
||||
// Node type constants
|
||||
enum NodeType {
|
||||
ELEMENT_NODE = 1,
|
||||
ATTRIBUTE_NODE,
|
||||
TEXT_NODE,
|
||||
CDATA_SECTION_NODE,
|
||||
ENTITY_REFERENCE_NODE,
|
||||
ENTITY_NODE,
|
||||
PROCESSING_INSTRUCTION_NODE,
|
||||
COMMENT_NODE,
|
||||
DOCUMENT_NODE,
|
||||
DOCUMENT_TYPE_NODE,
|
||||
DOCUMENT_FRAGMENT_NODE,
|
||||
NOTATION_NODE
|
||||
};
|
||||
|
||||
Node(nsIDOMNode* aNode, Document* aOwner);
|
||||
virtual ~Node();
|
||||
|
||||
// Read functions
|
||||
virtual nsresult getNodeName(nsAString& aName);
|
||||
virtual nsresult getNodeValue(nsAString& aValue);
|
||||
virtual unsigned short getNodeType() const;
|
||||
virtual Node* getParentNode();
|
||||
virtual Node* getFirstChild();
|
||||
virtual Node* getLastChild();
|
||||
virtual Node* getPreviousSibling();
|
||||
virtual Node* getNextSibling();
|
||||
virtual NamedNodeMap* getAttributes();
|
||||
virtual Document* getOwnerDocument();
|
||||
|
||||
// Node manipulation functions
|
||||
virtual Node* appendChild(Node* aNewChild);
|
||||
|
||||
virtual MBool hasChildNodes() const;
|
||||
|
||||
// Introduced in DOM2
|
||||
virtual nsresult getNamespaceURI(nsAString& aNSURI);
|
||||
|
||||
// From DOM3 26-Jan-2001 WD
|
||||
virtual nsresult getBaseURI(nsAString& aURI);
|
||||
|
||||
// txXPathNode functions
|
||||
virtual MBool getLocalName(nsIAtom** aLocalName);
|
||||
virtual PRInt32 getNamespaceID();
|
||||
virtual PRInt32 lookupNamespaceID(nsIAtom* aPrefix);
|
||||
virtual Node* getXPathParent();
|
||||
virtual PRInt32 compareDocumentPosition(Node* aOther);
|
||||
|
||||
protected:
|
||||
PRInt32 mNamespaceID;
|
||||
|
||||
private:
|
||||
// Struct to hold document order information
|
||||
struct OrderInfo {
|
||||
~OrderInfo();
|
||||
PRUint32* mOrder;
|
||||
PRInt32 mSize;
|
||||
Node* mRoot;
|
||||
};
|
||||
|
||||
OrderInfo* mOrderInfo;
|
||||
|
||||
// Helpfunctions for compareDocumentPosition
|
||||
OrderInfo* getOrderInfo();
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper class for nsIDOMNamedNodeMap.
|
||||
*/
|
||||
class NamedNodeMap : public MozillaObjectWrapper
|
||||
{
|
||||
public:
|
||||
NamedNodeMap(nsIDOMNamedNodeMap* aNamedNodeMap, Document* aOwner);
|
||||
~NamedNodeMap();
|
||||
|
||||
Node* getNamedItem(const nsAString& aName);
|
||||
Node* item(PRUint32 aIndex);
|
||||
PRUint32 getLength();
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper class for nsIDOMDocument.
|
||||
*/
|
||||
class Document : public Node
|
||||
{
|
||||
public:
|
||||
Document(nsIDOMDocument* aDocument);
|
||||
~Document();
|
||||
|
||||
Element* getDocumentElement();
|
||||
|
||||
// Determine what kind of node this is, and create the appropriate
|
||||
// wrapper for it.
|
||||
Node* createWrapper(nsIDOMNode* node);
|
||||
|
||||
// Factory functions for various node types. These functions
|
||||
// are responsible for storing the wrapper classes they create in
|
||||
// the document's wrapperHashTable.
|
||||
// Note the addition of the factory functions to "wrap"
|
||||
// nsIDOM* objects.
|
||||
Attr* createAttribute(nsIDOMAttr* aAttr);
|
||||
Element* createElement(nsIDOMElement* aElement);
|
||||
NamedNodeMap* createNamedNodeMap(nsIDOMNamedNodeMap* aMap);
|
||||
Node* createNode(nsIDOMNode* aNode);
|
||||
ProcessingInstruction* createProcessingInstruction(
|
||||
nsIDOMProcessingInstruction* aPi);
|
||||
|
||||
Element* getElementById(const nsAString& aID);
|
||||
|
||||
PRInt32 namespaceURIToID(const nsAString& aNamespaceURI);
|
||||
void namespaceIDToURI(PRInt32 aNamespaceID, nsAString& aNamespaceURI);
|
||||
|
||||
private:
|
||||
PLDHashTable mWrapperHashTable;
|
||||
PLDHashTable mAttributeNodes;
|
||||
|
||||
#ifdef DEBUG
|
||||
friend class MozillaObjectWrapper;
|
||||
|
||||
PRBool mInHashTableDeletion;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper class for nsIDOMElement.
|
||||
*/
|
||||
class Element : public Node
|
||||
{
|
||||
public:
|
||||
Element(nsIDOMElement* aElement, Document* aOwner);
|
||||
~Element();
|
||||
|
||||
void setAttributeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aName,
|
||||
const nsAString& aValue);
|
||||
|
||||
// txXPathNode functions
|
||||
MBool getLocalName(nsIAtom** aLocalName);
|
||||
MBool getAttr(nsIAtom* aLocalName, PRInt32 aNSID, nsAString& aValue);
|
||||
MBool hasAttr(nsIAtom* aLocalName, PRInt32 aNSID);
|
||||
};
|
||||
|
||||
class txAttributeNodeKey
|
||||
{
|
||||
public:
|
||||
txAttributeNodeKey()
|
||||
{
|
||||
}
|
||||
txAttributeNodeKey(nsIContent* aParent,
|
||||
nsIAtom* aLocalName,
|
||||
PRInt32 aNameSpaceId) : mParent(aParent),
|
||||
mLocalName(aLocalName),
|
||||
mNSId(aNameSpaceId)
|
||||
{
|
||||
}
|
||||
~txAttributeNodeKey()
|
||||
{
|
||||
}
|
||||
PRBool Equals(const txAttributeNodeKey& aAttributeNodeKey) const
|
||||
{
|
||||
return (mParent == aAttributeNodeKey.mParent) &&
|
||||
(mLocalName == aAttributeNodeKey.mLocalName) &&
|
||||
(mNSId == aAttributeNodeKey.mNSId);
|
||||
}
|
||||
inline PRUint32 GetHash(void) const
|
||||
{
|
||||
return NS_PTR_TO_INT32(mParent.get()) ^
|
||||
(NS_PTR_TO_INT32(mLocalName.get()) << 12) ^
|
||||
(mNSId << 24);
|
||||
}
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIContent> mParent;
|
||||
nsCOMPtr<nsIAtom> mLocalName;
|
||||
PRInt32 mNSId;
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper class for nsIDOMAttr.
|
||||
*/
|
||||
class Attr : public Node,
|
||||
public txAttributeNodeKey
|
||||
{
|
||||
public:
|
||||
Attr(nsIDOMAttr* aAttr, Document* aOwner);
|
||||
~Attr();
|
||||
|
||||
// txXPathNode functions override
|
||||
MBool getLocalName(nsIAtom** aLocalName);
|
||||
Node* getXPathParent();
|
||||
|
||||
txAttributeNodeKey* GetKey() {
|
||||
return NS_STATIC_CAST(txAttributeNodeKey*, this);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Wrapper class for nsIDOMProcessingInstruction.
|
||||
*/
|
||||
class ProcessingInstruction : public Node
|
||||
{
|
||||
public:
|
||||
ProcessingInstruction(nsIDOMProcessingInstruction* aProcInstr,
|
||||
Document* aOwner);
|
||||
~ProcessingInstruction();
|
||||
|
||||
// txXPathNode functions
|
||||
MBool getLocalName(nsIAtom** aLocalName);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,139 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
*/
|
||||
// Tom Kneeland (3/29/99)
|
||||
//
|
||||
// Implementation of the Document Object Model Level 1 Core
|
||||
// Implementation of the Attr class
|
||||
//
|
||||
|
||||
#include "dom.h"
|
||||
#include "txAtoms.h"
|
||||
#include "XMLUtils.h"
|
||||
|
||||
//
|
||||
//Construct an Attribute object using the specified name and document owner
|
||||
//
|
||||
Attr::Attr(const nsAString& name, Document* owner):
|
||||
NodeDefinition(Node::ATTRIBUTE_NODE, name, nsString(), owner)
|
||||
{
|
||||
int idx = nodeName.FindChar(':');
|
||||
if (idx == kNotFound) {
|
||||
mLocalName = do_GetAtom(nodeName);
|
||||
if (mLocalName == txXMLAtoms::xmlns)
|
||||
mNamespaceID = kNameSpaceID_XMLNS;
|
||||
else
|
||||
mNamespaceID = kNameSpaceID_None;
|
||||
}
|
||||
else {
|
||||
mLocalName = do_GetAtom(Substring(nodeName, idx + 1,
|
||||
nodeName.Length() - (idx + 1)));
|
||||
// namespace handling has to be handled late, the attribute must
|
||||
// be added to the tree to resolve the prefix, unless it's
|
||||
// xmlns or xml, try to do that here
|
||||
nsCOMPtr<nsIAtom> prefixAtom = do_GetAtom(Substring(nodeName, 0, idx));
|
||||
if (prefixAtom == txXMLAtoms::xmlns)
|
||||
mNamespaceID = kNameSpaceID_XMLNS;
|
||||
else if (prefixAtom == txXMLAtoms::xml)
|
||||
mNamespaceID = kNameSpaceID_XML;
|
||||
else
|
||||
mNamespaceID = kNameSpaceID_Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
Attr::Attr(const nsAString& aNamespaceURI,
|
||||
const nsAString& aName,
|
||||
Document* aOwner) :
|
||||
NodeDefinition(Node::ATTRIBUTE_NODE, aName, nsString(), aOwner)
|
||||
{
|
||||
if (aNamespaceURI.IsEmpty())
|
||||
mNamespaceID = kNameSpaceID_None;
|
||||
else
|
||||
mNamespaceID = txNamespaceManager::getNamespaceID(aNamespaceURI);
|
||||
|
||||
XMLUtils::getLocalPart(nodeName, getter_AddRefs(mLocalName));
|
||||
}
|
||||
|
||||
//
|
||||
//Release the mLocalName
|
||||
//
|
||||
Attr::~Attr()
|
||||
{
|
||||
}
|
||||
|
||||
void Attr::setNodeValue(const nsAString& aValue)
|
||||
{
|
||||
nodeValue = aValue;
|
||||
}
|
||||
|
||||
nsresult Attr::getNodeValue(nsAString& aValue)
|
||||
{
|
||||
aValue = nodeValue;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
//Not implemented anymore, return null as an error.
|
||||
//
|
||||
Node* Attr::appendChild(Node* newChild)
|
||||
{
|
||||
NS_ASSERTION(0, "not implemented");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
//
|
||||
//Return the attributes local (unprefixed) name atom.
|
||||
//
|
||||
MBool Attr::getLocalName(nsIAtom** aLocalName)
|
||||
{
|
||||
if (!aLocalName)
|
||||
return MB_FALSE;
|
||||
*aLocalName = mLocalName;
|
||||
NS_ADDREF(*aLocalName);
|
||||
return MB_TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
//Return the namespace the attribute belongs to. If the attribute doesn't
|
||||
//have a prefix it doesn't belong to any namespace per the namespace spec,
|
||||
//and is handled in the constructor.
|
||||
//
|
||||
PRInt32 Attr::getNamespaceID()
|
||||
{
|
||||
if (mNamespaceID >= 0)
|
||||
return mNamespaceID;
|
||||
|
||||
mNamespaceID = kNameSpaceID_None;
|
||||
PRInt32 idx = nodeName.FindChar(':');
|
||||
if (idx != kNotFound) {
|
||||
nsCOMPtr<nsIAtom> prefixAtom = do_GetAtom(Substring(nodeName, 0, idx));
|
||||
mNamespaceID = lookupNamespaceID(prefixAtom);
|
||||
}
|
||||
return mNamespaceID;
|
||||
}
|
||||
|
||||
//
|
||||
//Return the attributes owning element
|
||||
//
|
||||
Node* Attr::getXPathParent()
|
||||
{
|
||||
return ownerElement;
|
||||
}
|
||||
@@ -1,198 +0,0 @@
|
||||
/*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
*/
|
||||
// Tom Kneeland (3/29/99)
|
||||
//
|
||||
// Implementation of the Document Object Model Level 1 Core
|
||||
// Implementation of the Document class
|
||||
//
|
||||
// Modification History:
|
||||
// Who When What
|
||||
// TK 03/29/99 Created
|
||||
// LF 08/06/1999 Removed Default argument initializer from
|
||||
// Document() constructor
|
||||
// LF 08/06/1999 fixed typo: defalut to default
|
||||
//
|
||||
|
||||
#include "dom.h"
|
||||
|
||||
//
|
||||
//Construct a Document. Currently no parameters are required, but the the
|
||||
//node constructor is called to identify the node type.
|
||||
//
|
||||
Document::Document() : NodeDefinition(Node::DOCUMENT_NODE, nsString(), NULL)
|
||||
{
|
||||
mIDMap.Init(0);
|
||||
documentElement = nsnull;
|
||||
}
|
||||
|
||||
//
|
||||
//Return the one and only element for this document
|
||||
//
|
||||
Element* Document::getDocumentElement()
|
||||
{
|
||||
return documentElement;
|
||||
}
|
||||
|
||||
//
|
||||
//Construct an empty document fragment.
|
||||
// NOTE: The caller is responsible for cleaning up this fragment's memory
|
||||
// when it is no longer needed.
|
||||
//
|
||||
Node* Document::createDocumentFragment()
|
||||
{
|
||||
return new DocumentFragment(this);
|
||||
}
|
||||
|
||||
//
|
||||
//Construct an element with the specified tag name.
|
||||
// NOTE: The caller is responsible for cleaning up the element's menory
|
||||
//
|
||||
Element* Document::createElement(const nsAString& tagName)
|
||||
{
|
||||
return new Element(tagName, this);
|
||||
}
|
||||
|
||||
Element* Document::createElementNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aTagName)
|
||||
{
|
||||
return new Element(aNamespaceURI, aTagName, this);
|
||||
}
|
||||
|
||||
//
|
||||
//Construct an attribute with the specified name
|
||||
//
|
||||
Attr* Document::createAttribute(const nsAString& name)
|
||||
{
|
||||
return new Attr(name, this);
|
||||
}
|
||||
|
||||
Attr* Document::createAttributeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aName)
|
||||
{
|
||||
return new Attr(aNamespaceURI, aName, this);
|
||||
}
|
||||
|
||||
//
|
||||
//Construct a text node with the given data
|
||||
//
|
||||
Node* Document::createTextNode(const nsAString& theData)
|
||||
{
|
||||
return new NodeDefinition(Node::TEXT_NODE, theData, this);
|
||||
}
|
||||
|
||||
//
|
||||
//Construct a comment node with the given data
|
||||
//
|
||||
Node* Document::createComment(const nsAString& theData)
|
||||
{
|
||||
return new NodeDefinition(Node::COMMENT_NODE, theData, this);
|
||||
}
|
||||
|
||||
//
|
||||
//Construct a ProcessingInstruction node with the given targe and data.
|
||||
//
|
||||
ProcessingInstruction*
|
||||
Document::createProcessingInstruction(const nsAString& target,
|
||||
const nsAString& data)
|
||||
{
|
||||
return new ProcessingInstruction(target, data, this);
|
||||
}
|
||||
|
||||
//
|
||||
//Return an Element by ID, introduced by DOM2
|
||||
//
|
||||
DHASH_WRAPPER(txIDMap, txIDEntry, nsAString&)
|
||||
|
||||
Element* Document::getElementById(const nsAString& aID)
|
||||
{
|
||||
txIDEntry* entry = mIDMap.GetEntry(aID);
|
||||
if (entry)
|
||||
return entry->mElement;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
/**
|
||||
* private setter for element ID
|
||||
*/
|
||||
PRBool
|
||||
Document::setElementID(const nsAString& aID, Element* aElement)
|
||||
{
|
||||
txIDEntry* id = mIDMap.AddEntry(aID);
|
||||
// make sure IDs are unique
|
||||
if (id->mElement) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
id->mElement = aElement;
|
||||
id->mElement->setIDValue(aID);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
Node* Document::appendChild(Node* newChild)
|
||||
{
|
||||
unsigned short nodeType = newChild->getNodeType();
|
||||
|
||||
// Convert to a NodeDefinition Pointer
|
||||
NodeDefinition* pNewChild = (NodeDefinition*)newChild;
|
||||
|
||||
if (pNewChild->parentNode == this)
|
||||
{
|
||||
pNewChild = implRemoveChild(pNewChild);
|
||||
if (nodeType == Node::ELEMENT_NODE)
|
||||
documentElement = nsnull;
|
||||
}
|
||||
|
||||
switch (nodeType)
|
||||
{
|
||||
case Node::PROCESSING_INSTRUCTION_NODE :
|
||||
case Node::COMMENT_NODE :
|
||||
case Node::DOCUMENT_TYPE_NODE :
|
||||
return implAppendChild(pNewChild);
|
||||
|
||||
case Node::ELEMENT_NODE :
|
||||
if (!documentElement)
|
||||
{
|
||||
Node* returnVal = implAppendChild(pNewChild);
|
||||
documentElement = (Element*)pNewChild;
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsresult Document::getBaseURI(nsAString& aURI)
|
||||
{
|
||||
aURI = documentBaseURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32 Document::namespaceURIToID(const nsAString& aNamespaceURI)
|
||||
{
|
||||
return txNamespaceManager::getNamespaceID(aNamespaceURI);
|
||||
}
|
||||
|
||||
void Document::namespaceIDToURI(PRInt32 aNamespaceID, nsAString& aNamespaceURI)
|
||||
{
|
||||
txNamespaceManager::getNamespaceURI(aNamespaceID, aNamespaceURI);
|
||||
}
|
||||
@@ -1,275 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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/
|
||||
*
|
||||
* The program provided "as is" without any warranty express or
|
||||
* implied, including the warranty of non-infringement and the implied
|
||||
* warranties of merchantibility and fitness for a particular purpose.
|
||||
* The Copyright owner will not be liable for any damages suffered by
|
||||
* you as a result of using the Program. In no event will the Copyright
|
||||
* owner be liable for any special, indirect or consequential damages or
|
||||
* lost profits even if the Copyright owner has been advised of the
|
||||
* possibility of their occurrence.
|
||||
*
|
||||
* Please see release.txt distributed with this file for more information.
|
||||
*
|
||||
*/
|
||||
// Tom Kneeland (3/29/99)
|
||||
//
|
||||
// Implementation of the Document Object Model Level 1 Core
|
||||
// Implementation of the Element class
|
||||
//
|
||||
|
||||
#include "dom.h"
|
||||
#include "txAtoms.h"
|
||||
#include "XMLUtils.h"
|
||||
|
||||
//
|
||||
//Construct a new element with the specified tagName and Document owner.
|
||||
//Simply call the constructor for NodeDefinition, and specify the proper node
|
||||
//type.
|
||||
//
|
||||
Element::Element(const nsAString& tagName, Document* owner) :
|
||||
NodeDefinition(Node::ELEMENT_NODE, tagName, nsString(), owner)
|
||||
{
|
||||
mAttributes.ownerElement = this;
|
||||
mNamespaceID = kNameSpaceID_Unknown;
|
||||
|
||||
int idx = tagName.FindChar(':');
|
||||
if (idx == kNotFound) {
|
||||
mLocalName = do_GetAtom(tagName);
|
||||
}
|
||||
else {
|
||||
mLocalName = do_GetAtom(Substring(tagName, idx + 1,
|
||||
tagName.Length() - (idx + 1)));
|
||||
}
|
||||
}
|
||||
|
||||
Element::Element(const nsAString& aNamespaceURI,
|
||||
const nsAString& aTagName,
|
||||
Document* aOwner) :
|
||||
NodeDefinition(Node::ELEMENT_NODE, aTagName, nsString(), aOwner)
|
||||
{
|
||||
Element(aTagName, aOwner);
|
||||
if (aNamespaceURI.IsEmpty())
|
||||
mNamespaceID = kNameSpaceID_None;
|
||||
else
|
||||
mNamespaceID = txNamespaceManager::getNamespaceID(aNamespaceURI);
|
||||
}
|
||||
|
||||
//
|
||||
// This element is being destroyed, so destroy all attributes stored
|
||||
// in the mAttributes NamedNodeMap.
|
||||
//
|
||||
Element::~Element()
|
||||
{
|
||||
mAttributes.clear();
|
||||
}
|
||||
|
||||
Node* Element::appendChild(Node* newChild)
|
||||
{
|
||||
switch (newChild->getNodeType())
|
||||
{
|
||||
case Node::ELEMENT_NODE :
|
||||
case Node::TEXT_NODE :
|
||||
case Node::COMMENT_NODE :
|
||||
case Node::PROCESSING_INSTRUCTION_NODE :
|
||||
{
|
||||
// Remove the "newChild" if it is already a child of this node
|
||||
NodeDefinition* pNewChild = (NodeDefinition*)newChild;
|
||||
if (pNewChild->getParentNode() == this)
|
||||
pNewChild = implRemoveChild(pNewChild);
|
||||
|
||||
return implAppendChild(pNewChild);
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
//
|
||||
//Return the elements local (unprefixed) name.
|
||||
//
|
||||
MBool Element::getLocalName(nsIAtom** aLocalName)
|
||||
{
|
||||
if (!aLocalName)
|
||||
return MB_FALSE;
|
||||
*aLocalName = mLocalName;
|
||||
NS_ADDREF(*aLocalName);
|
||||
return MB_TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
//Return the namespace the elements belongs to.
|
||||
//
|
||||
PRInt32 Element::getNamespaceID()
|
||||
{
|
||||
if (mNamespaceID>=0)
|
||||
return mNamespaceID;
|
||||
int idx = nodeName.FindChar(':');
|
||||
if (idx == kNotFound) {
|
||||
Node* node = this;
|
||||
while (node && node->getNodeType() == Node::ELEMENT_NODE) {
|
||||
nsAutoString 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);
|
||||
}
|
||||
else {
|
||||
mNamespaceID = kNameSpaceID_None;
|
||||
}
|
||||
return mNamespaceID;
|
||||
}
|
||||
node = node->getParentNode();
|
||||
}
|
||||
mNamespaceID = kNameSpaceID_None;
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIAtom> prefix = do_GetAtom(Substring(nodeName, 0, idx));
|
||||
mNamespaceID = lookupNamespaceID(prefix);
|
||||
}
|
||||
return mNamespaceID;
|
||||
}
|
||||
|
||||
NamedNodeMap* Element::getAttributes()
|
||||
{
|
||||
return &mAttributes;
|
||||
}
|
||||
|
||||
//
|
||||
//Add an attribute to this Element. Create a new Attr object using the
|
||||
//name and value specified. Then add the Attr to the the Element's
|
||||
//mAttributes NamedNodeMap.
|
||||
//
|
||||
void Element::setAttribute(const nsAString& name, const nsAString& value)
|
||||
{
|
||||
// Check to see if an attribute with this name already exists. If it does
|
||||
// overwrite its value, if not, add it.
|
||||
Attr* tempAttribute = getAttributeNode(name);
|
||||
if (tempAttribute) {
|
||||
tempAttribute->setNodeValue(value);
|
||||
}
|
||||
else {
|
||||
tempAttribute = getOwnerDocument()->createAttribute(name);
|
||||
tempAttribute->setNodeValue(value);
|
||||
tempAttribute->ownerElement = this;
|
||||
mAttributes.append(tempAttribute);
|
||||
}
|
||||
}
|
||||
|
||||
void Element::setAttributeNS(const nsAString& aNamespaceURI,
|
||||
const nsAString& aName,
|
||||
const nsAString& aValue)
|
||||
{
|
||||
// Check to see if an attribute with this name already exists. If it does
|
||||
// overwrite its value, if not, add it.
|
||||
PRInt32 namespaceID = txNamespaceManager::getNamespaceID(aNamespaceURI);
|
||||
nsCOMPtr<nsIAtom> localName;
|
||||
XMLUtils::getLocalPart(aName, getter_AddRefs(localName));
|
||||
|
||||
Attr* foundNode = 0;
|
||||
AttrMap::ListItem* item = mAttributes.firstItem;
|
||||
while (item) {
|
||||
foundNode = (Attr*)item->node;
|
||||
nsCOMPtr<nsIAtom> attrName;
|
||||
if (foundNode->getLocalName(getter_AddRefs(attrName)) &&
|
||||
namespaceID == foundNode->getNamespaceID() &&
|
||||
localName == attrName) {
|
||||
break;
|
||||
}
|
||||
foundNode = 0;
|
||||
item = item->next;
|
||||
}
|
||||
|
||||
if (foundNode) {
|
||||
foundNode->setNodeValue(aValue);
|
||||
}
|
||||
else {
|
||||
Attr* temp = getOwnerDocument()->createAttributeNS(aNamespaceURI,
|
||||
aName);
|
||||
temp->setNodeValue(aValue);
|
||||
temp->ownerElement = this;
|
||||
mAttributes.append(temp);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//Return the attribute specified by name
|
||||
//
|
||||
Attr* Element::getAttributeNode(const nsAString& name)
|
||||
{
|
||||
return (Attr*)mAttributes.getNamedItem(name);
|
||||
}
|
||||
|
||||
//
|
||||
// Return true if the attribute specified by localname and nsID
|
||||
// exists, and sets aValue to the value of the attribute.
|
||||
// Return false, if the attribute does not exist.
|
||||
//
|
||||
MBool Element::getAttr(nsIAtom* aLocalName, PRInt32 aNSID,
|
||||
nsAString& aValue)
|
||||
{
|
||||
aValue.Truncate();
|
||||
AttrMap::ListItem* item = mAttributes.firstItem;
|
||||
while (item) {
|
||||
Attr* attrNode = (Attr*)item->node;
|
||||
nsCOMPtr<nsIAtom> localName;
|
||||
if (attrNode->getLocalName(getter_AddRefs(localName)) &&
|
||||
aNSID == attrNode->getNamespaceID() &&
|
||||
aLocalName == localName) {
|
||||
attrNode->getNodeValue(aValue);
|
||||
return MB_TRUE;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
return MB_FALSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Return true if the attribute specified by localname and nsID
|
||||
// exists. Return false otherwise.
|
||||
//
|
||||
MBool Element::hasAttr(nsIAtom* aLocalName, PRInt32 aNSID)
|
||||
{
|
||||
AttrMap::ListItem* item = mAttributes.firstItem;
|
||||
while (item) {
|
||||
Attr* attrNode = (Attr*)item->node;
|
||||
nsCOMPtr<nsIAtom> localName;
|
||||
if (attrNode->getLocalName(getter_AddRefs(localName)) &&
|
||||
aNSID == attrNode->getNamespaceID() &&
|
||||
aLocalName == localName) {
|
||||
return MB_TRUE;
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
return MB_FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* ID accessors. Getter used for id() patterns, private setter for parser
|
||||
*/
|
||||
PRBool
|
||||
Element::getIDValue(nsAString& aValue)
|
||||
{
|
||||
if (mIDValue.IsEmpty()) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
aValue = mIDValue;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
Element::setIDValue(const nsAString& aValue)
|
||||
{
|
||||
mIDValue = aValue;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user