Compare commits

..

38 Commits

Author SHA1 Message Date
dkl%redhat.com
8c591d53e2 Removed some remaining SelectVisible calls in favor of CanSeeBug
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@121533 18797224-902f-48f8-a5cc-f745e15eee43
2002-05-15 18:36:31 +00:00
dkl%redhat.com
c1aa983fd5 Update to HEAD 2002/05/13
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@121401 18797224-902f-48f8-a5cc-f745e15eee43
2002-05-13 21:56:49 +00:00
dkl%redhat.com
3551227412 forgot one
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@121393 18797224-902f-48f8-a5cc-f745e15eee43
2002-05-13 20:49:00 +00:00
dkl%redhat.com
d0cc91f285 Fixed some template inconsistencies with current 2.16 Stable Branch
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@121392 18797224-902f-48f8-a5cc-f745e15eee43
2002-05-13 20:46:50 +00:00
(no author)
65ff7d56b3 This commit was manufactured by cvs2svn to create branch
'Bugzilla_PgSQL_branch'.

git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@121370 18797224-902f-48f8-a5cc-f745e15eee43
2002-05-13 06:24:51 +00:00
dkl%redhat.com
800eccde9a Merge with HEAD 2002/04/26
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@119979 18797224-902f-48f8-a5cc-f745e15eee43
2002-04-26 18:59:37 +00:00
(no author)
5360e5b008 This commit was manufactured by cvs2svn to create branch
'Bugzilla_PgSQL_branch'.

git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@119975 18797224-902f-48f8-a5cc-f745e15eee43
2002-04-26 18:12:55 +00:00
dkl%redhat.com
da759055dd Sync to HEAD 2002/03/21
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@117156 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-22 05:16:48 +00:00
(no author)
1f960bb1bd This commit was manufactured by cvs2svn to create branch
'Bugzilla_PgSQL_branch'.

git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@116669 18797224-902f-48f8-a5cc-f745e15eee43
2002-03-15 23:23:14 +00:00
dkl%redhat.com
e0f4b89db1 Update to HEAD 2002/02/26
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@115395 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-27 01:11:14 +00:00
(no author)
025b6e8e46 This commit was manufactured by cvs2svn to create branch
'Bugzilla_PgSQL_branch'.

git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@115298 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-24 09:28:23 +00:00
dkl%redhat.com
704f46aa53 Update to HEAD 2002/02/04
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@113607 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-04 15:56:15 +00:00
(no author)
f26338df7e This commit was manufactured by cvs2svn to create branch
'Bugzilla_PgSQL_branch'.

git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@113575 18797224-902f-48f8-a5cc-f745e15eee43
2002-02-03 09:28:50 +00:00
dkl%redhat.com
58548c3f0d Update to HEAD 2002/01/30
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@113247 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-30 23:00:13 +00:00
(no author)
9a6b4393ad This commit was manufactured by cvs2svn to create branch
'Bugzilla_PgSQL_branch'.

git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@113166 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-29 23:26:38 +00:00
dkl%redhat.com
4316819604 Fix runtests.sh error on processmail
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@112507 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-21 23:27:24 +00:00
dkl%redhat.com
9d93dfabb8 Fix botched earlier sync with HEAD
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@112499 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-21 20:42:30 +00:00
dkl%redhat.com
d2ddb07675 Update to HEAD 01/18/2002
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@112473 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-18 23:06:43 +00:00
dkl%redhat.com
66d426dc97 Lost the pgsetup.pl file somewhere along the line. Adding back properly.
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@111575 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-08 16:13:05 +00:00
dkl%redhat.com
b7e91cb3b6 Changes to CanSeeBug to allow multiple checks in one call for buglist.cgi
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@111509 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-07 23:20:15 +00:00
dkl%redhat.com
5ac0899827 Update to HEAD 2002-01-07
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@111508 18797224-902f-48f8-a5cc-f745e15eee43
2002-01-07 23:14:41 +00:00
dkl%redhat.com
4f49e57a3b Merge 3 with HEAD: 2001/12/26
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@111103 18797224-902f-48f8-a5cc-f745e15eee43
2001-12-27 07:26:12 +00:00
dkl%redhat.com
38c27be28f Merge 2 with HEAD: 2001/12/26
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@111102 18797224-902f-48f8-a5cc-f745e15eee43
2001-12-27 06:02:04 +00:00
dkl%redhat.com
d60d3d6121 Merge fix. This is frustrating.
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@111101 18797224-902f-48f8-a5cc-f745e15eee43
2001-12-27 05:29:04 +00:00
dkl%redhat.com
db0b87fb6c Merge with HEAD on 2001/12/26
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@111100 18797224-902f-48f8-a5cc-f745e15eee43
2001-12-27 05:09:43 +00:00
(no author)
6e2791a4b7 This commit was manufactured by cvs2svn to create branch
'Bugzilla_PgSQL_branch'.

git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@110404 18797224-902f-48f8-a5cc-f745e15eee43
2001-12-12 22:41:21 +00:00
dkl%redhat.com
14542c62c7 Update to HEAD 2001-12-03
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@109510 18797224-902f-48f8-a5cc-f745e15eee43
2001-12-03 04:06:19 +00:00
dkl%redhat.com
38ebcba576 Fixed error in AddFDef
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@108598 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-20 18:40:38 +00:00
dkl%redhat.com
a5502157a9 Update to HEAD - November 18, 2001
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@108470 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-19 05:57:30 +00:00
(no author)
ba69b37618 This commit was manufactured by cvs2svn to create branch
'Bugzilla_PgSQL_branch'.

git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@108456 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-18 22:20:21 +00:00
dkl%redhat.com
22b863a5e9 Synced up with CVS HEAD and created Bugzilla_PgSQL_branch_sync tag
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@107700 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-08 23:03:10 +00:00
dkl%redhat.com
3e54979994 Fixed conflict in Bug.pm, removal of tabs from lots of files.
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@107385 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-06 01:21:11 +00:00
dkl%redhat.com
d73ca44c76 Add new cpan module dependencies
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@107356 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-05 21:43:11 +00:00
dkl%redhat.com
a4fc52b12e Updates and bug fixes
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@107354 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-05 21:10:15 +00:00
dkl%redhat.com
353baca797 New SQL utility functions. Changes in buglist.cgi to improve queries.
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@106967 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-01 15:35:03 +00:00
dkl%redhat.com
4618ab6c36 Initial checkin of pgsetup.pl. Utility for setting up Bugzilla database in PostgreSQL.
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@106569 18797224-902f-48f8-a5cc-f745e15eee43
2001-10-29 20:15:50 +00:00
justdave%syndicomm.com
faaed9c15f initial commit of PgSQL megapatch v0.2
git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@106532 18797224-902f-48f8-a5cc-f745e15eee43
2001-10-29 07:49:05 +00:00
(no author)
675f64d0ae This commit was manufactured by cvs2svn to create branch
'Bugzilla_PgSQL_branch'.

git-svn-id: svn://10.0.0.236/branches/Bugzilla_PgSQL_branch@106501 18797224-902f-48f8-a5cc-f745e15eee43
2001-10-28 03:41:01 +00:00
511 changed files with 106012 additions and 50472 deletions

View File

@@ -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
MODULE = transformiix
DIRS = source
ifndef TX_EXE
DIRS += build resources
endif
include $(topsrcdir)/config/rules.mk

View File

@@ -1,149 +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 \
windowwatcher \
mimetype \
intl \
$(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/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/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/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/StringFunctionCall.$(OBJ_SUFFIX) \
../source/xpath/StringResult.$(OBJ_SUFFIX) \
../source/xpath/txLiteralExpr.$(OBJ_SUFFIX) \
../source/xpath/txMozillaXPathTreeWalker.$(OBJ_SUFFIX) \
../source/xpath/txNameTest.$(OBJ_SUFFIX) \
../source/xpath/txNodeSet.$(OBJ_SUFFIX) \
../source/xpath/txNodeTypeTest.$(OBJ_SUFFIX) \
../source/xpath/txForwardContext.$(OBJ_SUFFIX) \
../source/xpath/txNodeSetContext.$(OBJ_SUFFIX) \
../source/xpath/txResultRecycler.$(OBJ_SUFFIX) \
../source/xpath/UnionExpr.$(OBJ_SUFFIX) \
../source/xpath/UnaryExpr.$(OBJ_SUFFIX) \
../source/xpath/VariableRefExpr.$(OBJ_SUFFIX) \
../source/xml/XMLUtils.$(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/parser \
-I$(srcdir)/../source/xpath -I$(srcdir)/../source/xslt/util \
-I$(srcdir)/../source/xslt/functions

View File

@@ -1,287 +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 "nsIErrorService.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;
}
nsCOMPtr<nsIErrorService> errorService =
do_GetService(NS_ERRORSERVICE_CONTRACTID);
if (errorService) {
errorService->RegisterErrorStringBundle(NS_ERROR_MODULE_XSLT,
XSLT_MSGS_URL);
}
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)

View File

@@ -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);

View File

@@ -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

View File

@@ -1,254 +0,0 @@
<html>
<head>
<title>Compiled Stylesheets</title>
<style>
.comment {
font-style: italic;
}
</style>
</head>
<body>
<h1>Compiled Stylesheets</h1>
<h2>Overview</h2>
<p>
There are 5 main entities: Stylesheet-loaders, stylesheet-compiler,
stylesheet, execution-state and processor. The normal usecase is:
<ol>
<li>Set up a stylesheet-loader to read a resource.
<li>Let it feed events to the stylesheet-compiler.
<li>The compiler creates a stylesheet.
<li>Init an execution-state with stylesheet, initial node, global
parameters and an outputhandler factory.
<li>Start the processor.
</ol>
</p>
<h2>Main classes</h2>
<h3>txStylesheet</h3>
<h4>Description:</h4>
<p>
This class represents a compiled stylesheet. If the stylesheet
contains imported and/or included stylesheets they are all compiled
into a single <code>txStylesheet</code>-object.
</p>
<p>
The stylesheet contains functions for getting the different top-level
entities that exist in a stylesheet, such as attribute-sets, templates
and global variables. The <code>txStylesheet</code> owns all objects
in the stylesheet, including the instructions in templates and
variables.
</p>
<p>
A single <code>txStylesheet</code>-object can be used for multiple
transformations, even running concurrently. Once a stylesheet is
compiled it is never changed, nor does it carry any state.
</p>
<h4>Typical functions:</h4>
<pre>
txInstruction* findTemplate(Node* aNode,
const txExpandedName& aMode,
txIMatchContext* aContext,
ImportFrame* aImportedBy,
ImportFrame** aImportFrame);
txDecimalFormat* getDecimalFormat(const txExpandedName& aName);
txInstruction* getAttributeSet(const txExpandedName& aName);
txOutputFormat* getOutputFormat();
</pre>
<h3>txStylesheetCompiler</h3>
<h4>Description:</h4>
<p>
This class gets "events" from a stylesheet loader and creates a
compiled stylesheet. The class calls back through a callback interface
to the stylesheet-loader to load included and imported stylesheets.
</p>
<p>
The output from the <code>txStylesheetCompiler</code> is a
ready-to-use <code>txStylesheet</code> object.
</p>
<p>
To load included and imported stylesheets the
<code>txStylesheetCompiler</code> calls the loader through a
<code>txIIncludeLoaderCallback</code> interface suppling the url to
load, and the <code>txStylesheetCompiler</code>-object that the loader
should use to notify its events to. There is a separate
<code>txStylesheetCompiler</code>-object for each sub-stylesheet,
however only the initial <code>txStylesheetCompiler</code> will create
a <code>txStylesheet</code>-object.
</p>
<p class="comment">
Do we want to refcount txIIncludeLoaderCallback? It might otherwise
be hairy to deal with loads being cancled or failing.
</p>
<h4>Typical functions:</h4>
<pre>
nsresult startElement(PRInt32 aNamespaceID, txAtom* aLocalName,
txAtom* aPrefix, txStylesheetAttr* aAttributes,
PRInt32 aAttrCount);
nsresult endElement();
nsresult characters(const String& aStr);
nsresult doneLoading();
void cancel(nsresult aError);
</pre>
<h3>txHandlerTable</h3>
<h4>Description:</h4>
<p>
To process the elements and textnodes in the stylesheet the
<code>txStylesheetCompiler</code> calls different
stylesheet-compile-handlers. Which handler to call is decided by two
things:
<ol>
<li>The "mode" of the compiler, i.e. is it processing a top-level
element? Is it processing the contents of a template? Is it
processing the children of a xsl:attribute-set element?
<li>The name and namespace of the element. (Of course, this doesn't
apply to textnodes).
</ol>
The handlers are global static C-style functions. The handlers
processes the elements and textnodes in the stylesheet and
creates instructions and toplevel-items.
</p>
<p>
To find which handler to call the compiler uses
<code>txHandlerTable</code>-objects. The <code>txHandlerTable</code>
contains a list of these stylesheet-compile-handlers keyed on
element-name. It also contains a handler for text and a handler for
LRE-elements.
</p>
<p>
There are different <code>txHandlerTable</code>-objects for different
"modes" of the compiler. There is one for handling top-level elements,
one for handling template-parameters, one for handling the contents of
a xsl:attribte-set element, one for handling the contents of
unsupported extension-elements etc. The
<code>txStylesheetCompiler</code> always has a current
<code>txHandlerTable</code> which is used to find the handler to call.
</p>
<p>
The <code>txHandlerTable</code>s are initialized from static structs.
This is to avoid having large pieces of code containing very similar
code.
</p>
<h4>Typical functions:</h4>
<pre>
nsresult init(txHandlerTableData* aTableData);
txElementHandler* find(PRInt32 aNamespaceID, txAtom* aLocalName);
</pre>
<h3>txStylesheetCompilerState</h3>
<p class="comment">
Do we want to rename this txStylesheetCompilerInternal?
</p>
<h4>Description:</h4>
<p>
This class manages the internal state of the
<code>txStylesheetCompiler</code>. The reason that this is a separate
class is so that the <code>txStylesheetCompiler</code> can keep a clean
interface towards the stylesheet-loaders.
</p>
<p>
The <code>txStylesheetCompilerState</code>-class is used both by the
<code>txStylesheetCompiler</code>-class and by the
stylesheet-compile-handlers.
</p>
<p>
The class has three main purposes:
<ul>
<li>
Keep track of the current context. Such as:
<ul>
<li>Namespace mappings.
<li>Base-URI.
<li>Extension-element namespaces.
<li>Whitespace preservation mode.
</ul>
</li>
<li>
Store the state that the stylesheet-compile-handlers need. For
example the current xsl:for-each loop to add xsl:sort-elements to.
</li>
<li>
Keep track of the current <code>txHandlerTable</code>, so that the
right stylesheet-compile-handler is called for elements and text.
</li>
</ul>
</p>
<p>
This is the class that implements <code>txIParseContext</code> during
all stylesheet-compilation.
</p>
<h4>Typical functions:</h4>
<pre>
nsresult pushHandlerTable(txHandlerTable* aTable);
nsresult parsePattern(const String& aPattern, txPattern** aResult);
nsresult parseExpr(const String& aExpr, Expr** aResult);
nsresult addToplevelItem(txToplevelItem* aItem);
nsresult openInstructionContainer(txInstructionContainer* aContainer);
nsresult addInstruction(txInstruction* aInstruction);
</pre>
<h3>txExecutionState</h3>
<h4>Description:</h4>
<p>
This class manages all state during the execution of a stylesheet.
This includes
<ul>
<li>The current <code>txIEvalContext</code>.
<li>The next <code>txInstruction</code> to be executed.
<li>Variables that are in scope.
<li>Values of global variables and keys.
<li>Current result-handler.
<li>Stylesheet being executed.
</ul>
</p>
<p>
The <code>txExecutionState</code> also acts as a general-purpose stack
that instructions can use to communicate between each other. The class
is the owner of this data and will delete it as appropriate if the
execution aborts.
</p>
<h4>Typical functions:</h4>
<pre>
nsresult pushEvalContext(txIEvalContext* aContext);
txIEvalContext* popEvalContext();
nsresult pushString(const nsAString& aStr);
void popString(nsAString& aStr);
txInstruction* getNextInstruction();
nsresult runTemplate(txInstruction* aInstruction);
void gotoInstruction(txInstruction* aNext);
</pre>
<h3>txXSLTProcessor</h3>
<h4>Description:</h4>
<p>
This is a fully static class that contains the main loop for executing
a stylsheet.
</p>
<h4>Typical functions:</h4>
<pre>
nsresult execute(txExecutionState& aEs);
</pre>
</body>
</html>

View File

@@ -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>

View File

@@ -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>

View File

@@ -1,199 +0,0 @@
<html>
<head>
<title>Optimizing Stylesheets</title>
<style>
.comment {
font-style: italic;
}
</style>
</head>
<body>
<h1>Optimizing Stylesheets</h1>
<h2>Overview</h2>
<p>
This document outlines optimizations that we can perform on
stylesheets after a stylesheet is compiled, but before it is executed.
</p>
<h2>Create AVTs out of xsl:attributes</h2>
<p>
People often write stylesheets like
<pre>
&lt;LRE&gt;
&lt;xsl:attribute name="foo"&gt;
text here
&lt;xsl:value-of select="@bar"/&gt;
&lt;/xsl:attribute&gt;
</pre>
This could be optimized into an AVT like
<pre>
&lt;LRE foo="text here{@foo}"&gt;
</pre>
This can be done both in templates and in attribute-sets
</p>
<h2>Investigate how RTFs are being used</h2>
<p>
When only the string-value or double-value of an RTF is being used it
is unneccesary to create an entire RTF. Instead we could set up a
string-handler and use the resulting string.
</p>
<p>
Once we have a node-set() function we could also have a special
handler that creates that resulting nodeset rather then
whatever-we-create-once-we-have-real-RTFs. That handler would be set
up when we can determain that a RTF is used only as argument to the
node-set() function.
</p>
<p>
In cases where an RTF is used as parameter in a call to another
template we could do further analysis to see how that parameter is
used in that template. Either by first analyzing how all template
parameters are used in all templates, or by recursivly searching
the called template when we find that a RTF is used as an argument.
</p>
<p>
We will still need a catch-all RTF implementation that is used when
we can't determin how a variable is used, or when it is used in
multiple different ways.
</p>
<h2>Inline/calculate constant variables</h2>
<p>
Variables that does not have a value that depends on the source
document can be inlined into the stylesheet. The value of these
variables could also be calculated before the transformation is
started.
</p>
<p>
This can be combined with the previous optimization of RTFs so that
stylesheets like
<pre>
&lt;xsl:variable name="v"&gt;_&lt;/xsl:variable&gt;
...
&lt;xsl:value-of select="concat(@id, $v, foo)"/&gt;
</pre>
is executed like
<pre>
&lt;xsl:value-of select="concat(@id, '_', foo)"/&gt;
</pre>
<p>
<p>
This can be done for both global and local variables.
</p>
<h2>Resolve cross-references</h2>
<p>
Cross-references to named templates, attribute-sets and template-modes
can be resolved before the stylesheet is executed. That way we don't
have to search for the template/attribute-set with a certain name, or
the group of templates for a certain mode.
</p>
<p>
Note that for apply-imports we won't always know at compile-time which
mode to seach for templates in.
</p>
<h2>Resolve variables by index rather then expanded name</h2>
<p>
Rather then seaching for variables with a certain name at runtime
we could remove names for variables/parameters entierly and put all
variables in an array (possibly a separate array for global variables)
and then let variable-references in expressions just point to an index
in that array.
</p>
<h2>Calculate and use constant AVTs</h2>
<p>
A lot of instruction-elements uses AVTs that often are constants in
stylesheets, such as the data-type parameter to xsl:sort. For xsl:sort
we could pre-create a finished nodesorter if all AVTs in all
xsl:sort-elements are constant.
</p>
<p>
Another example is xsl:element and xsl:attribute where we could use
LRE-instructions if the AVTs are constant. For xsl:number we could
create prepare the list of <code>txFormattedCounter</code>s.
</p>
<h2>Reuse parameter-map if exact same parameters are used</h2>
<p>
If a template calls another template and uses the exact same
parameters we can reuse the same parameter-map.
<pre>
&lt;xsl:template name="hsbc_html_body"&gt;
&lt;xsl:param name="appName"/&gt;
&lt;xsl:param name="title"/&gt;
&lt;body&gt;
&lt;xsl:call-template name="hsbc_form"&gt;
&lt;xsl:with-param name="appName" select="$appName"/&gt;
&lt;xsl:with-param name="title" select="$title"/&gt;
&lt;/xsl:call-template&gt;
&lt;/body&gt;
&lt;/xsl:template&gt;
</pre>
</p>
<p>
We have to watch out for default parameter-values as well as
parameters being specified by the caller of this template but not used
by this template. I.e. if the parameter "hello" is specified when
calling the above template.
</p>
<p class="comment">
All this might make this optimization useless.
</p>
<h2>Combind consecutive LRE items into a txResultBuffer</h2>
<p>
When a template contains several consecutive "LRE instructions" such
as LRE-elements, LRE-attributes and textnodes we can replace their
instructions with a special instruction that contains a
<code>txResultBuffer</code>. This buffer would then be flushed when
the instruction is executed. This can of course not be done for
LRE-attributes that contains AVTs. Even PI and comment-instructions
can be included in this buffer if their contents is strictly literal.
</p>
<p>
The result is that a template like
<pre>
&lt;xsl:template match="/"&gt;
&lt;html&gt;
&lt;body bgcolor="green"&gt;
Here goes pagecontent
&lt;xsl:apply-templates /&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;/xsl:template&gt;
</pre>
Would result in the first <code>txResultBuffer</code> to contain the
following transactions: eStartElementTransaction,
eStartElementTransaction, eAttributeTransaction, eCharacterTransaction.
</p>
<p class="comment">
There is probably a lower limit to when it's worth the effort to
replace the normal instructions with the buffer-instruction. A single
"LRE instruction" is probobably better kept as a normal instruction.
</p>
</body>
</html>

View File

@@ -1,523 +0,0 @@
<html>
<head>
<title>Optimizing XPath</title>
<style>
.comment {
font-style: italic;
}
h4 {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<h1>Optimizing XPath</h1>
<h2>Overview</h2>
<p>
This document outlines optimizations that we can perform to execute
xpath-expressions faster.
</p>
<h2>Stage 1, <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=94471">DONE</a></h2>
<h3>Summary</h3>
<p>
Speed up retrieval of orderInfo objects by storing them in resp.
node instead of in a hash.
</p>
<h3>Details</h3>
<p>
We currently spend a GREAT deal of time looking through a
DOMHelper::orders hash looking for the orderInfo object for a
specific node. If we moved the ownership and retrieval of these
orderInfo objects to the Node class instead we will probably save
a lot of time. I.E. instead of calling
<code>myDOMHelper->getDocumentOrder(node)</code> you call
<code>node->getDocumentOrder()</code> which then returns the
orderInfo object.
</p>
<p>
It would also be nice if we at the same time fixed some bugs wrt the
orderInfo objects and the function that sorts nodes using them.
</p>
<p>
Bugs filed at this are 88964 and 94471
</p>
<h2>Stage 2, <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=85893">DONE</a></h2>
<h3>Summary</h3>
<p>
Speed up document-order sorting by having the XPath engine always
return document-ordered nodesets.
</p>
<h3>Details</h3>
<p>
Currently the nodesets returned from the XPath engine are totally
unordered (or rather, have undefined order) which forces the XSLT
code to sort the nodesets. This is quite expensive since it requires
us to generate orderInfo objects for every node. Considering that
many XPath classes actually returns nodesets that are already
ordered in document order (or reversed document order) this seems a
bit unnecessary.
</p>
<p>
However we still need to handle the classes that don't by default
return document-ordered nodesets. A good example of this is the id()
function. For example "id('foo bar')" produces two nodes which the
id-function has no idea how they relate in terms of document order.
Another example is "foo | bar", where the UnionExpr object gets two
nodesets (ordered in document order since all XPath classes should
now return ordered nodesets) and need to merge them into a single
ordered nodeset.
</p>
<h2>Stage 3, <a href="http://bugzilla.mozilla.org/show_bug.cgi?id=205703">DONE</a></h2>
<h3>Summary</h3>
<p>
Refcount <code>ExprResult</code>s to reduce the number of objects
created during evaluation.
</p>
<h3>Details</h3>
<p>
Right now every subexpression creates a new object during evaluation.
If we refcounted objects we would be often be able to reuse the same
objects across multiple evaluations. We should also keep global
result-objects for true and false, that way expressions that return
bool-values would never have to create any objects.
</p>
<p>
This does however require that the returned objects arn't modified
since they might be used elsewhere. This is not a big problem in the
current code where we pretty much only modify nodesets in a couple
of places.
</p>
<p>
To be able to reuse objects across subexpressions we chould have an
<code>ExprResult::ensureModifyable</code>-function. This would
return the same object if the refcount is 1, and create a new object
to return otherwise. This is especially usefull for nodesets which
would be mostly used by a single object at a time. But it could be
just as usefull for other types, though then we might need a
<code>ExprResult::ensureModifyableOfType(ExprResult::ResultType)</code>-function
that only returned itself if it has a refcount of 1 and is of the
requsted type.
</p>
<h2>Stage 4</h2>
<h3>Summary</h3>
<p>
Speed up evaluation of XPath expressions by using specialized
classes for common optimizable expressions.
</p>
<h3>Details</h3>
<p>
Some common expressions are possible to execute faster if we have
classes that are specialized for them. For example the expression
"@foo" can be evaluated by simply calling |context->getAttributeNode
("foo")|, instead we now walk all attributes of the context node and
filter each node using a AttributeExpr. Below is a list of
expressions that I can think of that are optimizable, but there are
probably more.
</p>
<p>
One thing that we IMHO should keep in mind is to only put effort on
optimising expressions that are actually used in realworld
stylesheets. For example "foo | foo", "foo | bar[0]" and
"foo[position()]" can all be optimised to "foo", but since noone
should be so stupid as to write such an expression we shouldn't
spend time or codesize on that. Of course we should return the
correct result according to spec for those expressions, we just
shouldn't bother with evaluating them fast.
</p>
<p>
Apart from finding expression that we can evaluate more cleverly
there is also the problem of how and where do we create these
optimised objects instead of the unoptimised, general ones we create
now. And what are these optimised classes, should they be normal
Expr classes or should they be something else? We could also add
"optional" methods to Expr which have default implementations in
Expr, for example a ::isContextSensitive() which returns MB_TRUE
unless overridden. However we probably can't answer all this until
we know which expressions we want to optimised and how we want to
optimise them.
</p>
<p>
These expressions can be optimised:
</p>
<p><h4><a name="usecase01" href="#usecase01">Use case 1</a></h4>
<h4>Class:</h4>
Steps along the attribute axis which doesn't contain wildcards
<h4>Example:</h4>
@foo
<h4>What we do today:</h4>
Walk through the attributes NamedNodeMap and filter each node using a
NameTest.
<h4>What we could do:</h4>
Call getAttributeNode (or actually getAttributeNodeNS) on the
contextnode and return a nodeset containing just the returned node, or
an empty nodeset if NULL is returned.
</p>
<p><h4><a name="usecase02" href="#usecase02">Use case 2</a></h4>
<h4>Class:</h4>
Union expressions where each expression consists of a LocationStep and
all LocationSteps have the same axis. None of the LocationSteps have any
predicates (well, this could be relaxed a bit)
<h4>Example:</h4>
foo | bar | baz
<h4>What we do today:</h4>
Evaluate each LocationStep separately and thus walk the same path through
the document each time. During the walking the NodeTest is applied to
filter out the correct nodes. The resulting nodesets are then merged and
thus we generate orderInfo objects for most nodes.
<h4>What we could do:</h4>
Have just one LocationStep object which contains a NodeTest that is a
"UnionNodeTest" which contains a list of NodeTests. The UnionNodeTest
then tests each NodeTest until it finds one that returns true. If none
do then false is returned.
This results in just one walk along the axis and no need to generate any
orderInfo objects.
</p>
<p><h4><a name="usecase03" href="#usecase03">Use case 3</a></h4>
<h4>Class:</h4>
Steps where the predicates isn't context-node-list sensitive.
<h4>Example:</h4>
foo[@bar]
<h4>What we do today:</h4>
Build a nodeset of all nodes that match 'foo' and then filter the
nodeset through the predicate and thus do some node shuffling.
<h4>What we could do:</h4>
Create a "PredicatedNodeTest" that contains a NodeTest and a list of
predicates. The PredicatedNodeTest returns true if both the NodeTest
returns true and all predicats evaluate to true. Then let the
LocationStep have that PredicateNodeTest as NodeTest and no predicates.
This will save us the predicate filtering and thus some node shuffling.
(Note how this combines nicely with the previous optimisation...)
(Actually this can be done even if some predicates are context-list
sensitive, but only up until the first that isn't.)
</p>
<p><h4><a name="usecase04" href="#usecase04">Use case 4</a></h4>
<h4>Class:</h4>
PathExprs that only contains steps that from the child:: and attribute::
axes.
<h4>Example:</h4>
foo/bar/baz
<h4>What we do today:</h4>
For each step we evaluate the step once for every node in a nodeset
(for example for the second step the nodeset is the list of all "foo"
children) and then merge the resulting nodesets while making sure that
we keep the nodes in document order (and thus generate orderInfo
objects).
<h4>What we could do:</h4>
The same thing except that we don't merge the resulting nodeset, but
rather just concatenate them. We always know that the resulting nodesets
are after each other in node order.
</p>
<p><h4><a name="usecase05" href="#usecase05">Use case 5</a></h4>
<h4>Class:</h4>
List of predicates where some predicate are not context-list sensitive
<h4>Example:</h4>
foo[position() > 3][@bar][.//baz][position() > size() div 2][.//@fud]
<h4>What we do today:</h4>
Apply each predicate separately requiring us to shuffle nodes five times
in the above example.
<h4>What we could do:</h4>
Merge all predicates that are not node context-list sensitive into the
previous predicate. The above predicate list could be merged into the
following predicate list
foo[(position() > 3) and (@bar) and (.//baz)][(position() > size() div 2) and (.//@fud)]
Which only requires two node-shuffles
</p>
<p><h4><a name="usecase06" href="#usecase06">Use case 6</a></h4>
<h4>Class:</h4>
Predicates that are only context-list-position sensitive and not
context-list-size sensitive
<h4>Example:</h4>
foo[position() > 5][position() mod 2]
<h4>What we do today:</h4>
Build the entire list of nodes that matches "foo" and then apply the
predicates
<h4>What we could do:</h4>
Apply the predicates during the initial build of the first nodeset. We
would have to keep track of how many nodes has passed each and somehow
override the code that calculates the context-list-position.
</p>
<p><h4><a name="usecase07" href="#usecase07">Use case 7</a></h4>
<h4>Class:</h4>
Predicates that are constants
<h4>Example:</h4>
foo[5]
<h4>What we do today:</h4>
Perform the appropriate walk and build the entire nodeset. Then apply
the predicate.
<h4>What we could do:</h4>
There are three types of constant results; 1) Numerical values 2)
Results with a true boolean-value 3) Results with a false boolean value.
In the case of 1) we should only step up until the n:th node (5 in above
example) and then stop. For 2) we should completely ignore the predicate
and for 3) we should return an empty nodeset without doing any walking.
In some cases we can't at parsetime decide if a constant expression will
return a numerical or not, for example for "foo[$pos]", so the decision
of 1) 2) or 3) would have to be made at evaltime. However we should be
able to decide if it's a constant or not at parsetime.
Note that while evaluating a LocationStep [//foo] can be considered
constant.
</p>
<p><h4><a name="usecase08" href="#usecase08">Use case 8</a></h4>
<h4>Class:</h4>
PathExprs that contains '//' followed by an unpredicated child-step.
<h4>Example:</h4>
.//bar
<h4>What we do today:</h4>
We walk the entire subtree below the contextnode and at every node we
evaluate the 'bar'-expression which walks all the children of the
contextnode. This means that we'll walk the entire subtree twice.
<h4>What we could do:</h4>
Change the expression into "./descendant::bar". This means that we'll
only walk the tree once. This can only be done if there are no
predicates since the context-node-list will be different for
predicates in the new expression.
Note that this combines nicely with the "Steps where the predicates
isn't context-node-list sensitive" optimization.
</p>
<p><h4><a name="usecase09" href="#usecase09">Use case 9</a></h4>
<h4>Class:</h4>
PathExprs where the first step is '.'
<h4>Example:</h4>
./*
<h4>What we do today:</h4>
Evaluate the step "." which always returns the same node and then
evaluate the rest of the PathExpr.
<h4>What we could do:</h4>
Remove the '.'-step and simply evaluate the other steps. In the example
we could even remove the entire PathExpr-object and replace it with a
single Step-object.
</p>
<p><h4><a name="usecase10" href="#usecase10">Use case 10</a></h4>
<h4>Class:</h4>
Steps along the attribute axis which doesn't contain wildcards and
we only care about the boolean value.
<h4>Example:</h4>
foo[@bar], @foo or @bar
<h4>What we do today:</h4>
Evaluate the step and create a nodeset. Then get the bool-value of
the nodeset by checking if the nodeset contain any nodes.
<h4>What we could do:</h4>
Simply check if the current element has an attribute of the
requested name and return a bool-result.
</p>
<p><h4><a name="usecase11" href="#usecase11">Use case 11</a></h4>
<h4>Class:</h4>
Unpredicated steps where we only care about the boolean value.
<h4>Example:</h4>
foo[<u>processing-instruction()</u>]
<h4>What we do today:</h4>
Evaluate the step and create a nodeset. Then get the bool-value of
the nodeset by checking if the nodeset contain any nodes.
<h4>What we could do:</h4>
Walk along the axis until we find a node that matches the nodetest.
If one is found we can stop the walking and return a true
bool-result immediatly, otherwise a false bool-result is returned.
It might not be worth implementing all axes unless we can reuse
code from the normal Step-code. This could also be applied to
<code>PathExpr</code>s by getting the boolvalue of the last step.
</p>
<p><h4><a name="usecase12" href="#usecase12">Use case 12</a></h4>
<h4>Class:</h4>
Unpredicated steps where we only care about the string-value.
<h4>Example:</h4>
starts-with(<u>processing-instruction()</u>, 'hello')
<h4>What we do today:</h4>
Evaluate the step and create a nodeset. Then get the string-value of
the nodeset by getting the stringvalue of the first node.
<h4>What we could do:</h4>
Walk along the axis until we find a node that matches the nodetest.
If one is found we can stop the walking and return a string-result
containing the value of that node. Otherwise an empty string-result
can be returned.<br>
This can also be done when we only care about the number-value.<br>
This could be combined with the "Unpredicated steps where we only
care about the boolean value" optimization by instead of returning
a bool-value or string-value return a nodeset containing just the
found node. If that is done this optimization could be applied to
<code>PathExpr</code>s.
</p>
<p><h4><a name="usecase13" href="#usecase13">Use case 13</a></h4>
<h4>Class:</h4>
Expressions where the value of an attribute is compared to
a literal.
<h4>Example:</h4>
@bar = 'value'
<h4>What we do today:</h4>
Evaluate the attribute-step and then compare the resulting nodeset
to the value.
<h4>What we could do:</h4>
Get the attribute-value for the element and compare that directly
to the value. In the above example we would just call
<code>getAttr('bar', kNameSpaceID_None)</code> and compare the
resulting string with 'value'.
</p>
<p><h4><a name="usecase14" href="#usecase14">Use case 14</a></h4>
<h4>Class:</h4>
PathExprs where the last step has a predicate that is not
context-nodeset dependent and that contains a part that is not
context-node dependent.
<h4>Example:</h4>
foo/*[@bar = current()/@bar]
<h4>What we do today:</h4>
<h4>What we could do:</h4>
First evaluate "foo/*" and "current()/@bar". Then replace
"current()/@bar" with a literal (and possibly optimize) and filter
all nodes in the nodeset from "foo/*".
</p>
<p><h4><a name="usecase15" href="#usecase15">Use case 15</a></h4>
<h4>Class:</h4>
local-name() or namespace-uri() compared to a literal
<h4>Example:</h4>
local-name() = 'foo'
<h4>What we do today:</h4>
evaluate the local-name function and compare the string-result to
the string-result of the literal.
<h4>What we could do:</h4>
Atomize the literal (or get the namespaceID in case of
namespace-uri()) and then compare that to the atom-name of the
contextnode. This is primarily usefull when combined with the
previous class.
</p>
<p><h4><a name="usecase16" href="#usecase16">Use case 16</a></h4>
<h4>Class:</h4>
Comparisons where one side is a nodeset and the other is not a
bool-value.
<h4>Example:</h4>
//myElem = @baz
<h4>What we do today:</h4>
Evaluate both sides and then compare them according to the spec.
<h4>What we could do:</h4>
First of all we should start by evaluating the nodeset-side, if the
result is an empty nodeset false can be returned immediatly.
Otherwise we evaluate as normal. When both sides are nodesets we
should examine them and try to figure out which is faster to
evaluate. That expression should be evaluated first (probably
by making it the left-hand-side expression).
</p>
<p><h4><a name="usecase17" href="#usecase17">Use case 17</a></h4>
<h4>Class:</h4>
Comparisons where one side is a PathExpr and the other is a
bool-value.
<h4>Example:</h4>
baz = ($foo > $bar)
<h4>What we do today:</h4>
Evaluate both sides and then compare them.
<h4>What we could do:</h4>
Apply the "Steps where we only care about the boolean
value"-optimization on the PathExpr-side and then evaluate as usual.
</p>
<p><h4><a name="usecase18" href="#usecase18">Use case 18</a></h4>
<h4>Class:</h4>
Subexpressions that will be evaluated more then once where the only
change is in context it doesn't depend on
<h4>Example:</h4>
foo[@bar = <u>sum($var/@bar)</u>]
<h4>What we do today:</h4>
Reevaluate the subexpression every time we need it and every time
get the same result.
<h4>What we could do:</h4>
We should save the result from the first evaluation and just bring
it back the following time we need it. This can be done by
inserting an extra expression between the subexpression and its
parent, this expression would then first go look in a cache
available through the <code>nsIEvalContext</code>, if the value
isn't available there the original expression is evaluated and its
result is saved in the cache. The cache can be keyed on an integer
which is stored in the inserted 'cache-expression'.<br>
The cache itself could be created by another expression that is
inserted at the top of the expression. This way that expression
works as a boundry-point for the cache and can in theory be
inserted anywhere in an expression if needed.
</p>
<h2>Stage 5</h2>
<h3>Summary</h3>
<p>
Detect when we can concatenate nodesets instead of merge them in
PathExpr.
</p>
<h3>Details</h3>
<p>
Why can we for expressions like "foo/bar/baz" concatenate the resulting
nodesets without having to check nodeorder? Because at every step two
statements are true:
<ol>
<li>We iterate a nodeset where no node is an ancestor of another</li>
<li>The LocationStep only returns nodes that are members of the subtree
below the context-node</li>
</ol>
</p>
<p>
For example; While evaluating the second step in "foo/bar/baz" we
iterate a nodelist containing all "foo" children of the original
contextnode, i.e. none can be an ancestor of another. And the
LocationStep "bar" only returns children of the contextnode.
</p>
<p>
So, it would be nice if we can detect when this occurs as often as
possible. For example the expression "id(foo)/bar/baz" fulfils those
requirements if the nodeset returned from contains doesn't contain any
ancestors of other nodes in the nodeset, which probably often is the
case in real-world stylesheets.
</p>
<p>
We should perform this check on every step to be able to take advantage
of it as often as possible. For example the in expression
"id(@boss)/ancestor::team/members" we can't use this optimisation at the
second step since the ancestor axis returns nodes that are not members
of the contextnodes subtree. However we will probably be able to use the
optimisation at the third step since if iterated nodeset contains only
one node (and thus can't contain ancestors of it's members).
</p>
</body>
</html>

View File

@@ -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">&lt;?xml version="1.0"?&gt;</FONT>").
<P>
<B>example:</B>
<TABLE BGColor="" BORDER="1">
<TR>
<TD>
<PRE>
&lt;?xml version="1.0"?&gt;
&lt;?xml-stylesheet href="my.xsl" type="text/xsl"?&gt;
&lt;document&gt;
...
&lt;/document&gt;
</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">&nbsp;-- 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>

View File

@@ -1,45 +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
include $(topsrcdir)/config/rules.mk

View File

@@ -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);
}

View File

@@ -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);
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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>

View File

@@ -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;
}

View File

@@ -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 + " ");
}
}

View File

@@ -1,45 +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
include $(topsrcdir)/config/rules.mk

View File

@@ -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 an 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>

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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 ;
}

View File

@@ -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>
<content 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>
<content 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>

View File

@@ -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="@MOZILLA_VERSION@"
chrome:skinVersion="1.5">
</RDF:Description>
<!-- overlay information -->
<RDF:Seq about="urn:mozilla:overlays">
<RDF:li resource="chrome://communicator/content/tasksOverlay.xul"/>
</RDF:Seq>
<RDF:Seq about="chrome://communicator/content/tasksOverlay.xul">
<RDF:li>chrome://xslt-qa/content/xslt-qa-overlay.xul</RDF:li>
</RDF:Seq>
</RDF:RDF>

View File

@@ -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/&/&amp;/g; $purp=~s/</&lt;/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);
}

View File

@@ -1,17 +0,0 @@
const X_APP = "Buster";
const X_VER = "2.0"
const X_JAR_FILE = "xslt-qa.jar";
var err = initInstall("Install " + X_APP, X_APP, X_VER);
logComment("initInstall: " + err);
logComment( "Installation started ..." );
addFile("We're on our way ...", X_JAR_FILE, getFolder("chrome"), "");
registerChrome(CONTENT|DELAYED_CHROME, getFolder("chrome", X_JAR_FILE), "content/xslt-qa/");
err = getLastError();
if (err == SUCCESS) {
performInstall();
alert("Please restart Mozilla");
}
else {
cancelInstall();
}

View File

@@ -1,17 +0,0 @@
xslt-qa.jar:
content/xslt-qa/contents.rdf (contents.rdf)
content/xslt-qa/xslt-qa-overlay.xul
content/xslt-qa/xslt-qa-overlay.js
content/xslt-qa/buster/buster.xul
content/xslt-qa/buster/buster.css
content/xslt-qa/buster/buster-statics.js
content/xslt-qa/buster/buster-handlers.js
content/xslt-qa/buster/buster-files.js
content/xslt-qa/buster/buster-test.js
content/xslt-qa/buster/buster-view.js
content/xslt-qa/buster/result-view.xul
content/xslt-qa/buster/result-inspector.xul
content/xslt-qa/buster/result-view.css
content/xslt-qa/buster/result-view.js
content/xslt-qa/buster/DumpDOM.js
content/xslt-qa/buster/DiffDOM.js

View File

@@ -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 window [
<!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>

View File

@@ -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;
}

View File

@@ -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;
}
}
}
};

View File

@@ -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>

View File

@@ -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');
}

View File

@@ -1,45 +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="xsltToolsMenuID"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="xslt-qa-overlay.js" />
<menupopup id="toolsPopup">
<menuitem label="Xalan Tests" oncommand="onStartBuster()"/>
</menupopup>
</overlay>

View File

@@ -1,2 +0,0 @@
en-US.jar:
locale/en-US/communicator/layout/xslt.properties

View File

@@ -1,65 +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 TransforMiiX XSLT Processor.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 2003
# 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 *****
1 = Parsing an XSLT stylesheet failed.
2 = Parsing an XPath expression failed.
4 = XSLT transformation failed.
5 = Invalid XSLT/XPath function.
6 = XSLT Stylesheet (possibly) contains a recursion.
7 = Attribute value illegal in XSLT 1.0.
8 = An XPath expression was expected to return a NodeSet.
9 = XSLT transformation was terminated by <xsl:message>.
10 = A network error occured loading an XSLT stylesheet:
11 = An XSLT stylesheet does not have an XML mimetype:
12 = An XSLT stylesheet directly or indirectly imports or includes itself:
13 = An XPath function was called with the wrong number of arguments.
14 = An unknown XPath extension function was called.
15 = XPath parse failure: ')' expected:
16 = XPath parse failure: invalid axis:
17 = XPath parse failure: Name or Nodetype test expected:
18 = XPath parse failure: ']' expected:
19 = XPath parse failure: invalid variable name:
20 = XPath parse failure: unexpected end of expression:
21 = XPath parse failure: operator expected:
22 = XPath parse failure: unclosed literal:
23 = XPath parse failure: ':' unexpected:
24 = XPath parse failure: '!' unexpected, negation is not():
25 = XPath parse failure: illegal character found:
26 = XPath parse failure: binary operator expected:
LoadingError = Error loading stylesheet: %S
TransformError = Error during XSLT transformation: %S

View File

@@ -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

View File

@@ -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;
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -1,68 +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")
#else
#define TX_LG_IMPL
#define TX_LG_CREATE
#endif

View File

@@ -1,41 +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:
/**
* Deletes this TxObject
**/
virtual ~TxObject() {};
};
#endif

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -1,132 +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_INVALID_ARG NS_ERROR_INVALID_ARG
#define NS_XSLT_GET_NEW_HANDLER \
NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_XSLT, 1)
#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_ALREADY_SET \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 3)
#define NS_ERROR_XSLT_EXECUTION_FAILURE \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 4)
#define NS_ERROR_XPATH_UNKNOWN_FUNCTION \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 5)
#define NS_ERROR_XSLT_BAD_RECURSION \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 6)
#define NS_ERROR_XSLT_BAD_VALUE \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 7)
#define NS_ERROR_XSLT_NODESET_EXPECTED \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 8)
#define NS_ERROR_XSLT_ABORTED \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 9)
#define NS_ERROR_XSLT_NETWORK_ERROR \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 10)
#define NS_ERROR_XSLT_WRONG_MIME_TYPE \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 11)
#define NS_ERROR_XSLT_LOAD_RECURSION \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 12)
#define NS_ERROR_XPATH_BAD_ARGUMENT_COUNT \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 13)
#define NS_ERROR_XPATH_BAD_EXTENSION_FUNCTION \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 14)
#define NS_ERROR_XPATH_PAREN_EXPECTED \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 15)
#define NS_ERROR_XPATH_INVALID_AXIS \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 16)
#define NS_ERROR_XPATH_NO_NODE_TYPE_TEST \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 17)
#define NS_ERROR_XPATH_BRACKET_EXPECTED \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 18)
#define NS_ERROR_XPATH_INVALID_VAR_NAME \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 19)
#define NS_ERROR_XPATH_UNEXPECTED_END \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 20)
#define NS_ERROR_XPATH_OPERATOR_EXPECTED \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 21)
#define NS_ERROR_XPATH_UNCLOSED_LITERAL \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 22)
#define NS_ERROR_XPATH_BAD_COLON \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 23)
#define NS_ERROR_XPATH_BAD_BANG \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 24)
#define NS_ERROR_XPATH_ILLEGAL_CHAR \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 25)
#define NS_ERROR_XPATH_BINARY_EXPECTED \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XSLT, 26)
#endif // __TX_ERROR

View File

@@ -1,203 +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 "TxObject.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;
mItems = nsnull;
mItemCount = 0;
mBufferCount = 0;
}

View File

@@ -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

View File

@@ -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 "txAtoms.h"
#include "txXPathNode.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);
}

View File

@@ -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

View File

@@ -1,153 +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.
*/
inline void* peek()
{
NS_ASSERTION(!isEmpty(), "peeking at empty stack");
return ElementAt(Count() - 1);
}
/**
* 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.
*/
inline nsresult push(void* aObject)
{
return InsertElementAt(aObject, Count()) ? NS_OK :
NS_ERROR_OUT_OF_MEMORY;
}
/**
* 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.
*/
inline void* pop()
{
NS_ASSERTION(!isEmpty(), "popping from empty stack");
const PRInt32 count = Count() - 1;
void* object = ElementAt(count);
RemoveElementsAt(count, 1);
return object;
}
/**
* Returns true if there are no objects in the stack.
*
* @return true if there are no objects in the stack.
*/
inline PRBool isEmpty()
{
return (Count() <= 0);
}
/**
* Returns the number of elements in the Stack.
*
* @return the number of elements in the Stack.
*/
inline 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.
*/
inline
txStackIterator(txStack* aStack) : mStack(aStack),
mPosition(0)
{
}
/**
* Returns true if there is more objects on the stack.
*
* @return .
*/
inline PRBool hasNext()
{
return (mPosition < mStack->Count());
}
/**
* Returns the next object pointer from the stack.
*
* @return .
*/
inline void* next()
{
if (mPosition == mStack->Count()) {
return nsnull;
}
return mStack->ElementAt(mPosition++);
}
private:
txStack* mStack;
PRInt32 mPosition;
};
#endif /* txStack_h___ */

View File

@@ -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);
}

View File

@@ -1,79 +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.
*/
inline PRBool TX_StringEqualsAtom(const nsAString& aString, nsIAtom* aAtom)
{
return aAtom->Equals(aString);
}
#endif // txStringUtils_h__

View File

@@ -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___ */

View File

@@ -1,358 +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 = '/';
/**
* Implementation of utility functions for parsing URLs.
* Just file paths for now.
*/
void
txParsedURL::init(const nsAFlatString& aSpec)
{
mPath.Truncate();
mName.Truncate();
mRef.Truncate();
PRUint32 specLength = aSpec.Length();
if (!specLength) {
return;
}
const PRUnichar* start = aSpec.get();
const PRUnichar* end = start + specLength;
const PRUnichar* c = end - 1;
// check for #ref
for (; c >= start; --c) {
if (*c == '#') {
// we could eventually unescape this, too.
mRef = Substring(c + 1, end);
end = c;
--c;
if (c == start) {
// we're done,
return;
}
break;
}
}
for (c = end - 1; c >= start; --c) {
if (*c == '/') {
mName = Substring(c + 1, end);
mPath = Substring(start, c + 1);
return;
}
}
mName = Substring(start, end);
}
void
txParsedURL::resolve(const txParsedURL& aRef, txParsedURL& aDest)
{
/*
* No handling of absolute URLs now.
* These aren't really URLs yet, anyway, but paths with refs
*/
aDest.mPath = mPath + aRef.mPath;
if (aRef.mName.IsEmpty() && aRef.mPath.IsEmpty()) {
// the relative URL is just a fragment identifier
aDest.mName = mName;
if (aRef.mRef.IsEmpty()) {
// and not even that, keep the base ref
aDest.mRef = mRef;
return;
}
aDest.mRef = aRef.mRef;
return;
}
aDest.mName = aRef.mName;
aDest.mRef = aRef.mRef;
}
/**
* 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;
}
// Check whether the subject principal is the system principal.
// For performance, we will avoid calling SubjectPrincipalIsChrome()
// since it calls GetSubjectPrincipal() which causes us to walk
// the JS frame stack. We already did that above, so just get the
// system principal from the security manager, and do a raw comparison.
nsCOMPtr<nsIPrincipal> systemPrincipal;
gTxSecurityManager->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
if (subjectPrincipal == systemPrincipal) {
// we're running as system, grant access to the node.
return PR_TRUE;
}
// Ask the securitymanager if we have "UniversalBrowserRead"
PRBool caps = PR_FALSE;
nsresult rv =
gTxSecurityManager->IsCapabilityEnabled("UniversalBrowserRead",
&caps);
NS_ENSURE_SUCCESS(rv, PR_FALSE);
if (caps) {
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) {
ni = content->GetNodeInfo();
}
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) {
principal = doc->GetPrincipal();
}
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;
}
rv = gTxSecurityManager->CheckSameOriginPrincipal(subjectPrincipal,
principal);
return NS_SUCCEEDED(rv);
}
// static
void
URIUtils::ResetWithSource(nsIDocument *aNewDoc, nsIDOMNode *aSourceNode)
{
if (!aSourceNode) {
aNewDoc->Reset(nsnull, nsnull);
return;
}
nsCOMPtr<nsIDocument> sourceDoc = do_QueryInterface(aSourceNode);
if (!sourceDoc) {
nsCOMPtr<nsIDOMDocument> sourceDOMDocument;
aSourceNode->GetOwnerDocument(getter_AddRefs(sourceDOMDocument));
sourceDoc = do_QueryInterface(sourceDOMDocument);
}
if (!sourceDoc) {
NS_ASSERTION(0, "no source document found");
aNewDoc->Reset(nsnull, nsnull);
return;
}
nsCOMPtr<nsIChannel> channel;
nsCOMPtr<nsILoadGroup> loadGroup = sourceDoc->GetDocumentLoadGroup();
nsCOMPtr<nsIIOService> serv = do_GetService(NS_IOSERVICE_CONTRACTID);
if (serv) {
// Create a temporary channel to get nsIDocument->Reset to
// do the right thing. We want the output document to get
// much of the input document's characteristics.
serv->NewChannelFromURI(sourceDoc->GetDocumentURL(),
getter_AddRefs(channel));
}
aNewDoc->Reset(channel, loadGroup);
aNewDoc->SetBaseURL(sourceDoc->GetBaseURL());
// Copy charset
aNewDoc->SetDocumentCharacterSet(sourceDoc->GetDocumentCharacterSet());
aNewDoc->SetDocumentCharacterSetSource(
sourceDoc->GetDocumentCharacterSetSource());
}
#endif /* TX_EXE */

View File

@@ -1,114 +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 nsIDocument;
class nsIScriptSecurityManager;
extern nsIScriptSecurityManager *gTxSecurityManager;
#endif
/**
* A utility class for URI handling
* Not yet finished, only handles file URI at this point
**/
#ifdef TX_EXE
class txParsedURL
{
public:
void init(const nsAFlatString& aSpec);
void resolve(const txParsedURL& aRef, txParsedURL& aDest);
const nsDependentConcatenation getFile() const
{
return mPath + mName;
}
nsString mPath, mName, mRef;
};
#endif
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);
/**
* Reset the given document with the document of the source node
*/
static void ResetWithSource(nsIDocument *aNewDoc, nsIDOMNode *aSourceNode);
#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

View File

@@ -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

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>&lt;xsl:copy-of select="$product-name"/&gt;<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>&lt;xsl:if test="x | y | z"&gt;true&lt;/xsl:if&gt;<BR>
<B>Desired Result:</B>true<BR>
<B>Result:</B>true</P>
<P>
<B>Testing xsl:if</B>
<BR>
<B>Test:</B>&lt;xsl:if test="true()"&gt;true&lt;/xsl:if&gt;<BR>
<B>Desired Result:</B>true<BR>
<B>Result:</B>true</P>
<P>
<B>Testing xsl:if</B>
<BR>
<B>Test:</B>&lt;xsl:if test="'a'='b'"&gt;a equals b&lt;/xsl:if&gt;<BR>
<B></B>&lt;xsl:if test="'a'!='b'"&gt;a does not equal b&lt;/xsl:if&gt;<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>&lt;xsl:if test="2+1-3"&gt;2+1-3 is true&lt;/xsl:if&gt;<BR>
<B>&#160;</B>&lt;xsl:if test="not(2+1-3)"&gt;not(2+1-3) is true&lt;/xsl:if&gt;<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>&lt;xsl:apply-templates/&gt;<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>&lt;xsl:apply-templates mode="mode-test"/&gt;<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>&lt;xsl:call-template name="named-template-test"/&gt;<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>&lt;xsl:variable name="color"&gt;red&lt;/xsl:variable&gt;<BR>&lt;FONT COLOR="{$color}"&gt;Red Text&lt;/FONT&gt;</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>&lt;xsl:if test="descendant::z"&gt;true&lt;/xsl:if&gt;<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>&lt;xsl:if test="not(descendant-or-self::no-element)"&gt;true&lt;/xsl:if&gt;<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>&lt;xsl:element name="FONT"&gt;<BR>&lt;xsl:attribute name="COLOR"&gt;blue&lt;/xsl:attribute&gt;<BR>Passed<BR>&lt;/xsl:element&gt;</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>&lt;FONT xsl:use-attribute-sets="style1"&gt;<BR>Passed<BR>&lt;/FONT&gt;</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>&lt;xsl:element name="FONT" use-attribute-sets="style1 style2"&gt;<BR>Passed<BR>&lt;/xsl:element&gt;</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>&lt;xsl:number value="4"/&gt;<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>&lt;xsl:value-of select="70+4"/&gt;<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>&lt;xsl:value-of select="-70+4"/&gt;<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>&lt;xsl:value-of select="1900+70+8-4"/&gt;<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>&lt;xsl:value-of select="(4+5)-(9+9)"/&gt;<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>&lt;xsl:value-of select="7*4"/&gt;<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>&lt;xsl:value-of select="7mod4"/&gt;<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>&lt;xsl:value-of select="7div4"/&gt;<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>&lt;xsl:value-of select="7div0"/&gt;<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>&lt;xsl:value-of select="0 div 0"/&gt;<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>&lt;xsl:variable name="x" select="7*3"/&gt;<BR>&lt;xsl:variable name="y" select="3"/&gt;<BR>&lt;xsl:value-of select="$x div $y"/&gt;<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>&lt;xsl:value-of select="2 mod 2 = 0"/&gt;<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>&lt;xsl:value-of select="5 mod 2&lt;5 and 2*6&gt;= 12"/&gt;<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>&lt;xsl:value-of select="5 mod 2&lt;5 and 2*6&gt;12"/&gt;<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>&lt;xsl:value-of select="4+5*3"/&gt;<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>&lt;xsl:value-of select="4+5*3+(6-4)*7"/&gt;<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>&lt;xsl:value-of select="'747' + 8"/&gt;<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>

View File

@@ -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>

View File

@@ -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 &lt; 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> &lt;xsl:copy-of select="$product-name"/&gt;<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> &lt;xsl:if test="x | y | z"&gt;true&lt;/xsl:if&gt;<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> &lt;xsl:if test="true()"&gt;true&lt;/xsl:if&gt;<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> &lt;xsl:if test="'a'='b'"&gt;a equals b&lt;/xsl:if&gt;<BR/>
<B></B> &lt;xsl:if test="'a'!='b'"&gt;a does not equal b&lt;/xsl:if&gt;
<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> &lt;xsl:if test="2+1-3"&gt; 2+1-3 is true&lt;/xsl:if&gt;<BR/>
<B>&#160;</B>&lt;xsl:if test="not(2+1-3)"&gt; not(2+1-3) is true&lt;/xsl:if&gt;<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>&lt;xsl:apply-templates/&gt;<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>&lt;xsl:apply-templates mode="mode-test"/&gt;<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>&lt;xsl:call-template name="named-template-test"/&gt;<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>
&lt;xsl:variable name="color"&gt;red&lt;/xsl:variable&gt;<BR/>
&lt;FONT COLOR="{$color}"&gt;Red Text&lt;/FONT&gt;
</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>
&lt;xsl:if test="descendant::z"&gt;true&lt;/xsl:if&gt;<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>
&lt;xsl:if test="not(descendant-or-self::no-element)"&gt;true&lt;/xsl:if&gt;<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>
&lt;xsl:value-of select="count(x/attribute::*)"/&gt;<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>
&lt;xsl:element name="FONT"&gt;<BR />
&lt;xsl:attribute name="COLOR"&gt;blue&lt;/xsl:attribute&gt; <BR/>
Passed <BR/>
&lt;/xsl:element&gt;
</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>
&lt;FONT xsl:use-attribute-sets="style1"&gt;<BR />
Passed <BR/>
&lt;/FONT&gt;
</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>
&lt;xsl:element name="FONT" use-attribute-sets="style1 style2"&gt;<BR />
Passed <BR/>
&lt;/xsl:element&gt;
</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>
&lt;xsl:number value="4"/&gt;<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>
&lt;xsl:value-of select="70+4"/&gt;<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>
&lt;xsl:value-of select="-70+4"/&gt;<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>
&lt;xsl:value-of select="1900+70+8-4"/&gt;<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>
&lt;xsl:value-of select="(4+5)-(9+9)"/&gt;<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>
&lt;xsl:value-of select="7*4"/&gt;<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>
&lt;xsl:value-of select="7mod 4"/&gt;<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>
&lt;xsl:value-of select="7div 4"/&gt;<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>
&lt;xsl:value-of select="7div 0"/&gt;<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>
&lt;xsl:value-of select="0 div 0"/&gt;<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>
&lt;xsl:variable name="x" select="7*3"/&gt;<BR />
&lt;xsl:variable name="y" select="3"/&gt;<BR />
&lt;xsl:value-of select="$x div $y"/&gt;<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>
&lt;xsl:value-of select="2 mod 2 = 0"/&gt;<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>
&lt;xsl:value-of select="5 mod 2 &lt; 5 and 2*6 &gt;= 12"/&gt;<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 &lt; 5 and 2*6>=12"/>
</FONT>
</TD>
</TR>
<!-- new test -->
<TR>
<TD VALIGN="TOP"><B>Test:</B></TD>
<TD>
&lt;xsl:value-of select="5 mod 2 &lt; 5 and 2*6>12"/&gt;<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 &lt; 5 and 2*6>12"/>
</FONT>
</TD>
</TR>
<!-- new test -->
<TR>
<TD VALIGN="TOP"><B>Test:</B></TD>
<TD>
&lt;xsl:value-of select="4+5*3"/&gt;<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>
&lt;xsl:value-of select="4+5*3+(6-4)*7"/&gt;<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>
&lt;xsl:value-of select="'747' + 8"/&gt;<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>

View File

@@ -1,87 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY cr "&#x0A;">
]>
<!--
/**
* 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>&lt;?xml version=&quot;1.0&quot;?&gt;</B><BR/>
</xsl:if>
<xsl:apply-templates select="node()"/>
</BODY>
</HTML>
</xsl:template>
<!-- comment template -->
<xsl:template match="comment()">
<I>&lt;!--<xsl:value-of select="."/>--&gt;</I>
</xsl:template>
<!-- generic element template -->
<xsl:template match="*">
<!-- open element tag -->
<FONT COLOR="blue">&lt;</FONT><FONT COLOR="red"><xsl:value-of select="name(.)"/></FONT>
<xsl:apply-templates select="@*"/><FONT COLOR="blue">&gt;</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">&lt;/</FONT>
<FONT COLOR="red"><xsl:value-of select="name(.)"/></FONT>
<FONT COLOR="blue">&gt;</FONT>
<BR/>
</xsl:template>
<!-- generic attribute template -->
<xsl:template match="@*">
&#160;<B><xsl:value-of select="name(.)"/></B>
<FONT COLOR="green">=&quot;<xsl:value-of select="."/>&quot;</FONT>
</xsl:template>
<!-- processing instruction template -->
<xsl:template match="processing-instruction()">
<I>&lt;?<xsl:value-of select="name(.)"/>&#160;<xsl:value-of select="."/>?&gt;</I><BR/>
</xsl:template>
</xsl:stylesheet>

View File

@@ -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/NodeSetFunctionCall.$(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/StringFunctionCall.$(OBJ_SUFFIX) \
../xpath/StringResult.$(OBJ_SUFFIX) \
../xpath/txLiteralExpr.$(OBJ_SUFFIX) \
../xpath/txNameTest.$(OBJ_SUFFIX) \
../xpath/txNodeSet.$(OBJ_SUFFIX) \
../xpath/txNodeTypeTest.$(OBJ_SUFFIX) \
../xpath/txForwardContext.$(OBJ_SUFFIX) \
../xpath/txNodeSetContext.$(OBJ_SUFFIX) \
../xpath/txResultRecycler.$(OBJ_SUFFIX) \
../xpath/txStandaloneXPathTreeWalker.$(OBJ_SUFFIX) \
../xpath/UnionExpr.$(OBJ_SUFFIX) \
../xpath/UnaryExpr.$(OBJ_SUFFIX) \
../xpath/VariableRefExpr.$(OBJ_SUFFIX) \
../xml/XMLUtils.$(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

View File

@@ -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
SIMPLE_PROGRAMS = transformiix$(BIN_SUFFIX) testXalan$(BIN_SUFFIX) \
txTestExpr$(BIN_SUFFIX)
ifdef MARK_INC
SIMPLE_PROGRAMS += txXSLTMarkDriver$(BIN_SUFFIX)
endif
REQUIRES = string \
xpcom \
expat \
jprof \
$(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)
ifdef MOZ_JPROF
LIBS += -ljprof
endif
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)

View File

@@ -1,424 +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
#ifdef MOZ_JPROF
#include "jprof.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
#ifdef MOZ_JPROF
setupProfilingStuff();
#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;
}

View File

@@ -1,207 +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"
#ifdef MOZ_JPROF
#include "jprof.h"
#endif
/**
* 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)
{
using namespace std;
nsresult rv;
#ifdef MOZ_JPROF
setupProfilingStuff();
#endif
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);
}
if (NS_FAILED(rv)) {
cerr << "transformation failed with " << hex << rv << endl;
}
resultFileStream.close();
txXSLTProcessor::shutdown();
rv = NS_ShutdownXPCOM(nsnull);
NS_ENSURE_SUCCESS(rv, rv);
return 0;
}

View File

@@ -1,143 +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 "nsXPCOM.h"
#include "txStandaloneXSLTProcessor.h"
#include "nsString.h"
#include "ExprParser.h"
#include "txIXPathContext.h"
/**
* A ExprParser test exe
*/
static const char* kTokens[] = {"(", "concat", "(", "foo", ",", "'", "bar",
"'",")", "//", ".", "[", "preceding-sibling",
"::", "bar", "]", "/", "*", "[", "23", "]",
"|", "node", "(", ")", ")", "<", "3"};
static const PRUint8 kCount = sizeof(kTokens)/sizeof(char*);
class ParseContextImpl : public txIParseContext
{
public:
nsresult
resolveNamespacePrefix(nsIAtom* aPrefix, PRInt32& aID)
{
return NS_ERROR_FAILURE;
}
nsresult
resolveFunctionCall(nsIAtom* aName, PRInt32 aID, FunctionCall*& aFunction)
{
return NS_ERROR_XPATH_UNKNOWN_FUNCTION;
}
PRBool
caseInsensitiveNameTests()
{
return PR_FALSE;
}
void
SetErrorOffset(PRUint32 aOffset)
{
mOff = aOffset;
}
PRUint32 mOff;
};
static void doTest(const nsASingleFragmentString& aExpr)
{
ParseContextImpl ct;
nsAutoPtr<Expr> expression;
cout << NS_LossyConvertUTF16toASCII(aExpr).get() << endl;
ct.mOff = 0;
nsresult rv = txExprParser::createExpr(aExpr, &ct,
getter_Transfers(expression));
cout << "createExpr returned " << hex << rv << dec;
cout << " at " << ct.mOff << endl;
if (NS_FAILED(rv)) {
NS_LossyConvertUTF16toASCII cstring(aExpr);
cout << NS_LossyConvertUTF16toASCII(StringHead(aExpr, ct.mOff)).get();
cout << " ^ ";
cout << NS_LossyConvertUTF16toASCII(StringTail(aExpr, aExpr.Length()-ct.mOff)).get();
cout << endl << endl;
}
else {
nsAutoString expr;
expression->toString(expr);
cout << "parsed expression: ";
cout << NS_LossyConvertUTF16toASCII(expr).get() << endl << endl;
}
}
int main(int argc, char** argv)
{
using namespace std;
nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
if (!txXSLTProcessor::init())
return 1;
nsAutoString exprOrig, expr;
nsStringArray exprHead, exprTail;
PRUint8 i, dropStart, dropEnd;
exprHead.AppendString(NS_ConvertASCIItoUTF16(kTokens[0]));
exprTail.AppendString(NS_ConvertASCIItoUTF16(kTokens[kCount - 1]));
for (i = 2; i < kCount; ++i) {
exprHead.AppendString(*exprHead[i - 2] +
NS_ConvertASCIItoUTF16(kTokens[i - 1]));
exprTail.AppendString(NS_ConvertASCIItoUTF16(kTokens[kCount - i]) +
*exprTail[i - 2]);
}
exprOrig = NS_ConvertASCIItoUTF16(kTokens[0]) + *exprTail[kCount - 2];
cout << NS_LossyConvertUTF16toASCII(exprOrig).get() << endl << endl;
for (dropStart = 0; dropStart < kCount - 2; ++dropStart) {
doTest(*exprTail[kCount - 2 - dropStart]);
for (dropEnd = kCount - 3 - dropStart; dropEnd > 0; --dropEnd) {
expr = *exprHead[dropStart] + *exprTail[dropEnd];
doTest(expr);
}
doTest(*exprHead[dropStart]);
}
doTest(*exprHead[kCount - 2]);
txXSLTProcessor::shutdown();
rv = NS_ShutdownXPCOM(nsnull);
NS_ENSURE_SUCCESS(rv, rv);
return 0;
}

View File

@@ -1,132 +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"
#ifdef MOZ_JPROF
#include "jprof.h"
#endif
class txDriverProcessor : public txStandaloneXSLTProcessor,
public xmExternalDriver
{
public:
txDriverProcessor() : mXML(0), mOut(0)
{
}
int loadStylesheet (char * filename)
{
txParsedURL url;
url.init(NS_ConvertASCIItoUCS2(filename));
nsresult rv =
TX_CompileStylesheetPath(url, 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;
mStylesheet = 0;
return 0;
}
~txDriverProcessor()
{
delete mXML;
delete mOut;
}
private:
txXPathNode *mXML;
nsRefPtr<txStylesheet> mStylesheet;
SimpleErrorObserver mObserver;
ofstream* mOut;
};
int main (int argc, char ** argv)
{
txDriverProcessor driver;
#ifdef MOZ_JPROF
setupProfilingStuff();
#endif
NS_InitXPCOM2(nsnull, nsnull, nsnull);
if (!txDriverProcessor::init())
return 1;
driver.main (argc, argv);
txDriverProcessor::shutdown();
NS_ShutdownXPCOM(nsnull);
return 0;
}

View File

@@ -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 \
$(NULL)
ifndef TX_EXE
REQUIRES += dom \
content \
widget \
unicharutil \
necko \
$(NULL)
endif
DIRS = dom parser
CPPSRCS = XMLUtils.cpp
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(srcdir)/../base -I$(srcdir)/dom -I$(srcdir)/../xpath \
-I$(srcdir)/../xslt
libs:: $(OBJS)

View File

@@ -1,643 +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"
#include "txXPathTreeWalker.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;
}
/**
* 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;
}
}
//static
MBool XMLUtils::getXMLSpacePreserve(const txXPathNode& aNode)
{
nsAutoString value;
txXPathTreeWalker walker(aNode);
do {
if (walker.getAttr(txXMLAtoms::space, kNameSpaceID_XML, value)) {
if (TX_StringEqualsAtom(value, txXMLAtoms::preserve)) {
return PR_TRUE;
}
if (TX_StringEqualsAtom(value, txXMLAtoms::_default)) {
return PR_FALSE;
}
}
} while (walker.moveToParent());
return PR_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;
}

View File

@@ -1,156 +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 "nsDependentSubstring.h"
#include "nsIAtom.h"
#include "txError.h"
#include "txXPathNode.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);
/**
* 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(const txXPathNode& aNode);
};
#endif

View File

@@ -1,33 +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
ifdef TX_EXE
DIRS = standalone
endif
include $(topsrcdir)/config/rules.mk

View File

@@ -1,28 +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"
#endif
#endif

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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 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)
CPPSRCS = Attr.cpp \
Document.cpp \
Element.cpp \
NamedNodeMap.cpp \
NodeDefinition.cpp \
NodeListDefinition.cpp \
ProcessingInstruction.cpp
include $(topsrcdir)/config/rules.mk
INCLUDES += -I$(srcdir) -I$(srcdir)/../.. -I$(srcdir)/../../../base \
-I$(srcdir)/../../../xpath -I$(srcdir)/../../../xslt
libs:: $(OBJS)

View File

@@ -1,153 +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 NamedNodeMap class
//
#include "dom.h"
NamedNodeMap::NamedNodeMap()
{
}
NamedNodeMap::~NamedNodeMap()
{
}
Node* NamedNodeMap::getNamedItem(const nsAString& name)
{
ListItem* pSearchItem = findListItemByName(name);
if (pSearchItem)
return pSearchItem->node;
else
return nsnull;
}
Node* NamedNodeMap::setNamedItem(Node* arg)
{
//Since the DOM does not specify any ording for the NamedNodeMap, just
//try and remove the new node (arg). If successful, return a pointer to
//the removed item. Reguardless of wheter the node already existed or not,
//insert the new node at the end of the list.
nsAutoString nodeName;
arg->getNodeName(nodeName);
Node* pReplacedNode = removeNamedItem(nodeName);
NodeListDefinition::append(arg);
return pReplacedNode;
}
Node* NamedNodeMap::removeNamedItem(const nsAString& name)
{
NodeListDefinition::ListItem* pSearchItem;
Node* returnNode;
pSearchItem = findListItemByName(name);
if (pSearchItem)
{
if (pSearchItem != firstItem)
pSearchItem->prev->next = pSearchItem->next;
else
firstItem = pSearchItem->next;
if (pSearchItem != lastItem)
pSearchItem->next->prev = pSearchItem->prev;
else
lastItem = pSearchItem->prev;
pSearchItem->next = nsnull;
pSearchItem->prev = nsnull;
length--;
returnNode = pSearchItem->node;
delete pSearchItem;
return returnNode;
}
return nsnull;
}
NodeListDefinition::ListItem*
NamedNodeMap::findListItemByName(const nsAString& name)
{
NodeListDefinition::ListItem* pSearchItem = firstItem;
while (pSearchItem)
{
nsAutoString nodeName;
pSearchItem->node->getNodeName(nodeName);
if (name.Equals(nodeName))
return pSearchItem;
pSearchItem = pSearchItem->next;
}
return nsnull;
}
AttrMap::AttrMap()
{
ownerElement = nsnull;
}
AttrMap::~AttrMap()
{
}
Node* AttrMap::setNamedItem(Node* arg)
{
if (arg->getNodeType() != Node::ATTRIBUTE_NODE)
return nsnull;
((Attr*)arg)->ownerElement = ownerElement;
return NamedNodeMap::setNamedItem(arg);
}
Node* AttrMap::removeNamedItem(const nsAString& name)
{
Attr* node = (Attr*)NamedNodeMap::removeNamedItem(name);
if (node)
node->ownerElement = nsnull;
return node;
}
void AttrMap::clear()
{
ListItem* pDeleteItem;
ListItem* pListTraversal = firstItem;
while (pListTraversal) {
pDeleteItem = pListTraversal;
pListTraversal = pListTraversal->next;
delete pDeleteItem->node;
delete pDeleteItem;
}
firstItem = 0;
lastItem = 0;
length = 0;
}

View File

@@ -1,501 +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 NodeDefinition Class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
//
#include "dom.h"
#include "nsVoidArray.h"
#include "txURIUtils.h"
#include "txAtoms.h"
#include <string.h>
NodeDefinition::NodeDefinition(NodeType type, const nsAString& name,
const nsAString& value, Document* owner)
{
nodeName = name;
Init(type, value, owner);
}
NodeDefinition::NodeDefinition(NodeType aType, const nsAString& aValue,
Document* aOwner)
{
switch (aType)
{
case CDATA_SECTION_NODE:
{
nodeName = NS_LITERAL_STRING("#cdata-section");
break;
}
case COMMENT_NODE:
{
nodeName = NS_LITERAL_STRING("#comment");
break;
}
case DOCUMENT_NODE:
{
nodeName = NS_LITERAL_STRING("#document");
break;
}
case DOCUMENT_FRAGMENT_NODE:
{
nodeName = NS_LITERAL_STRING("#document-fragment");
break;
}
case TEXT_NODE:
{
nodeName = NS_LITERAL_STRING("#text");
break;
}
default:
{
break;
}
}
Init(aType, aValue, aOwner);
}
//
// This node is being destroyed, so loop through and destroy all the children.
//
NodeDefinition::~NodeDefinition()
{
DeleteChildren();
delete mOrderInfo;
}
void
NodeDefinition::Init(NodeType aType, const nsAString& aValue,
Document* aOwner)
{
nodeType = aType;
nodeValue = aValue;
ownerDocument = aOwner;
parentNode = nsnull;
previousSibling = nsnull;
nextSibling = nsnull;;
firstChild = nsnull;
lastChild = nsnull;
length = 0;
mOrderInfo = 0;
}
//
//Remove and delete all children of this node
//
void NodeDefinition::DeleteChildren()
{
NodeDefinition* pCurrent = firstChild;
NodeDefinition* pDestroyer;
while (pCurrent)
{
pDestroyer = pCurrent;
pCurrent = pCurrent->nextSibling;
delete pDestroyer;
}
length = 0;
firstChild = nsnull;
lastChild = nsnull;
}
nsresult NodeDefinition::getNodeName(nsAString& aName) const
{
aName = nodeName;
return NS_OK;
}
nsresult NodeDefinition::getNodeValue(nsAString& aValue)
{
aValue = nodeValue;
return NS_OK;
}
unsigned short NodeDefinition::getNodeType() const
{
return nodeType;
}
Node* NodeDefinition::getParentNode() const
{
return parentNode;
}
Node* NodeDefinition::getFirstChild() const
{
return firstChild;
}
Node* NodeDefinition::getLastChild() const
{
return lastChild;
}
Node* NodeDefinition::getPreviousSibling() const
{
return previousSibling;
}
Node* NodeDefinition::getNextSibling() const
{
return nextSibling;
}
NamedNodeMap* NodeDefinition::getAttributes()
{
return 0;
}
Document* NodeDefinition::getOwnerDocument() const
{
return ownerDocument;
}
Node* NodeDefinition::item(PRUint32 index)
{
PRUint32 selectLoop;
NodeDefinition* pSelectNode = firstChild;
if (index < length)
{
for (selectLoop=0;selectLoop<index;selectLoop++)
pSelectNode = pSelectNode->nextSibling;
return pSelectNode;
}
return nsnull;
}
PRUint32 NodeDefinition::getLength()
{
return length;
}
void NodeDefinition::setNodeValue(const nsAString& newNodeValue)
{
nodeValue = newNodeValue;
}
Node* NodeDefinition::appendChild(Node* newChild)
{
return nsnull;
}
NodeDefinition* NodeDefinition::implAppendChild(NodeDefinition* newChild)
{
// The new child should not be a child of any other node
if (!newChild->previousSibling && !newChild->nextSibling &&
!newChild->parentNode)
{
newChild->previousSibling = lastChild;
if (lastChild)
lastChild->nextSibling = newChild;
lastChild = newChild;
newChild->parentNode = this;
if (!newChild->previousSibling)
firstChild = newChild;
++length;
return newChild;
}
return nsnull;
}
NodeDefinition* NodeDefinition::implRemoveChild(NodeDefinition* oldChild)
{
if (oldChild != firstChild)
oldChild->previousSibling->nextSibling = oldChild->nextSibling;
else
firstChild = oldChild->nextSibling;
if (oldChild != lastChild)
oldChild->nextSibling->previousSibling = oldChild->previousSibling;
else
lastChild = oldChild->previousSibling;
oldChild->nextSibling = nsnull;
oldChild->previousSibling = nsnull;
oldChild->parentNode = nsnull;
--length;
return oldChild;
}
MBool NodeDefinition::hasChildNodes() const
{
if (firstChild)
return MB_TRUE;
else
return MB_FALSE;
}
MBool NodeDefinition::getLocalName(nsIAtom** aLocalName)
{
if (!aLocalName)
return MB_FALSE;
*aLocalName = 0;
return MB_TRUE;
}
nsresult NodeDefinition::getNamespaceURI(nsAString& aNSURI)
{
return txNamespaceManager::getNamespaceURI(getNamespaceID(), aNSURI);
}
PRInt32 NodeDefinition::getNamespaceID()
{
return kNameSpaceID_None;
}
//
// Looks up the Namespace associated with a certain prefix in the context of
// this node.
//
// @return namespace associated with prefix
//
PRInt32 NodeDefinition::lookupNamespaceID(nsIAtom* aPrefix)
{
// this is http://www.w3.org/2000/xmlns/,
// ID = kNameSpaceID_XMLNS, see txNamespaceManager::Init
if (aPrefix == txXMLAtoms::xmlns)
return kNameSpaceID_XMLNS;
// this is http://www.w3.org/XML/1998/namespace,
// ID = kNameSpaceID_XML, see txNamespaceManager::Init
if (aPrefix == txXMLAtoms::xml)
return kNameSpaceID_XML;
Node* node = this;
if (node->getNodeType() != Node::ELEMENT_NODE)
node = node->getXPathParent();
nsAutoString name(NS_LITERAL_STRING("xmlns:"));
if (aPrefix && (aPrefix != txXMLAtoms::_empty)) {
// We have a prefix, search for xmlns:prefix attributes.
nsAutoString prefixString;
aPrefix->ToString(prefixString);
name.Append(prefixString);
}
else {
// No prefix, look up the default namespace by searching for xmlns
// attributes. Remove the trailing :, set length to 5 (xmlns).
name.Truncate(5);
}
Attr* xmlns;
while (node && node->getNodeType() == Node::ELEMENT_NODE) {
if ((xmlns = ((Element*)node)->getAttributeNode(name))) {
/*
* xmlns:foo = "" makes "" a valid URI, so get that.
* xmlns = "" resolves to 0 (null Namespace) (caught above)
* in Element::getNamespaceID()
*/
nsAutoString nsURI;
xmlns->getNodeValue(nsURI);
return txNamespaceManager::getNamespaceID(nsURI);
}
node = node->getXPathParent();
}
if (!aPrefix || (aPrefix == txXMLAtoms::_empty))
return kNameSpaceID_None;
return kNameSpaceID_Unknown;
}
Node* NodeDefinition::getXPathParent()
{
return parentNode;
}
//
// Returns the base URI of the node. Acccounts for xml:base
// attributes.
//
// @return base URI for the node
//
nsresult NodeDefinition::getBaseURI(nsAString& aURI)
{
Node* node = this;
nsStringArray baseUrls;
nsAutoString url;
while (node) {
switch (node->getNodeType()) {
case Node::ELEMENT_NODE :
if (((Element*)node)->getAttr(txXMLAtoms::base, kNameSpaceID_XML,
url))
baseUrls.AppendString(url);
break;
case Node::DOCUMENT_NODE :
node->getBaseURI(url);
baseUrls.AppendString(url);
break;
default:
break;
}
node = node->getXPathParent();
}
PRInt32 count = baseUrls.Count();
if (count) {
baseUrls.StringAt(--count, aURI);
while (count > 0) {
nsAutoString dest;
URIUtils::resolveHref(*baseUrls[--count], aURI, dest);
aURI = dest;
}
}
return NS_OK;
} // getBaseURI
/*
* Compares document position of this node relative to another node
*/
PRInt32 NodeDefinition::compareDocumentPosition(Node* aOther)
{
OrderInfo* myOrder = getOrderInfo();
OrderInfo* otherOrder = ((NodeDefinition*)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
*/
NodeDefinition::OrderInfo* NodeDefinition::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 = ((NodeDefinition*)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*));
// Get childnumber of this node
int lastElem = parentOrder->mSize;
switch (getNodeType()) {
case Node::ATTRIBUTE_NODE:
{
NS_ASSERTION(parent->getNodeType() == Node::ELEMENT_NODE,
"parent to attribute is not an element");
Element* elem = (Element*)parent;
PRUint32 i;
NamedNodeMap* attrs = elem->getAttributes();
for (i = 0; i < attrs->getLength(); ++i) {
if (attrs->item(i) == this) {
mOrderInfo->mOrder[lastElem] = i + kTxAttrIndexOffset;
return mOrderInfo;
}
}
break;
}
// XXX Namespace: need to take care of namespace nodes here
default:
{
PRUint32 i = 0;
Node * child = parent->getFirstChild();
while (child) {
if (child == this) {
mOrderInfo->mOrder[lastElem] = i + kTxChildIndexOffset;
return mOrderInfo;
}
++i;
child = child->getNextSibling();
}
break;
}
}
NS_ASSERTION(0, "unable to get childnumber");
mOrderInfo->mOrder[lastElem] = 0;
return mOrderInfo;
}
/*
* OrderInfo destructor
*/
NodeDefinition::OrderInfo::~OrderInfo()
{
delete [] mOrder;
}

View File

@@ -1,119 +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 NodeListDefinition class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
//
#include "dom.h"
//
//Create an empty node list.
//
NodeListDefinition::NodeListDefinition()
{
firstItem = nsnull;
lastItem = nsnull;
length = 0;
}
//
//Free up the memory used by the List of Items. Don't delete the actual nodes
//though.
//
NodeListDefinition::~NodeListDefinition()
{
ListItem* pDeleteItem;
ListItem* pListTraversal = firstItem;
while (pListTraversal)
{
pDeleteItem = pListTraversal;
pListTraversal = pListTraversal->next;
delete pDeleteItem;
}
}
//
//Create a new ListItem, point it to the newNode, and append it to the current
//list of nodes.
//
void NodeListDefinition::append(Node* newNode)
{
append(*newNode);
}
void NodeListDefinition::append(Node& newNode)
{
ListItem* newListItem = new ListItem;
if (!newListItem)
return;
// Setup the new list item
newListItem->node = &newNode;
newListItem->prev = lastItem;
newListItem->next = nsnull;
//Append the list item
if (lastItem)
lastItem->next = newListItem;
lastItem = newListItem;
//Adjust firstItem if this new item is being added to an empty list
if (!firstItem)
firstItem = lastItem;
//Need to increment the length of the list. Inherited from NodeList
length++;
}
//
// Return the Node contained in the item specified
//
Node* NodeListDefinition::item(PRUint32 index)
{
PRUint32 selectLoop;
ListItem* pListItem = firstItem;
if (index < length)
{
for (selectLoop=0;selectLoop<index;selectLoop++)
pListItem = pListItem->next;
return pListItem->node;
}
return nsnull;
}
//
// Return the number of items in the list
//
PRUint32 NodeListDefinition::getLength()
{
return length;
}

View File

@@ -1,66 +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 ProcessingInstruction class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
//
#include "dom.h"
#include "nsIAtom.h"
//
//Construct a text object with the specified document owner and data
//
ProcessingInstruction::ProcessingInstruction(const nsAString& theTarget,
const nsAString& theData,
Document* owner) :
NodeDefinition(Node::PROCESSING_INSTRUCTION_NODE,
theTarget, theData, owner)
{
mLocalName = do_GetAtom(nodeName);
}
//
//Release the mLocalName
//
ProcessingInstruction::~ProcessingInstruction()
{
}
//
//ProcessingInstruction nodes can not have any children, so just return null
//from all child manipulation functions.
//
MBool ProcessingInstruction::getLocalName(nsIAtom** aLocalName)
{
if (!aLocalName)
return MB_FALSE;
*aLocalName = mLocalName;
NS_ADDREF(*aLocalName);
return MB_TRUE;
}

Some files were not shown because too many files have changed in this diff Show More