Added Olivier's changes to support the document() function

This commit is contained in:
kvisco%ziplink.net 2000-05-24 03:46:31 +00:00
Родитель 7d4e22e9f7
Коммит d958ae6f7e
6 изменённых файлов: 77 добавлений и 24 удалений

Просмотреть файл

@ -28,14 +28,14 @@
* W3C XPath 1.0 Recommendation
* -- Added lang attr declaration
*
* $Id: Names.cpp,v 1.5 2000-05-23 08:13:03 kvisco%ziplink.net Exp $
* $Id: Names.cpp,v 1.6 2000-05-24 03:45:40 kvisco%ziplink.net Exp $
*/
/**
* XSL names used throughout the XSLProcessor.
* Probably should be wrapped in a Namespace
* @author <a href="mailto:kvisco@ziplink.net">Keith Visco</a>
* @version $Revision: 1.5 $ $Date: 2000-05-23 08:13:03 $
* @version $Revision: 1.6 $ $Date: 2000-05-24 03:45:40 $
**/
#include "Names.h"
@ -149,11 +149,12 @@ const String NODE_FNAME = "node";
const String IDENTITY_OP = ".";
const String PARENT_OP = "..";
//-- XSLT extension functions
//-- XSLT additional functions
const String CURRENT_FN = "current";
const String FORMAT_NUMBER_FN = "format-number";
const String GENERATE_ID_FN = "generate-id";
const String SYSTEM_PROPERTY_FN = "system-property";
const String DOCUMENT_FN = "document";
//-- MISC
const String WILD_CARD = "*";

Просмотреть файл

@ -27,7 +27,7 @@
* W3C XPath 1.0 Recommendation
* -- Added lang attr declaration
* $Id: Names.h,v 1.5 2000-05-23 08:13:03 kvisco%ziplink.net Exp $
* $Id: Names.h,v 1.6 2000-05-24 03:45:41 kvisco%ziplink.net Exp $
*/
#include "TxString.h"
@ -144,11 +144,13 @@ extern const String NODE_FNAME;
extern const String IDENTITY_OP;
extern const String PARENT_OP;
//-- XSLT extension functions
//-- XSLT additional functions
extern const String CURRENT_FN;
extern const String FORMAT_NUMBER_FN;
extern const String GENERATE_ID_FN;
extern const String SYSTEM_PROPERTY_FN;
extern const String DOCUMENT_FN;
//-- MISC
extern const String WILD_CARD;

Просмотреть файл

@ -15,20 +15,23 @@
* 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.
* (C) 1999-2000 Keith Visco. All Rights Reserved.
*
* Contributor(s):
* Keith Visco, kvisco@ziplink.net
* -- original author.
*
* $Id: ProcessorState.cpp,v 1.2 2000-04-19 10:41:13 kvisco%ziplink.net Exp $
* Olivier Gerardin, ogerardin@vo.lu
* -- added code in ::resolveFunctionCall to support the
* document() function.
*
* $Id: ProcessorState.cpp,v 1.3 2000-05-24 03:45:41 kvisco%ziplink.net Exp $
*/
/**
* Implementation of ProcessorState
* This code was ported from XSL:P
* @author <a href="kvisco@ziplink.net">Keith Visco</a>
* @version $Revision: 1.2 $ $Date: 2000-04-19 10:41:13 $
* Much of this code was ported from XSL:P
* @version $Revision: 1.3 $ $Date: 2000-05-24 03:45:41 $
**/
#include "ProcessorState.h"
@ -587,6 +590,9 @@ FunctionCall* ProcessorState::resolveFunctionCall(const String& name) {
if (GENERATE_ID_FN.isEqual(name)) {
return new GenerateIdFunctionCall(&domHelper);
}
else if (DOCUMENT_FN.isEqual(name)) {
return new DocumentFunctionCall(xslDocument);
}
String err("invalid function call: ");
err.append(name);
@ -597,7 +603,7 @@ FunctionCall* ProcessorState::resolveFunctionCall(const String& name) {
/**
* Sorts the given NodeSet by DocumentOrder.
* Sorts the given NodeSet by DocumentOrder.
* @param nodes the NodeSet to sort
* <BR />
* <B>Note:</B> I will be moving this functionality elsewhere soon
@ -625,7 +631,7 @@ void ProcessorState::sortByDocumentOrder(NodeSet* nodes) {
}
nodes->clear();
for (i = 0; i < sorted.size(); i++)
for (i = 0; i < sorted.size(); i++)
nodes->add(sorted.get(i));
sorted.clear();

Просмотреть файл

@ -2,29 +2,39 @@
ROOT = ../..
BASE = $(ROOT)/base
NET = $(ROOT)/net
XPATH = $(ROOT)/xpath
XML = $(ROOT)/xml
XML_UTIL = $(XML)/util
DOM = $(XML)/dom
XSLT = $(ROOT)/xslt
XMLPARSER_PATH = $(XML)/parser
EXPAT_PARSER_PATH = $(XMLPARSER_PATH)/xmlparse
ALL_OBJS = \
GenerateIdFunctionCall.o
GenerateIdFunctionCall.o \
DocumentFunctionCall.o
INCLUDE_PATH = -I. \
-I$(BASE) \
-I$(NET) \
-I$(XPATH) \
-I$(XML) \
-I$(XML)/parser \
-I$(XML_UTIL) \
-I$(DOM) \
-I$(XSLT) \
-I$(XSLT)/util
-I$(XSLT)/util \
-I$(EXPAT_PARSER_PATH)
target: $(ALL_OBJS)
GenerateIdFunctionCall.o: XSLTFunctions.h GenerateIdFunctionCall.cpp
$(CC) $(INCLUDE_PATH) -c GenerateIdFunctionCall.cpp
DocumentFunctionCall.o: XSLTFunctions.h DocumentFunctionCall.cpp
$(CC) $(INCLUDE_PATH) -c DocumentFunctionCall.cpp

Просмотреть файл

@ -1,23 +1,23 @@
#
#
# 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@
@ -26,7 +26,8 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
CPPSRCS = GenerateIdFunctionCall.cpp
CPPSRCS = GenerateIdFunctionCall.cpp \
DocumentFunctionCall.cpp
include $(topsrcdir)/config/rules.mk
@ -34,4 +35,4 @@ INCLUDES += -I$(srcdir)/../../base -I$(srcdir)/../../xpath \
-I$(srcdir)/../../xml -I$(srcdir)/../../xml/util -I$(srcdir)/../../xml/dom \
-I$(srcdir)/../../xslt
install:: $(OBJS)
install:: $(OBJS)

Просмотреть файл

@ -20,7 +20,10 @@
* Keith Visco, kvisco@ziplink.net
* -- original author.
*
* $Id: XSLTFunctions.h,v 1.1 2000-04-19 10:40:06 kvisco%ziplink.net Exp $
* Olivier Gerardin,
* -- added document() function definition
*
* $Id: XSLTFunctions.h,v 1.2 2000-05-24 03:46:31 kvisco%ziplink.net Exp $
*/
#include "dom.h"
@ -33,6 +36,9 @@
#ifndef TRANSFRMX_XSLT_FUNCTIONS_H
#define TRANSFRMX_XSLT_FUNCTIONS_H
/**
* The definition for the XSLT generate-id() function
**/
class GenerateIdFunctionCall : public FunctionCall {
public:
@ -56,4 +62,31 @@ private:
DOMHelper* domHelper;
};
#endif
/**
* The definition for the XSLT document() function
**/
class DocumentFunctionCall : public FunctionCall {
public:
/**
* Creates a new document() function call
**/
DocumentFunctionCall(Document* xslDocument);
/**
* Evaluates this Expr based on the given context node and processor state
* @param context the context node for evaluation of this Expr
* @param ps the ContextState containing the stack information needed
* for evaluation
* @return the result of the evaluation
* @see FunctionCall.h
**/
virtual ExprResult* evaluate(Node* context, ContextState* cs);
private:
void retrieveDocument(String& uri,String& baseUri, NodeSet &resultNodeSet, ContextState* cs);
Document* xslDocument;
};
#endif