mirror of
https://gitlab.gnome.org/GNOME/libxslt
synced 2025-08-08 21:42:07 +03:00
Refactored xsltValueOf(). Changed to use xmlXPathCastToString() directly,
* libxslt/attributes.c libxslt/documents.c libxslt/functions.c libxslt/keys.c libxslt/namespaces.c libxslt/pattern.c libxslt/preproc.c libxslt/templates.c libxslt/templates.h libxslt/transform.c libxslt/variables.c libxslt/xslt.c libxslt/xsltInternals.h libxslt/xsltutils.c libxslt/xsltutils.h libexslt/common.c libexslt/dynamic.c libexslt/functions.c libexslt/strings.c: Refactored xsltValueOf(). Changed to use xmlXPathCastToString() directly, rather than creating an intermediate object with xmlXPathConvertString(). This now does not add a text-node to the result if the string is empty (this has impact on serialization, since an empty text-node is serialized as <foo></foo>, and now it will be serialized as <foo/>). Refactored other functions in transform.c: Mostly code cleanup/restructuring. Minimized number of function variables for instruction which eat up function stack memory when recursing templates (xsltIf(), xsltChoose(), xsltApplyTemplates(), xsltCallTemplate()). Changed XSLT tests to use xmlXPathCompiledEvalToBoolean(). Implemented redefinition checks at compilation-time and eliminating them at transformation time in the refactored code paths. Introduced the field @currentTemplateRule on xsltTransformContext to reflect the "Current Template Rule" as defined by the spec. NOTE that ctxt->currentTemplateRule and ctxt->templ is not the same; the former is the "Current Template Rule" as defined by the XSLT spec, the latter is simply the template struct being currently processed by Libxslt. Added XML_COMMENT_NODE and XML_CDATA_SECTION_NODE to the macro IS_XSLT_REAL_NODE. Misc code cleanup/restructuring and everything else I already forgot. Refactored lifetime of temporary result tree fragments. Substituted all calls to the now deprecated xsltRegisterTmpRVT() for the new xsltRegisterLocalRVT(). Fragments of xsl:variable and xsl:param are freed when the variable/pram is freed. Fragments created when evaluating a "select" of xsl:varible and xsl:param are also bound to the lifetime of the var/param. EXSLT's func:function now uses the following functions to let take care the transformation's garbage collector of returned tree fragments: xsltExtensionInstructionResultRegister(), xsltExtensionInstructionResultFinalize() Fixes: #339222 - xsl:param at invalid position inside an xsl:template is not catched #346015 - Non-declared caller-parameters are accepted #160400 - Compiles invalid XSLT; unbound variable accepted #308441 - namespaced parameters become unregistered #307103 - problem with proximity position in predicates of match patterns #328218 - problem with exsl:node-set() when converting strings to node sets #318088 - infinite recursion detection #321505 - Multiple contiguous CDATA in output #334493 - "--param" option does not have root context #114377 - weird func:result/xsl:variable/exsl:node-set interaction #150309 - Regression caused by fix for 142768
This commit is contained in:
61
ChangeLog
61
ChangeLog
@@ -1,3 +1,64 @@
|
||||
Fri Jul 14 17:55:42 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
|
||||
|
||||
* libxslt/attributes.c libxslt/documents.c
|
||||
libxslt/functions.c libxslt/keys.c libxslt/namespaces.c
|
||||
libxslt/pattern.c libxslt/preproc.c libxslt/templates.c
|
||||
libxslt/templates.h libxslt/transform.c libxslt/variables.c
|
||||
libxslt/xslt.c libxslt/xsltInternals.h libxslt/xsltutils.c
|
||||
libxslt/xsltutils.h libexslt/common.c libexslt/dynamic.c
|
||||
libexslt/functions.c libexslt/strings.c:
|
||||
Refactored xsltValueOf(). Changed to use xmlXPathCastToString()
|
||||
directly, rather than creating an intermediate object with
|
||||
xmlXPathConvertString(). This now does not add a text-node to
|
||||
the result if the string is empty (this has impact on
|
||||
serialization, since an empty text-node is serialized as
|
||||
<foo></foo>, and now it will be serialized as <foo/>).
|
||||
Refactored other functions in transform.c:
|
||||
Mostly code cleanup/restructuring. Minimized number of
|
||||
function variables for instruction which eat up function stack
|
||||
memory when recursing templates (xsltIf(), xsltChoose(),
|
||||
xsltApplyTemplates(), xsltCallTemplate()).
|
||||
Changed XSLT tests to use xmlXPathCompiledEvalToBoolean().
|
||||
Implemented redefinition checks at compilation-time and
|
||||
eliminating them at transformation time in the refactored code
|
||||
paths.
|
||||
Introduced the field @currentTemplateRule on xsltTransformContext to
|
||||
reflect the "Current Template Rule" as defined by the spec.
|
||||
NOTE that ctxt->currentTemplateRule and ctxt->templ is not the
|
||||
same; the former is the "Current Template Rule" as defined by the
|
||||
XSLT spec, the latter is simply the template struct being
|
||||
currently processed by Libxslt.
|
||||
Added XML_COMMENT_NODE and XML_CDATA_SECTION_NODE to the macro
|
||||
IS_XSLT_REAL_NODE.
|
||||
Misc code cleanup/restructuring and everything else I already forgot.
|
||||
Refactored lifetime of temporary result tree fragments.
|
||||
Substituted all calls to the now deprecated xsltRegisterTmpRVT()
|
||||
for the new xsltRegisterLocalRVT().
|
||||
Fragments of xsl:variable and xsl:param are freed when the
|
||||
variable/pram is freed.
|
||||
Fragments created when evaluating a "select" of xsl:varible and
|
||||
xsl:param are also bound to the lifetime of the var/param.
|
||||
EXSLT's func:function now uses the following functions to let take
|
||||
care the transformation's garbage collector of returned tree
|
||||
fragments:
|
||||
xsltExtensionInstructionResultRegister(),
|
||||
xsltExtensionInstructionResultFinalize()
|
||||
Fixes:
|
||||
#339222 - xsl:param at invalid position inside an xsl:template is
|
||||
not catched
|
||||
#346015 - Non-declared caller-parameters are accepted
|
||||
#160400 - Compiles invalid XSLT; unbound variable accepted
|
||||
#308441 - namespaced parameters become unregistered
|
||||
#307103 - problem with proximity position in predicates of match
|
||||
patterns
|
||||
#328218 - problem with exsl:node-set() when converting strings
|
||||
to node sets
|
||||
#318088 - infinite recursion detection
|
||||
#321505 - Multiple contiguous CDATA in output
|
||||
#334493 - "--param" option does not have root context
|
||||
#114377 - weird func:result/xsl:variable/exsl:node-set interaction
|
||||
#150309 - Regression caused by fix for 142768
|
||||
|
||||
Wed Jun 21 15:13:27 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
|
||||
|
||||
* tests/docs/bug-54.xml tests/general/bug-54.out
|
||||
|
@@ -1,116 +1,131 @@
|
||||
#define IN_LIBEXSLT
|
||||
#include "libexslt/libexslt.h"
|
||||
|
||||
#if defined(WIN32) && !defined (__CYGWIN__) && (!__MINGW32__)
|
||||
#include <win32config.h>
|
||||
#else
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
|
||||
#include <libxslt/xsltconfig.h>
|
||||
#include <libxslt/xsltutils.h>
|
||||
#include <libxslt/xsltInternals.h>
|
||||
#include <libxslt/extensions.h>
|
||||
#include <libxslt/transform.h>
|
||||
#include <libxslt/extra.h>
|
||||
#include <libxslt/preproc.h>
|
||||
|
||||
#include "exslt.h"
|
||||
|
||||
static void
|
||||
exsltNodeSetFunction (xmlXPathParserContextPtr ctxt, int nargs) {
|
||||
xmlChar *strval;
|
||||
xmlNodePtr retNode;
|
||||
xmlXPathObjectPtr ret;
|
||||
|
||||
if (nargs != 1) {
|
||||
xmlXPathSetArityError(ctxt);
|
||||
return;
|
||||
}
|
||||
|
||||
if (xmlXPathStackIsNodeSet (ctxt)) {
|
||||
xsltFunctionNodeSet (ctxt, nargs);
|
||||
return;
|
||||
}
|
||||
|
||||
strval = xmlXPathPopString (ctxt);
|
||||
retNode = xmlNewDocText (NULL, strval);
|
||||
ret = xmlXPathNewValueTree (retNode);
|
||||
if (ret == NULL) {
|
||||
xsltGenericError(xsltGenericErrorContext,
|
||||
"exsltNodeSetFunction: ret == NULL\n");
|
||||
} else {
|
||||
ret->type = XPATH_NODESET;
|
||||
}
|
||||
|
||||
if (strval != NULL)
|
||||
xmlFree (strval);
|
||||
|
||||
valuePush (ctxt, ret);
|
||||
}
|
||||
|
||||
static void
|
||||
exsltObjectTypeFunction (xmlXPathParserContextPtr ctxt, int nargs) {
|
||||
xmlXPathObjectPtr obj, ret;
|
||||
|
||||
if (nargs != 1) {
|
||||
xmlXPathSetArityError(ctxt);
|
||||
return;
|
||||
}
|
||||
|
||||
obj = valuePop(ctxt);
|
||||
|
||||
switch (obj->type) {
|
||||
case XPATH_STRING:
|
||||
ret = xmlXPathNewCString("string");
|
||||
break;
|
||||
case XPATH_NUMBER:
|
||||
ret = xmlXPathNewCString("number");
|
||||
break;
|
||||
case XPATH_BOOLEAN:
|
||||
ret = xmlXPathNewCString("boolean");
|
||||
break;
|
||||
case XPATH_NODESET:
|
||||
ret = xmlXPathNewCString("node-set");
|
||||
break;
|
||||
case XPATH_XSLT_TREE:
|
||||
ret = xmlXPathNewCString("RTF");
|
||||
break;
|
||||
case XPATH_USERS:
|
||||
ret = xmlXPathNewCString("external");
|
||||
break;
|
||||
default:
|
||||
xsltGenericError(xsltGenericErrorContext,
|
||||
"object-type() invalid arg\n");
|
||||
ctxt->error = XPATH_INVALID_TYPE;
|
||||
xmlXPathFreeObject(obj);
|
||||
return;
|
||||
}
|
||||
xmlXPathFreeObject(obj);
|
||||
valuePush(ctxt, ret);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* exsltCommonRegister:
|
||||
*
|
||||
* Registers the EXSLT - Common module
|
||||
*/
|
||||
|
||||
void
|
||||
exsltCommonRegister (void) {
|
||||
xsltRegisterExtModuleFunction((const xmlChar *) "node-set",
|
||||
EXSLT_COMMON_NAMESPACE,
|
||||
exsltNodeSetFunction);
|
||||
xsltRegisterExtModuleFunction((const xmlChar *) "object-type",
|
||||
EXSLT_COMMON_NAMESPACE,
|
||||
exsltObjectTypeFunction);
|
||||
xsltRegisterExtModuleElement((const xmlChar *) "document",
|
||||
EXSLT_COMMON_NAMESPACE,
|
||||
(xsltPreComputeFunction) xsltDocumentComp,
|
||||
(xsltTransformFunction) xsltDocumentElem);
|
||||
}
|
||||
#define IN_LIBEXSLT
|
||||
#include "libexslt/libexslt.h"
|
||||
|
||||
#if defined(WIN32) && !defined (__CYGWIN__) && (!__MINGW32__)
|
||||
#include <win32config.h>
|
||||
#else
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
|
||||
#include <libxslt/xsltconfig.h>
|
||||
#include <libxslt/xsltutils.h>
|
||||
#include <libxslt/xsltInternals.h>
|
||||
#include <libxslt/extensions.h>
|
||||
#include <libxslt/transform.h>
|
||||
#include <libxslt/extra.h>
|
||||
#include <libxslt/preproc.h>
|
||||
|
||||
#include "exslt.h"
|
||||
|
||||
static void
|
||||
exsltNodeSetFunction (xmlXPathParserContextPtr ctxt, int nargs) {
|
||||
if (nargs != 1) {
|
||||
xmlXPathSetArityError(ctxt);
|
||||
return;
|
||||
}
|
||||
if (xmlXPathStackIsNodeSet (ctxt)) {
|
||||
xsltFunctionNodeSet (ctxt, nargs);
|
||||
return;
|
||||
} else {
|
||||
xmlDocPtr fragment;
|
||||
xsltTransformContextPtr tctxt = xsltXPathGetTransformContext(ctxt);
|
||||
xmlNodePtr txt;
|
||||
xmlChar *strval;
|
||||
xmlXPathObjectPtr obj;
|
||||
/*
|
||||
* SPEC EXSLT:
|
||||
* "You can also use this function to turn a string into a text
|
||||
* node, which is helpful if you want to pass a string to a
|
||||
* function that only accepts a node-set."
|
||||
*/
|
||||
fragment = xsltCreateRVT(tctxt);
|
||||
if (fragment == NULL) {
|
||||
xsltTransformError(tctxt, NULL, tctxt->inst,
|
||||
"exsltNodeSetFunction: Failed to create a tree fragment.\n");
|
||||
tctxt->state = XSLT_STATE_STOPPED;
|
||||
return;
|
||||
}
|
||||
xsltRegisterLocalRVT(tctxt, fragment);
|
||||
|
||||
strval = xmlXPathPopString (ctxt);
|
||||
|
||||
txt = xmlNewDocText (fragment, strval);
|
||||
xmlAddChild((xmlNodePtr) fragment, txt);
|
||||
obj = xmlXPathNewNodeSet(txt);
|
||||
if (obj == NULL) {
|
||||
xsltTransformError(tctxt, NULL, tctxt->inst,
|
||||
"exsltNodeSetFunction: Failed to create a node set object.\n");
|
||||
tctxt->state = XSLT_STATE_STOPPED;
|
||||
}
|
||||
if (strval != NULL)
|
||||
xmlFree (strval);
|
||||
|
||||
valuePush (ctxt, obj);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
exsltObjectTypeFunction (xmlXPathParserContextPtr ctxt, int nargs) {
|
||||
xmlXPathObjectPtr obj, ret;
|
||||
|
||||
if (nargs != 1) {
|
||||
xmlXPathSetArityError(ctxt);
|
||||
return;
|
||||
}
|
||||
|
||||
obj = valuePop(ctxt);
|
||||
|
||||
switch (obj->type) {
|
||||
case XPATH_STRING:
|
||||
ret = xmlXPathNewCString("string");
|
||||
break;
|
||||
case XPATH_NUMBER:
|
||||
ret = xmlXPathNewCString("number");
|
||||
break;
|
||||
case XPATH_BOOLEAN:
|
||||
ret = xmlXPathNewCString("boolean");
|
||||
break;
|
||||
case XPATH_NODESET:
|
||||
ret = xmlXPathNewCString("node-set");
|
||||
break;
|
||||
case XPATH_XSLT_TREE:
|
||||
ret = xmlXPathNewCString("RTF");
|
||||
break;
|
||||
case XPATH_USERS:
|
||||
ret = xmlXPathNewCString("external");
|
||||
break;
|
||||
default:
|
||||
xsltGenericError(xsltGenericErrorContext,
|
||||
"object-type() invalid arg\n");
|
||||
ctxt->error = XPATH_INVALID_TYPE;
|
||||
xmlXPathFreeObject(obj);
|
||||
return;
|
||||
}
|
||||
xmlXPathFreeObject(obj);
|
||||
valuePush(ctxt, ret);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* exsltCommonRegister:
|
||||
*
|
||||
* Registers the EXSLT - Common module
|
||||
*/
|
||||
|
||||
void
|
||||
exsltCommonRegister (void) {
|
||||
xsltRegisterExtModuleFunction((const xmlChar *) "node-set",
|
||||
EXSLT_COMMON_NAMESPACE,
|
||||
exsltNodeSetFunction);
|
||||
xsltRegisterExtModuleFunction((const xmlChar *) "object-type",
|
||||
EXSLT_COMMON_NAMESPACE,
|
||||
exsltObjectTypeFunction);
|
||||
xsltRegisterExtModuleElement((const xmlChar *) "document",
|
||||
EXSLT_COMMON_NAMESPACE,
|
||||
(xsltPreComputeFunction) xsltDocumentComp,
|
||||
(xsltTransformFunction) xsltDocumentElem);
|
||||
}
|
||||
|
@@ -1,274 +1,274 @@
|
||||
/*
|
||||
* dynamic.c: Implementation of the EXSLT -- Dynamic module
|
||||
*
|
||||
* References:
|
||||
* http://www.exslt.org/dyn/dyn.html
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Authors:
|
||||
* Mark Vakoc <mark_vakoc@jdedwards.com>
|
||||
* Thomas Broyer <tbroyer@ltgt.net>
|
||||
*
|
||||
* TODO:
|
||||
* elements:
|
||||
* functions:
|
||||
* min
|
||||
* max
|
||||
* sum
|
||||
* map
|
||||
* closure
|
||||
*/
|
||||
|
||||
#define IN_LIBEXSLT
|
||||
#include "libexslt/libexslt.h"
|
||||
|
||||
#if defined(WIN32) && !defined (__CYGWIN__) && (!__MINGW32__)
|
||||
#include <win32config.h>
|
||||
#else
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
|
||||
#include <libxslt/xsltconfig.h>
|
||||
#include <libxslt/xsltutils.h>
|
||||
#include <libxslt/xsltInternals.h>
|
||||
#include <libxslt/extensions.h>
|
||||
|
||||
#include "exslt.h"
|
||||
|
||||
/**
|
||||
* exsltDynEvaluateFunction:
|
||||
* @ctxt: an XPath parser context
|
||||
* @nargs: the number of arguments
|
||||
*
|
||||
* Evaluates the string as an XPath expression and returns the result
|
||||
* value, which may be a boolean, number, string, node set, result tree
|
||||
* fragment or external object.
|
||||
*/
|
||||
|
||||
static void
|
||||
exsltDynEvaluateFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
||||
xmlChar *str = NULL;
|
||||
xmlXPathObjectPtr ret = NULL;
|
||||
|
||||
if (ctxt == NULL)
|
||||
return;
|
||||
if (nargs != 1) {
|
||||
xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
|
||||
xsltGenericError(xsltGenericErrorContext,
|
||||
"dyn:evalute() : invalid number of args %d\n", nargs);
|
||||
ctxt->error = XPATH_INVALID_ARITY;
|
||||
return;
|
||||
}
|
||||
str = xmlXPathPopString(ctxt);
|
||||
/* return an empty node-set if an empty string is passed in */
|
||||
if (!str||!xmlStrlen(str)) {
|
||||
if (str) xmlFree(str);
|
||||
valuePush(ctxt,xmlXPathNewNodeSet(NULL));
|
||||
return;
|
||||
}
|
||||
ret = xmlXPathEval(str,ctxt->context);
|
||||
if (ret)
|
||||
valuePush(ctxt,ret);
|
||||
else {
|
||||
xsltGenericError(xsltGenericErrorContext,
|
||||
"dyn:evaluate() : unable to evaluate expression '%s'\n",str);
|
||||
valuePush(ctxt,xmlXPathNewNodeSet(NULL));
|
||||
}
|
||||
xmlFree(str);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* exsltDynMapFunction:
|
||||
* @ctxt: an XPath parser context
|
||||
* @nargs: the number of arguments
|
||||
*
|
||||
* Evaluates the string as an XPath expression and returns the result
|
||||
* value, which may be a boolean, number, string, node set, result tree
|
||||
* fragment or external object.
|
||||
*/
|
||||
|
||||
static void
|
||||
exsltDynMapFunction(xmlXPathParserContextPtr ctxt, int nargs)
|
||||
{
|
||||
xmlChar *str = NULL;
|
||||
xmlNodeSetPtr nodeset = NULL;
|
||||
xmlXPathCompExprPtr comp = NULL;
|
||||
xmlXPathObjectPtr ret = NULL;
|
||||
xmlDocPtr oldDoc, container;
|
||||
xmlNodePtr oldNode;
|
||||
int oldContextSize;
|
||||
int oldProximityPosition;
|
||||
int i, j;
|
||||
|
||||
|
||||
if (nargs != 2) {
|
||||
xmlXPathSetArityError(ctxt);
|
||||
return;
|
||||
}
|
||||
str = xmlXPathPopString(ctxt);
|
||||
if (xmlXPathCheckError(ctxt)) {
|
||||
xmlXPathSetTypeError(ctxt);
|
||||
return;
|
||||
}
|
||||
|
||||
nodeset = xmlXPathPopNodeSet(ctxt);
|
||||
if (xmlXPathCheckError(ctxt)) {
|
||||
xmlXPathSetTypeError(ctxt);
|
||||
return;
|
||||
}
|
||||
if (str == NULL || !xmlStrlen(str) || !(comp = xmlXPathCompile(str))) {
|
||||
if (nodeset != NULL)
|
||||
xmlXPathFreeNodeSet(nodeset);
|
||||
if (str != NULL)
|
||||
xmlFree(str);
|
||||
valuePush(ctxt, xmlXPathNewNodeSet(NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
ret = xmlXPathNewNodeSet(NULL);
|
||||
if (ret == NULL) {
|
||||
xsltGenericError(xsltGenericErrorContext,
|
||||
"exsltDynMapFunctoin: ret == NULL\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
oldDoc = ctxt->context->doc;
|
||||
oldNode = ctxt->context->node;
|
||||
oldContextSize = ctxt->context->contextSize;
|
||||
oldProximityPosition = ctxt->context->proximityPosition;
|
||||
|
||||
/**
|
||||
* since we really don't know we're going to be adding node(s)
|
||||
* down the road we create the RVT regardless
|
||||
*/
|
||||
container = xsltCreateRVT(xsltXPathGetTransformContext(ctxt));
|
||||
if (container != NULL)
|
||||
xsltRegisterTmpRVT(xsltXPathGetTransformContext(ctxt), container);
|
||||
|
||||
if (nodeset && nodeset->nodeNr > 0) {
|
||||
xmlXPathNodeSetSort(nodeset);
|
||||
ctxt->context->contextSize = nodeset->nodeNr;
|
||||
ctxt->context->proximityPosition = 0;
|
||||
for (i = 0; i < nodeset->nodeNr; i++) {
|
||||
xmlXPathObjectPtr subResult = NULL;
|
||||
|
||||
ctxt->context->proximityPosition++;
|
||||
ctxt->context->node = nodeset->nodeTab[i];
|
||||
ctxt->context->doc = nodeset->nodeTab[i]->doc;
|
||||
|
||||
subResult = xmlXPathCompiledEval(comp, ctxt->context);
|
||||
if (subResult != NULL) {
|
||||
switch (subResult->type) {
|
||||
case XPATH_NODESET:
|
||||
if (subResult->nodesetval != NULL)
|
||||
for (j = 0; j < subResult->nodesetval->nodeNr;
|
||||
j++)
|
||||
xmlXPathNodeSetAdd(ret->nodesetval,
|
||||
subResult->nodesetval->
|
||||
nodeTab[j]);
|
||||
break;
|
||||
case XPATH_BOOLEAN:
|
||||
if (container != NULL) {
|
||||
xmlNodePtr cur =
|
||||
xmlNewChild((xmlNodePtr) container, NULL,
|
||||
BAD_CAST "boolean",
|
||||
BAD_CAST (subResult->
|
||||
boolval ? "true" : ""));
|
||||
if (cur != NULL) {
|
||||
cur->ns =
|
||||
xmlNewNs(cur,
|
||||
BAD_CAST
|
||||
"http://exslt.org/common",
|
||||
BAD_CAST "exsl");
|
||||
xmlXPathNodeSetAddUnique(ret->nodesetval,
|
||||
cur);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XPATH_NUMBER:
|
||||
if (container != NULL) {
|
||||
xmlChar *val =
|
||||
xmlXPathCastNumberToString(subResult->
|
||||
floatval);
|
||||
xmlNodePtr cur =
|
||||
xmlNewChild((xmlNodePtr) container, NULL,
|
||||
BAD_CAST "number", val);
|
||||
if (val != NULL)
|
||||
xmlFree(val);
|
||||
|
||||
if (cur != NULL) {
|
||||
cur->ns =
|
||||
xmlNewNs(cur,
|
||||
BAD_CAST
|
||||
"http://exslt.org/common",
|
||||
BAD_CAST "exsl");
|
||||
xmlXPathNodeSetAddUnique(ret->nodesetval,
|
||||
cur);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XPATH_STRING:
|
||||
if (container != NULL) {
|
||||
xmlNodePtr cur =
|
||||
xmlNewChild((xmlNodePtr) container, NULL,
|
||||
BAD_CAST "string",
|
||||
subResult->stringval);
|
||||
if (cur != NULL) {
|
||||
cur->ns =
|
||||
xmlNewNs(cur,
|
||||
BAD_CAST
|
||||
"http://exslt.org/common",
|
||||
BAD_CAST "exsl");
|
||||
xmlXPathNodeSetAddUnique(ret->nodesetval,
|
||||
cur);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
xmlXPathFreeObject(subResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
ctxt->context->doc = oldDoc;
|
||||
ctxt->context->node = oldNode;
|
||||
ctxt->context->contextSize = oldContextSize;
|
||||
ctxt->context->proximityPosition = oldProximityPosition;
|
||||
|
||||
|
||||
cleanup:
|
||||
/* restore the xpath context */
|
||||
if (comp != NULL)
|
||||
xmlXPathFreeCompExpr(comp);
|
||||
if (nodeset != NULL)
|
||||
xmlXPathFreeNodeSet(nodeset);
|
||||
if (str != NULL)
|
||||
xmlFree(str);
|
||||
valuePush(ctxt, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* exsltDynRegister:
|
||||
*
|
||||
* Registers the EXSLT - Dynamic module
|
||||
*/
|
||||
|
||||
void
|
||||
exsltDynRegister (void) {
|
||||
xsltRegisterExtModuleFunction ((const xmlChar *) "evaluate",
|
||||
EXSLT_DYNAMIC_NAMESPACE,
|
||||
exsltDynEvaluateFunction);
|
||||
xsltRegisterExtModuleFunction ((const xmlChar *) "map",
|
||||
EXSLT_DYNAMIC_NAMESPACE,
|
||||
exsltDynMapFunction);
|
||||
|
||||
}
|
||||
/*
|
||||
* dynamic.c: Implementation of the EXSLT -- Dynamic module
|
||||
*
|
||||
* References:
|
||||
* http://www.exslt.org/dyn/dyn.html
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Authors:
|
||||
* Mark Vakoc <mark_vakoc@jdedwards.com>
|
||||
* Thomas Broyer <tbroyer@ltgt.net>
|
||||
*
|
||||
* TODO:
|
||||
* elements:
|
||||
* functions:
|
||||
* min
|
||||
* max
|
||||
* sum
|
||||
* map
|
||||
* closure
|
||||
*/
|
||||
|
||||
#define IN_LIBEXSLT
|
||||
#include "libexslt/libexslt.h"
|
||||
|
||||
#if defined(WIN32) && !defined (__CYGWIN__) && (!__MINGW32__)
|
||||
#include <win32config.h>
|
||||
#else
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
|
||||
#include <libxslt/xsltconfig.h>
|
||||
#include <libxslt/xsltutils.h>
|
||||
#include <libxslt/xsltInternals.h>
|
||||
#include <libxslt/extensions.h>
|
||||
|
||||
#include "exslt.h"
|
||||
|
||||
/**
|
||||
* exsltDynEvaluateFunction:
|
||||
* @ctxt: an XPath parser context
|
||||
* @nargs: the number of arguments
|
||||
*
|
||||
* Evaluates the string as an XPath expression and returns the result
|
||||
* value, which may be a boolean, number, string, node set, result tree
|
||||
* fragment or external object.
|
||||
*/
|
||||
|
||||
static void
|
||||
exsltDynEvaluateFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
||||
xmlChar *str = NULL;
|
||||
xmlXPathObjectPtr ret = NULL;
|
||||
|
||||
if (ctxt == NULL)
|
||||
return;
|
||||
if (nargs != 1) {
|
||||
xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
|
||||
xsltGenericError(xsltGenericErrorContext,
|
||||
"dyn:evalute() : invalid number of args %d\n", nargs);
|
||||
ctxt->error = XPATH_INVALID_ARITY;
|
||||
return;
|
||||
}
|
||||
str = xmlXPathPopString(ctxt);
|
||||
/* return an empty node-set if an empty string is passed in */
|
||||
if (!str||!xmlStrlen(str)) {
|
||||
if (str) xmlFree(str);
|
||||
valuePush(ctxt,xmlXPathNewNodeSet(NULL));
|
||||
return;
|
||||
}
|
||||
ret = xmlXPathEval(str,ctxt->context);
|
||||
if (ret)
|
||||
valuePush(ctxt,ret);
|
||||
else {
|
||||
xsltGenericError(xsltGenericErrorContext,
|
||||
"dyn:evaluate() : unable to evaluate expression '%s'\n",str);
|
||||
valuePush(ctxt,xmlXPathNewNodeSet(NULL));
|
||||
}
|
||||
xmlFree(str);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* exsltDynMapFunction:
|
||||
* @ctxt: an XPath parser context
|
||||
* @nargs: the number of arguments
|
||||
*
|
||||
* Evaluates the string as an XPath expression and returns the result
|
||||
* value, which may be a boolean, number, string, node set, result tree
|
||||
* fragment or external object.
|
||||
*/
|
||||
|
||||
static void
|
||||
exsltDynMapFunction(xmlXPathParserContextPtr ctxt, int nargs)
|
||||
{
|
||||
xmlChar *str = NULL;
|
||||
xmlNodeSetPtr nodeset = NULL;
|
||||
xmlXPathCompExprPtr comp = NULL;
|
||||
xmlXPathObjectPtr ret = NULL;
|
||||
xmlDocPtr oldDoc, container;
|
||||
xmlNodePtr oldNode;
|
||||
int oldContextSize;
|
||||
int oldProximityPosition;
|
||||
int i, j;
|
||||
|
||||
|
||||
if (nargs != 2) {
|
||||
xmlXPathSetArityError(ctxt);
|
||||
return;
|
||||
}
|
||||
str = xmlXPathPopString(ctxt);
|
||||
if (xmlXPathCheckError(ctxt)) {
|
||||
xmlXPathSetTypeError(ctxt);
|
||||
return;
|
||||
}
|
||||
|
||||
nodeset = xmlXPathPopNodeSet(ctxt);
|
||||
if (xmlXPathCheckError(ctxt)) {
|
||||
xmlXPathSetTypeError(ctxt);
|
||||
return;
|
||||
}
|
||||
if (str == NULL || !xmlStrlen(str) || !(comp = xmlXPathCompile(str))) {
|
||||
if (nodeset != NULL)
|
||||
xmlXPathFreeNodeSet(nodeset);
|
||||
if (str != NULL)
|
||||
xmlFree(str);
|
||||
valuePush(ctxt, xmlXPathNewNodeSet(NULL));
|
||||
return;
|
||||
}
|
||||
|
||||
ret = xmlXPathNewNodeSet(NULL);
|
||||
if (ret == NULL) {
|
||||
xsltGenericError(xsltGenericErrorContext,
|
||||
"exsltDynMapFunctoin: ret == NULL\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
oldDoc = ctxt->context->doc;
|
||||
oldNode = ctxt->context->node;
|
||||
oldContextSize = ctxt->context->contextSize;
|
||||
oldProximityPosition = ctxt->context->proximityPosition;
|
||||
|
||||
/**
|
||||
* since we really don't know we're going to be adding node(s)
|
||||
* down the road we create the RVT regardless
|
||||
*/
|
||||
container = xsltCreateRVT(xsltXPathGetTransformContext(ctxt));
|
||||
if (container != NULL)
|
||||
xsltRegisterLocalRVT(xsltXPathGetTransformContext(ctxt), container);
|
||||
|
||||
if (nodeset && nodeset->nodeNr > 0) {
|
||||
xmlXPathNodeSetSort(nodeset);
|
||||
ctxt->context->contextSize = nodeset->nodeNr;
|
||||
ctxt->context->proximityPosition = 0;
|
||||
for (i = 0; i < nodeset->nodeNr; i++) {
|
||||
xmlXPathObjectPtr subResult = NULL;
|
||||
|
||||
ctxt->context->proximityPosition++;
|
||||
ctxt->context->node = nodeset->nodeTab[i];
|
||||
ctxt->context->doc = nodeset->nodeTab[i]->doc;
|
||||
|
||||
subResult = xmlXPathCompiledEval(comp, ctxt->context);
|
||||
if (subResult != NULL) {
|
||||
switch (subResult->type) {
|
||||
case XPATH_NODESET:
|
||||
if (subResult->nodesetval != NULL)
|
||||
for (j = 0; j < subResult->nodesetval->nodeNr;
|
||||
j++)
|
||||
xmlXPathNodeSetAdd(ret->nodesetval,
|
||||
subResult->nodesetval->
|
||||
nodeTab[j]);
|
||||
break;
|
||||
case XPATH_BOOLEAN:
|
||||
if (container != NULL) {
|
||||
xmlNodePtr cur =
|
||||
xmlNewChild((xmlNodePtr) container, NULL,
|
||||
BAD_CAST "boolean",
|
||||
BAD_CAST (subResult->
|
||||
boolval ? "true" : ""));
|
||||
if (cur != NULL) {
|
||||
cur->ns =
|
||||
xmlNewNs(cur,
|
||||
BAD_CAST
|
||||
"http://exslt.org/common",
|
||||
BAD_CAST "exsl");
|
||||
xmlXPathNodeSetAddUnique(ret->nodesetval,
|
||||
cur);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XPATH_NUMBER:
|
||||
if (container != NULL) {
|
||||
xmlChar *val =
|
||||
xmlXPathCastNumberToString(subResult->
|
||||
floatval);
|
||||
xmlNodePtr cur =
|
||||
xmlNewChild((xmlNodePtr) container, NULL,
|
||||
BAD_CAST "number", val);
|
||||
if (val != NULL)
|
||||
xmlFree(val);
|
||||
|
||||
if (cur != NULL) {
|
||||
cur->ns =
|
||||
xmlNewNs(cur,
|
||||
BAD_CAST
|
||||
"http://exslt.org/common",
|
||||
BAD_CAST "exsl");
|
||||
xmlXPathNodeSetAddUnique(ret->nodesetval,
|
||||
cur);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XPATH_STRING:
|
||||
if (container != NULL) {
|
||||
xmlNodePtr cur =
|
||||
xmlNewChild((xmlNodePtr) container, NULL,
|
||||
BAD_CAST "string",
|
||||
subResult->stringval);
|
||||
if (cur != NULL) {
|
||||
cur->ns =
|
||||
xmlNewNs(cur,
|
||||
BAD_CAST
|
||||
"http://exslt.org/common",
|
||||
BAD_CAST "exsl");
|
||||
xmlXPathNodeSetAddUnique(ret->nodesetval,
|
||||
cur);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
xmlXPathFreeObject(subResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
ctxt->context->doc = oldDoc;
|
||||
ctxt->context->node = oldNode;
|
||||
ctxt->context->contextSize = oldContextSize;
|
||||
ctxt->context->proximityPosition = oldProximityPosition;
|
||||
|
||||
|
||||
cleanup:
|
||||
/* restore the xpath context */
|
||||
if (comp != NULL)
|
||||
xmlXPathFreeCompExpr(comp);
|
||||
if (nodeset != NULL)
|
||||
xmlXPathFreeNodeSet(nodeset);
|
||||
if (str != NULL)
|
||||
xmlFree(str);
|
||||
valuePush(ctxt, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* exsltDynRegister:
|
||||
*
|
||||
* Registers the EXSLT - Dynamic module
|
||||
*/
|
||||
|
||||
void
|
||||
exsltDynRegister (void) {
|
||||
xsltRegisterExtModuleFunction ((const xmlChar *) "evaluate",
|
||||
EXSLT_DYNAMIC_NAMESPACE,
|
||||
exsltDynEvaluateFunction);
|
||||
xsltRegisterExtModuleFunction ((const xmlChar *) "map",
|
||||
EXSLT_DYNAMIC_NAMESPACE,
|
||||
exsltDynMapFunction);
|
||||
|
||||
}
|
||||
|
1409
libexslt/functions.c
1409
libexslt/functions.c
File diff suppressed because it is too large
Load Diff
1051
libexslt/strings.c
1051
libexslt/strings.c
File diff suppressed because it is too large
Load Diff
2262
libxslt/attributes.c
2262
libxslt/attributes.c
File diff suppressed because it is too large
Load Diff
@@ -1,437 +1,439 @@
|
||||
/*
|
||||
* documents.c: Implementation of the documents handling
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* daniel@veillard.com
|
||||
*/
|
||||
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "xsltutils.h"
|
||||
#include "documents.h"
|
||||
#include "transform.h"
|
||||
#include "imports.h"
|
||||
#include "keys.h"
|
||||
#include "security.h"
|
||||
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
#include <libxml/xinclude.h>
|
||||
#endif
|
||||
|
||||
#define WITH_XSLT_DEBUG_DOCUMENTS
|
||||
|
||||
#ifdef WITH_XSLT_DEBUG
|
||||
#define WITH_XSLT_DEBUG_DOCUMENTS
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Hooks for the document loader *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* xsltDocDefaultLoaderFunc:
|
||||
* @URI: the URI of the document to load
|
||||
* @dict: the dictionnary to use when parsing that document
|
||||
* @options: parsing options, a set of xmlParserOption
|
||||
* @ctxt: the context, either a stylesheet or a transformation context
|
||||
* @type: the xsltLoadType indicating the kind of loading required
|
||||
*
|
||||
* Default function to load document not provided by the compilation or
|
||||
* transformation API themselve, for example when an xsl:import,
|
||||
* xsl:include is found at compilation time or when a document()
|
||||
* call is made at runtime.
|
||||
*
|
||||
* Returns the pointer to the document (which will be modified and
|
||||
* freed by the engine later), or NULL in case of error.
|
||||
*/
|
||||
static xmlDocPtr
|
||||
xsltDocDefaultLoaderFunc(const xmlChar * URI, xmlDictPtr dict, int options,
|
||||
void *ctxt ATTRIBUTE_UNUSED,
|
||||
xsltLoadType type ATTRIBUTE_UNUSED)
|
||||
{
|
||||
xmlParserCtxtPtr pctxt;
|
||||
xmlParserInputPtr inputStream;
|
||||
xmlDocPtr doc;
|
||||
|
||||
pctxt = xmlNewParserCtxt();
|
||||
if (pctxt == NULL)
|
||||
return(NULL);
|
||||
if ((dict != NULL) && (pctxt->dict != NULL)) {
|
||||
xmlDictFree(pctxt->dict);
|
||||
pctxt->dict = NULL;
|
||||
}
|
||||
if (dict != NULL) {
|
||||
pctxt->dict = dict;
|
||||
xmlDictReference(pctxt->dict);
|
||||
#ifdef WITH_XSLT_DEBUG
|
||||
xsltGenericDebug(xsltGenericDebugContext,
|
||||
"Reusing dictionary for document\n");
|
||||
#endif
|
||||
}
|
||||
xmlCtxtUseOptions(pctxt, options);
|
||||
inputStream = xmlLoadExternalEntity((const char *) URI, NULL, pctxt);
|
||||
if (inputStream == NULL) {
|
||||
xmlFreeParserCtxt(pctxt);
|
||||
return(NULL);
|
||||
}
|
||||
inputPush(pctxt, inputStream);
|
||||
if (pctxt->directory == NULL)
|
||||
pctxt->directory = xmlParserGetDirectory((const char *) URI);
|
||||
|
||||
xmlParseDocument(pctxt);
|
||||
|
||||
if (pctxt->wellFormed) {
|
||||
doc = pctxt->myDoc;
|
||||
}
|
||||
else {
|
||||
doc = NULL;
|
||||
xmlFreeDoc(pctxt->myDoc);
|
||||
pctxt->myDoc = NULL;
|
||||
}
|
||||
xmlFreeParserCtxt(pctxt);
|
||||
|
||||
return(doc);
|
||||
}
|
||||
|
||||
|
||||
xsltDocLoaderFunc xsltDocDefaultLoader = xsltDocDefaultLoaderFunc;
|
||||
|
||||
/**
|
||||
* xsltSetLoaderFunc:
|
||||
* @f: the new function to handle document loading.
|
||||
*
|
||||
* Set the new function to load document, if NULL it resets it to the
|
||||
* default function.
|
||||
*/
|
||||
|
||||
void
|
||||
xsltSetLoaderFunc(xsltDocLoaderFunc f) {
|
||||
if (f == NULL)
|
||||
xsltDocDefaultLoader = xsltDocDefaultLoaderFunc;
|
||||
else
|
||||
xsltDocDefaultLoader = f;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Module interfaces *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* xsltNewDocument:
|
||||
* @ctxt: an XSLT transformation context (or NULL)
|
||||
* @doc: a parsed XML document
|
||||
*
|
||||
* Register a new document, apply key computations
|
||||
*
|
||||
* Returns a handler to the document
|
||||
*/
|
||||
xsltDocumentPtr
|
||||
xsltNewDocument(xsltTransformContextPtr ctxt, xmlDocPtr doc) {
|
||||
xsltDocumentPtr cur;
|
||||
|
||||
cur = (xsltDocumentPtr) xmlMalloc(sizeof(xsltDocument));
|
||||
if (cur == NULL) {
|
||||
xsltTransformError(ctxt, NULL, (xmlNodePtr) doc,
|
||||
"xsltNewDocument : malloc failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
memset(cur, 0, sizeof(xsltDocument));
|
||||
cur->doc = doc;
|
||||
if (ctxt != NULL) {
|
||||
if (! XSLT_IS_RES_TREE_FRAG(doc)) {
|
||||
cur->next = ctxt->docList;
|
||||
ctxt->docList = cur;
|
||||
}
|
||||
#ifdef XSLT_REFACTORED_KEYCOMP
|
||||
/*
|
||||
* A key with a specific name for a specific document
|
||||
* will only be computed if there's a call to the key()
|
||||
* function using that specific name for that specific
|
||||
* document. I.e. computation of keys will be done in
|
||||
* xsltGetKey() (keys.c) on an on-demand basis.
|
||||
*/
|
||||
#else
|
||||
/*
|
||||
* Old behaviour.
|
||||
*/
|
||||
xsltInitCtxtKeys(ctxt, cur);
|
||||
#endif
|
||||
}
|
||||
return(cur);
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltNewStyleDocument:
|
||||
* @style: an XSLT style sheet
|
||||
* @doc: a parsed XML document
|
||||
*
|
||||
* Register a new document, apply key computations
|
||||
*
|
||||
* Returns a handler to the document
|
||||
*/
|
||||
xsltDocumentPtr
|
||||
xsltNewStyleDocument(xsltStylesheetPtr style, xmlDocPtr doc) {
|
||||
xsltDocumentPtr cur;
|
||||
|
||||
cur = (xsltDocumentPtr) xmlMalloc(sizeof(xsltDocument));
|
||||
if (cur == NULL) {
|
||||
xsltTransformError(NULL, style, (xmlNodePtr) doc,
|
||||
"xsltNewStyleDocument : malloc failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
memset(cur, 0, sizeof(xsltDocument));
|
||||
cur->doc = doc;
|
||||
if (style != NULL) {
|
||||
cur->next = style->docList;
|
||||
style->docList = cur;
|
||||
}
|
||||
return(cur);
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltFreeStyleDocuments:
|
||||
* @style: an XSLT stylesheet (representing a stylesheet-level)
|
||||
*
|
||||
* Frees the node-trees (and xsltDocument structures) of all
|
||||
* stylesheet-modules of the stylesheet-level represented by
|
||||
* the given @style.
|
||||
*/
|
||||
void
|
||||
xsltFreeStyleDocuments(xsltStylesheetPtr style) {
|
||||
xsltDocumentPtr doc, cur;
|
||||
#ifdef XSLT_REFACTORED_XSLT_NSCOMP
|
||||
xsltNsMapPtr nsMap;
|
||||
#endif
|
||||
|
||||
if (style == NULL)
|
||||
return;
|
||||
|
||||
#ifdef XSLT_REFACTORED_XSLT_NSCOMP
|
||||
if (XSLT_HAS_INTERNAL_NSMAP(style))
|
||||
nsMap = XSLT_GET_INTERNAL_NSMAP(style);
|
||||
else
|
||||
nsMap = NULL;
|
||||
#endif
|
||||
|
||||
cur = style->docList;
|
||||
while (cur != NULL) {
|
||||
doc = cur;
|
||||
cur = cur->next;
|
||||
#ifdef XSLT_REFACTORED_XSLT_NSCOMP
|
||||
/*
|
||||
* Restore all changed namespace URIs of ns-decls.
|
||||
*/
|
||||
if (nsMap)
|
||||
xsltRestoreDocumentNamespaces(nsMap, doc->doc);
|
||||
#endif
|
||||
xsltFreeDocumentKeys(doc);
|
||||
if (!doc->main)
|
||||
xmlFreeDoc(doc->doc);
|
||||
xmlFree(doc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltFreeDocuments:
|
||||
* @ctxt: an XSLT transformation context
|
||||
*
|
||||
* Free up all the space used by the loaded documents
|
||||
*/
|
||||
void
|
||||
xsltFreeDocuments(xsltTransformContextPtr ctxt) {
|
||||
xsltDocumentPtr doc, cur;
|
||||
|
||||
cur = ctxt->docList;
|
||||
while (cur != NULL) {
|
||||
doc = cur;
|
||||
cur = cur->next;
|
||||
xsltFreeDocumentKeys(doc);
|
||||
if (!doc->main)
|
||||
xmlFreeDoc(doc->doc);
|
||||
xmlFree(doc);
|
||||
}
|
||||
cur = ctxt->styleList;
|
||||
while (cur != NULL) {
|
||||
doc = cur;
|
||||
cur = cur->next;
|
||||
xsltFreeDocumentKeys(doc);
|
||||
if (!doc->main)
|
||||
xmlFreeDoc(doc->doc);
|
||||
xmlFree(doc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltLoadDocument:
|
||||
* @ctxt: an XSLT transformation context
|
||||
* @URI: the computed URI of the document
|
||||
*
|
||||
* Try to load a document (not a stylesheet)
|
||||
* within the XSLT transformation context
|
||||
*
|
||||
* Returns the new xsltDocumentPtr or NULL in case of error
|
||||
*/
|
||||
xsltDocumentPtr
|
||||
xsltLoadDocument(xsltTransformContextPtr ctxt, const xmlChar *URI) {
|
||||
xsltDocumentPtr ret;
|
||||
xmlDocPtr doc;
|
||||
|
||||
if ((ctxt == NULL) || (URI == NULL))
|
||||
return(NULL);
|
||||
|
||||
/*
|
||||
* Security framework check
|
||||
*/
|
||||
if (ctxt->sec != NULL) {
|
||||
int res;
|
||||
|
||||
res = xsltCheckRead(ctxt->sec, ctxt, URI);
|
||||
if (res == 0) {
|
||||
xsltTransformError(ctxt, NULL, NULL,
|
||||
"xsltLoadDocument: read rights for %s denied\n",
|
||||
URI);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Walk the context list to find the document if preparsed
|
||||
*/
|
||||
ret = ctxt->docList;
|
||||
while (ret != NULL) {
|
||||
if ((ret->doc != NULL) && (ret->doc->URL != NULL) &&
|
||||
(xmlStrEqual(ret->doc->URL, URI)))
|
||||
return(ret);
|
||||
ret = ret->next;
|
||||
}
|
||||
|
||||
doc = xsltDocDefaultLoader(URI, ctxt->dict, ctxt->parserOptions,
|
||||
(void *) ctxt, XSLT_LOAD_DOCUMENT);
|
||||
|
||||
if (doc == NULL)
|
||||
return(NULL);
|
||||
|
||||
if (ctxt->xinclude != 0) {
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
#if LIBXML_VERSION >= 20603
|
||||
xmlXIncludeProcessFlags(doc, ctxt->parserOptions);
|
||||
#else
|
||||
xmlXIncludeProcess(doc);
|
||||
#endif
|
||||
#else
|
||||
xsltTransformError(ctxt, NULL, NULL,
|
||||
"xsltLoadDocument(%s) : XInclude processing not compiled in\n",
|
||||
URI);
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
* Apply white-space stripping if asked for
|
||||
*/
|
||||
if (xsltNeedElemSpaceHandling(ctxt))
|
||||
xsltApplyStripSpaces(ctxt, xmlDocGetRootElement(doc));
|
||||
if (ctxt->debugStatus == XSLT_DEBUG_NONE)
|
||||
xmlXPathOrderDocElems(doc);
|
||||
|
||||
ret = xsltNewDocument(ctxt, doc);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltLoadStyleDocument:
|
||||
* @style: an XSLT style sheet
|
||||
* @URI: the computed URI of the document
|
||||
*
|
||||
* Try to load a stylesheet document within the XSLT transformation context
|
||||
*
|
||||
* Returns the new xsltDocumentPtr or NULL in case of error
|
||||
*/
|
||||
xsltDocumentPtr
|
||||
xsltLoadStyleDocument(xsltStylesheetPtr style, const xmlChar *URI) {
|
||||
xsltDocumentPtr ret;
|
||||
xmlDocPtr doc;
|
||||
xsltSecurityPrefsPtr sec;
|
||||
|
||||
if ((style == NULL) || (URI == NULL))
|
||||
return(NULL);
|
||||
|
||||
/*
|
||||
* Security framework check
|
||||
*/
|
||||
sec = xsltGetDefaultSecurityPrefs();
|
||||
if (sec != NULL) {
|
||||
int res;
|
||||
|
||||
res = xsltCheckRead(sec, NULL, URI);
|
||||
if (res == 0) {
|
||||
xsltTransformError(NULL, NULL, NULL,
|
||||
"xsltLoadStyleDocument: read rights for %s denied\n",
|
||||
URI);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Walk the context list to find the document if preparsed
|
||||
*/
|
||||
ret = style->docList;
|
||||
while (ret != NULL) {
|
||||
if ((ret->doc != NULL) && (ret->doc->URL != NULL) &&
|
||||
(xmlStrEqual(ret->doc->URL, URI)))
|
||||
return(ret);
|
||||
ret = ret->next;
|
||||
}
|
||||
|
||||
doc = xsltDocDefaultLoader(URI, style->dict, XSLT_PARSE_OPTIONS,
|
||||
(void *) style, XSLT_LOAD_STYLESHEET);
|
||||
if (doc == NULL)
|
||||
return(NULL);
|
||||
|
||||
ret = xsltNewStyleDocument(style, doc);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltFindDocument:
|
||||
* @ctxt: an XSLT transformation context
|
||||
* @doc: a parsed XML document
|
||||
*
|
||||
* Try to find a document within the XSLT transformation context
|
||||
*
|
||||
* Returns the desired xsltDocumentPtr or NULL in case of error
|
||||
*/
|
||||
xsltDocumentPtr
|
||||
xsltFindDocument (xsltTransformContextPtr ctxt, xmlDocPtr doc) {
|
||||
xsltDocumentPtr ret;
|
||||
|
||||
if ((ctxt == NULL) || (doc == NULL))
|
||||
return(NULL);
|
||||
|
||||
/*
|
||||
* Walk the context list to find the document
|
||||
*/
|
||||
ret = ctxt->docList;
|
||||
while (ret != NULL) {
|
||||
if (ret->doc == doc)
|
||||
return(ret);
|
||||
ret = ret->next;
|
||||
}
|
||||
if (doc == ctxt->style->doc)
|
||||
return(ctxt->document);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* documents.c: Implementation of the documents handling
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* daniel@veillard.com
|
||||
*/
|
||||
|
||||
#define IN_LIBXSLT
|
||||
#include "libxslt.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <libxml/xmlmemory.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/hash.h>
|
||||
#include <libxml/parser.h>
|
||||
#include <libxml/parserInternals.h>
|
||||
#include "xslt.h"
|
||||
#include "xsltInternals.h"
|
||||
#include "xsltutils.h"
|
||||
#include "documents.h"
|
||||
#include "transform.h"
|
||||
#include "imports.h"
|
||||
#include "keys.h"
|
||||
#include "security.h"
|
||||
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
#include <libxml/xinclude.h>
|
||||
#endif
|
||||
|
||||
#define WITH_XSLT_DEBUG_DOCUMENTS
|
||||
|
||||
#ifdef WITH_XSLT_DEBUG
|
||||
#define WITH_XSLT_DEBUG_DOCUMENTS
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Hooks for the document loader *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* xsltDocDefaultLoaderFunc:
|
||||
* @URI: the URI of the document to load
|
||||
* @dict: the dictionnary to use when parsing that document
|
||||
* @options: parsing options, a set of xmlParserOption
|
||||
* @ctxt: the context, either a stylesheet or a transformation context
|
||||
* @type: the xsltLoadType indicating the kind of loading required
|
||||
*
|
||||
* Default function to load document not provided by the compilation or
|
||||
* transformation API themselve, for example when an xsl:import,
|
||||
* xsl:include is found at compilation time or when a document()
|
||||
* call is made at runtime.
|
||||
*
|
||||
* Returns the pointer to the document (which will be modified and
|
||||
* freed by the engine later), or NULL in case of error.
|
||||
*/
|
||||
static xmlDocPtr
|
||||
xsltDocDefaultLoaderFunc(const xmlChar * URI, xmlDictPtr dict, int options,
|
||||
void *ctxt ATTRIBUTE_UNUSED,
|
||||
xsltLoadType type ATTRIBUTE_UNUSED)
|
||||
{
|
||||
xmlParserCtxtPtr pctxt;
|
||||
xmlParserInputPtr inputStream;
|
||||
xmlDocPtr doc;
|
||||
|
||||
pctxt = xmlNewParserCtxt();
|
||||
if (pctxt == NULL)
|
||||
return(NULL);
|
||||
if ((dict != NULL) && (pctxt->dict != NULL)) {
|
||||
xmlDictFree(pctxt->dict);
|
||||
pctxt->dict = NULL;
|
||||
}
|
||||
if (dict != NULL) {
|
||||
pctxt->dict = dict;
|
||||
xmlDictReference(pctxt->dict);
|
||||
#ifdef WITH_XSLT_DEBUG
|
||||
xsltGenericDebug(xsltGenericDebugContext,
|
||||
"Reusing dictionary for document\n");
|
||||
#endif
|
||||
}
|
||||
xmlCtxtUseOptions(pctxt, options);
|
||||
inputStream = xmlLoadExternalEntity((const char *) URI, NULL, pctxt);
|
||||
if (inputStream == NULL) {
|
||||
xmlFreeParserCtxt(pctxt);
|
||||
return(NULL);
|
||||
}
|
||||
inputPush(pctxt, inputStream);
|
||||
if (pctxt->directory == NULL)
|
||||
pctxt->directory = xmlParserGetDirectory((const char *) URI);
|
||||
|
||||
xmlParseDocument(pctxt);
|
||||
|
||||
if (pctxt->wellFormed) {
|
||||
doc = pctxt->myDoc;
|
||||
}
|
||||
else {
|
||||
doc = NULL;
|
||||
xmlFreeDoc(pctxt->myDoc);
|
||||
pctxt->myDoc = NULL;
|
||||
}
|
||||
xmlFreeParserCtxt(pctxt);
|
||||
|
||||
return(doc);
|
||||
}
|
||||
|
||||
|
||||
xsltDocLoaderFunc xsltDocDefaultLoader = xsltDocDefaultLoaderFunc;
|
||||
|
||||
/**
|
||||
* xsltSetLoaderFunc:
|
||||
* @f: the new function to handle document loading.
|
||||
*
|
||||
* Set the new function to load document, if NULL it resets it to the
|
||||
* default function.
|
||||
*/
|
||||
|
||||
void
|
||||
xsltSetLoaderFunc(xsltDocLoaderFunc f) {
|
||||
if (f == NULL)
|
||||
xsltDocDefaultLoader = xsltDocDefaultLoaderFunc;
|
||||
else
|
||||
xsltDocDefaultLoader = f;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Module interfaces *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
/**
|
||||
* xsltNewDocument:
|
||||
* @ctxt: an XSLT transformation context (or NULL)
|
||||
* @doc: a parsed XML document
|
||||
*
|
||||
* Register a new document, apply key computations
|
||||
*
|
||||
* Returns a handler to the document
|
||||
*/
|
||||
xsltDocumentPtr
|
||||
xsltNewDocument(xsltTransformContextPtr ctxt, xmlDocPtr doc) {
|
||||
xsltDocumentPtr cur;
|
||||
|
||||
cur = (xsltDocumentPtr) xmlMalloc(sizeof(xsltDocument));
|
||||
if (cur == NULL) {
|
||||
xsltTransformError(ctxt, NULL, (xmlNodePtr) doc,
|
||||
"xsltNewDocument : malloc failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
memset(cur, 0, sizeof(xsltDocument));
|
||||
cur->doc = doc;
|
||||
if (ctxt != NULL) {
|
||||
if (! XSLT_IS_RES_TREE_FRAG(doc)) {
|
||||
cur->next = ctxt->docList;
|
||||
ctxt->docList = cur;
|
||||
}
|
||||
#ifdef XSLT_REFACTORED_KEYCOMP
|
||||
/*
|
||||
* A key with a specific name for a specific document
|
||||
* will only be computed if there's a call to the key()
|
||||
* function using that specific name for that specific
|
||||
* document. I.e. computation of keys will be done in
|
||||
* xsltGetKey() (keys.c) on an on-demand basis.
|
||||
*/
|
||||
#else
|
||||
/*
|
||||
* Old behaviour.
|
||||
*/
|
||||
xsltInitCtxtKeys(ctxt, cur);
|
||||
#endif
|
||||
}
|
||||
return(cur);
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltNewStyleDocument:
|
||||
* @style: an XSLT style sheet
|
||||
* @doc: a parsed XML document
|
||||
*
|
||||
* Register a new document, apply key computations
|
||||
*
|
||||
* Returns a handler to the document
|
||||
*/
|
||||
xsltDocumentPtr
|
||||
xsltNewStyleDocument(xsltStylesheetPtr style, xmlDocPtr doc) {
|
||||
xsltDocumentPtr cur;
|
||||
|
||||
cur = (xsltDocumentPtr) xmlMalloc(sizeof(xsltDocument));
|
||||
if (cur == NULL) {
|
||||
xsltTransformError(NULL, style, (xmlNodePtr) doc,
|
||||
"xsltNewStyleDocument : malloc failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
memset(cur, 0, sizeof(xsltDocument));
|
||||
cur->doc = doc;
|
||||
if (style != NULL) {
|
||||
cur->next = style->docList;
|
||||
style->docList = cur;
|
||||
}
|
||||
return(cur);
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltFreeStyleDocuments:
|
||||
* @style: an XSLT stylesheet (representing a stylesheet-level)
|
||||
*
|
||||
* Frees the node-trees (and xsltDocument structures) of all
|
||||
* stylesheet-modules of the stylesheet-level represented by
|
||||
* the given @style.
|
||||
*/
|
||||
void
|
||||
xsltFreeStyleDocuments(xsltStylesheetPtr style) {
|
||||
xsltDocumentPtr doc, cur;
|
||||
#ifdef XSLT_REFACTORED_XSLT_NSCOMP
|
||||
xsltNsMapPtr nsMap;
|
||||
#endif
|
||||
|
||||
if (style == NULL)
|
||||
return;
|
||||
|
||||
#ifdef XSLT_REFACTORED_XSLT_NSCOMP
|
||||
if (XSLT_HAS_INTERNAL_NSMAP(style))
|
||||
nsMap = XSLT_GET_INTERNAL_NSMAP(style);
|
||||
else
|
||||
nsMap = NULL;
|
||||
#endif
|
||||
|
||||
cur = style->docList;
|
||||
while (cur != NULL) {
|
||||
doc = cur;
|
||||
cur = cur->next;
|
||||
#ifdef XSLT_REFACTORED_XSLT_NSCOMP
|
||||
/*
|
||||
* Restore all changed namespace URIs of ns-decls.
|
||||
*/
|
||||
if (nsMap)
|
||||
xsltRestoreDocumentNamespaces(nsMap, doc->doc);
|
||||
#endif
|
||||
xsltFreeDocumentKeys(doc);
|
||||
if (!doc->main)
|
||||
xmlFreeDoc(doc->doc);
|
||||
xmlFree(doc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltFreeDocuments:
|
||||
* @ctxt: an XSLT transformation context
|
||||
*
|
||||
* Free up all the space used by the loaded documents
|
||||
*/
|
||||
void
|
||||
xsltFreeDocuments(xsltTransformContextPtr ctxt) {
|
||||
xsltDocumentPtr doc, cur;
|
||||
|
||||
cur = ctxt->docList;
|
||||
while (cur != NULL) {
|
||||
doc = cur;
|
||||
cur = cur->next;
|
||||
xsltFreeDocumentKeys(doc);
|
||||
if (!doc->main)
|
||||
xmlFreeDoc(doc->doc);
|
||||
xmlFree(doc);
|
||||
}
|
||||
cur = ctxt->styleList;
|
||||
while (cur != NULL) {
|
||||
doc = cur;
|
||||
cur = cur->next;
|
||||
xsltFreeDocumentKeys(doc);
|
||||
if (!doc->main)
|
||||
xmlFreeDoc(doc->doc);
|
||||
xmlFree(doc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltLoadDocument:
|
||||
* @ctxt: an XSLT transformation context
|
||||
* @URI: the computed URI of the document
|
||||
*
|
||||
* Try to load a document (not a stylesheet)
|
||||
* within the XSLT transformation context
|
||||
*
|
||||
* Returns the new xsltDocumentPtr or NULL in case of error
|
||||
*/
|
||||
xsltDocumentPtr
|
||||
xsltLoadDocument(xsltTransformContextPtr ctxt, const xmlChar *URI) {
|
||||
xsltDocumentPtr ret;
|
||||
xmlDocPtr doc;
|
||||
|
||||
if ((ctxt == NULL) || (URI == NULL))
|
||||
return(NULL);
|
||||
|
||||
/*
|
||||
* Security framework check
|
||||
*/
|
||||
if (ctxt->sec != NULL) {
|
||||
int res;
|
||||
|
||||
res = xsltCheckRead(ctxt->sec, ctxt, URI);
|
||||
if (res == 0) {
|
||||
xsltTransformError(ctxt, NULL, NULL,
|
||||
"xsltLoadDocument: read rights for %s denied\n",
|
||||
URI);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Walk the context list to find the document if preparsed
|
||||
*/
|
||||
ret = ctxt->docList;
|
||||
while (ret != NULL) {
|
||||
if ((ret->doc != NULL) && (ret->doc->URL != NULL) &&
|
||||
(xmlStrEqual(ret->doc->URL, URI)))
|
||||
return(ret);
|
||||
ret = ret->next;
|
||||
}
|
||||
|
||||
doc = xsltDocDefaultLoader(URI, ctxt->dict, ctxt->parserOptions,
|
||||
(void *) ctxt, XSLT_LOAD_DOCUMENT);
|
||||
|
||||
if (doc == NULL)
|
||||
return(NULL);
|
||||
|
||||
if (ctxt->xinclude != 0) {
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
#if LIBXML_VERSION >= 20603
|
||||
xmlXIncludeProcessFlags(doc, ctxt->parserOptions);
|
||||
#else
|
||||
xmlXIncludeProcess(doc);
|
||||
#endif
|
||||
#else
|
||||
xsltTransformError(ctxt, NULL, NULL,
|
||||
"xsltLoadDocument(%s) : XInclude processing not compiled in\n",
|
||||
URI);
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
* Apply white-space stripping if asked for
|
||||
*/
|
||||
if (xsltNeedElemSpaceHandling(ctxt))
|
||||
xsltApplyStripSpaces(ctxt, xmlDocGetRootElement(doc));
|
||||
if (ctxt->debugStatus == XSLT_DEBUG_NONE)
|
||||
xmlXPathOrderDocElems(doc);
|
||||
|
||||
ret = xsltNewDocument(ctxt, doc);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltLoadStyleDocument:
|
||||
* @style: an XSLT style sheet
|
||||
* @URI: the computed URI of the document
|
||||
*
|
||||
* Try to load a stylesheet document within the XSLT transformation context
|
||||
*
|
||||
* Returns the new xsltDocumentPtr or NULL in case of error
|
||||
*/
|
||||
xsltDocumentPtr
|
||||
xsltLoadStyleDocument(xsltStylesheetPtr style, const xmlChar *URI) {
|
||||
xsltDocumentPtr ret;
|
||||
xmlDocPtr doc;
|
||||
xsltSecurityPrefsPtr sec;
|
||||
|
||||
if ((style == NULL) || (URI == NULL))
|
||||
return(NULL);
|
||||
|
||||
/*
|
||||
* Security framework check
|
||||
*/
|
||||
sec = xsltGetDefaultSecurityPrefs();
|
||||
if (sec != NULL) {
|
||||
int res;
|
||||
|
||||
res = xsltCheckRead(sec, NULL, URI);
|
||||
if (res == 0) {
|
||||
xsltTransformError(NULL, NULL, NULL,
|
||||
"xsltLoadStyleDocument: read rights for %s denied\n",
|
||||
URI);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Walk the context list to find the document if preparsed
|
||||
*/
|
||||
ret = style->docList;
|
||||
while (ret != NULL) {
|
||||
if ((ret->doc != NULL) && (ret->doc->URL != NULL) &&
|
||||
(xmlStrEqual(ret->doc->URL, URI)))
|
||||
return(ret);
|
||||
ret = ret->next;
|
||||
}
|
||||
|
||||
doc = xsltDocDefaultLoader(URI, style->dict, XSLT_PARSE_OPTIONS,
|
||||
(void *) style, XSLT_LOAD_STYLESHEET);
|
||||
if (doc == NULL)
|
||||
return(NULL);
|
||||
|
||||
ret = xsltNewStyleDocument(style, doc);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xsltFindDocument:
|
||||
* @ctxt: an XSLT transformation context
|
||||
* @doc: a parsed XML document
|
||||
*
|
||||
* Try to find a document within the XSLT transformation context.
|
||||
* This will not find document infos for temporary
|
||||
* Result Tree Fragments.
|
||||
*
|
||||
* Returns the desired xsltDocumentPtr or NULL in case of error
|
||||
*/
|
||||
xsltDocumentPtr
|
||||
xsltFindDocument (xsltTransformContextPtr ctxt, xmlDocPtr doc) {
|
||||
xsltDocumentPtr ret;
|
||||
|
||||
if ((ctxt == NULL) || (doc == NULL))
|
||||
return(NULL);
|
||||
|
||||
/*
|
||||
* Walk the context list to find the document
|
||||
*/
|
||||
ret = ctxt->docList;
|
||||
while (ret != NULL) {
|
||||
if (ret->doc == doc)
|
||||
return(ret);
|
||||
ret = ret->next;
|
||||
}
|
||||
if (doc == ctxt->style->doc)
|
||||
return(ctxt->document);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
1888
libxslt/functions.c
1888
libxslt/functions.c
File diff suppressed because it is too large
Load Diff
1633
libxslt/keys.c
1633
libxslt/keys.c
File diff suppressed because it is too large
Load Diff
1686
libxslt/namespaces.c
1686
libxslt/namespaces.c
File diff suppressed because it is too large
Load Diff
5169
libxslt/pattern.c
5169
libxslt/pattern.c
File diff suppressed because it is too large
Load Diff
4737
libxslt/preproc.c
4737
libxslt/preproc.c
File diff suppressed because it is too large
Load Diff
1638
libxslt/templates.c
1638
libxslt/templates.c
File diff suppressed because it is too large
Load Diff
@@ -1,77 +1,77 @@
|
||||
/*
|
||||
* Summary: interface for the template processing
|
||||
* Description: This set of routine encapsulates XPath calls
|
||||
* and Attribute Value Templates evaluation.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_XSLT_TEMPLATES_H__
|
||||
#define __XML_XSLT_TEMPLATES_H__
|
||||
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
#include "xsltexports.h"
|
||||
#include "xsltInternals.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltEvalXPathPredicate (xsltTransformContextPtr ctxt,
|
||||
xmlXPathCompExprPtr comp,
|
||||
xmlNsPtr *nsList,
|
||||
int nsNr);
|
||||
XSLTPUBFUN xmlChar * XSLTCALL
|
||||
xsltEvalTemplateString (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr node,
|
||||
xmlNodePtr parent);
|
||||
XSLTPUBFUN xmlChar * XSLTCALL
|
||||
xsltEvalAttrValueTemplate (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr node,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns);
|
||||
XSLTPUBFUN const xmlChar * XSLTCALL
|
||||
xsltEvalStaticAttrValueTemplate (xsltStylesheetPtr style,
|
||||
xmlNodePtr node,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns,
|
||||
int *found);
|
||||
|
||||
/* TODO: this is obviously broken ... the namespaces should be passed too ! */
|
||||
XSLTPUBFUN xmlChar * XSLTCALL
|
||||
xsltEvalXPathString (xsltTransformContextPtr ctxt,
|
||||
xmlXPathCompExprPtr comp);
|
||||
XSLTPUBFUN xmlChar * XSLTCALL
|
||||
xsltEvalXPathStringNs (xsltTransformContextPtr ctxt,
|
||||
xmlXPathCompExprPtr comp,
|
||||
int nsNr,
|
||||
xmlNsPtr *nsList);
|
||||
|
||||
XSLTPUBFUN xmlNodePtr * XSLTCALL
|
||||
xsltTemplateProcess (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr node);
|
||||
XSLTPUBFUN xmlAttrPtr XSLTCALL
|
||||
xsltAttrListTemplateProcess (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr target,
|
||||
xmlAttrPtr cur);
|
||||
XSLTPUBFUN xmlAttrPtr XSLTCALL
|
||||
xsltAttrTemplateProcess (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr target,
|
||||
xmlAttrPtr attr);
|
||||
XSLTPUBFUN xmlChar * XSLTCALL
|
||||
xsltAttrTemplateValueProcess (xsltTransformContextPtr ctxt,
|
||||
const xmlChar* attr);
|
||||
XSLTPUBFUN xmlChar * XSLTCALL
|
||||
xsltAttrTemplateValueProcessNode(xsltTransformContextPtr ctxt,
|
||||
const xmlChar* str,
|
||||
xmlNodePtr node);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_XSLT_TEMPLATES_H__ */
|
||||
|
||||
/*
|
||||
* Summary: interface for the template processing
|
||||
* Description: This set of routine encapsulates XPath calls
|
||||
* and Attribute Value Templates evaluation.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_XSLT_TEMPLATES_H__
|
||||
#define __XML_XSLT_TEMPLATES_H__
|
||||
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/xpathInternals.h>
|
||||
#include "xsltexports.h"
|
||||
#include "xsltInternals.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltEvalXPathPredicate (xsltTransformContextPtr ctxt,
|
||||
xmlXPathCompExprPtr comp,
|
||||
xmlNsPtr *nsList,
|
||||
int nsNr);
|
||||
XSLTPUBFUN xmlChar * XSLTCALL
|
||||
xsltEvalTemplateString (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr contextNode,
|
||||
xmlNodePtr inst);
|
||||
XSLTPUBFUN xmlChar * XSLTCALL
|
||||
xsltEvalAttrValueTemplate (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr node,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns);
|
||||
XSLTPUBFUN const xmlChar * XSLTCALL
|
||||
xsltEvalStaticAttrValueTemplate (xsltStylesheetPtr style,
|
||||
xmlNodePtr node,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns,
|
||||
int *found);
|
||||
|
||||
/* TODO: this is obviously broken ... the namespaces should be passed too ! */
|
||||
XSLTPUBFUN xmlChar * XSLTCALL
|
||||
xsltEvalXPathString (xsltTransformContextPtr ctxt,
|
||||
xmlXPathCompExprPtr comp);
|
||||
XSLTPUBFUN xmlChar * XSLTCALL
|
||||
xsltEvalXPathStringNs (xsltTransformContextPtr ctxt,
|
||||
xmlXPathCompExprPtr comp,
|
||||
int nsNr,
|
||||
xmlNsPtr *nsList);
|
||||
|
||||
XSLTPUBFUN xmlNodePtr * XSLTCALL
|
||||
xsltTemplateProcess (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr node);
|
||||
XSLTPUBFUN xmlAttrPtr XSLTCALL
|
||||
xsltAttrListTemplateProcess (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr target,
|
||||
xmlAttrPtr cur);
|
||||
XSLTPUBFUN xmlAttrPtr XSLTCALL
|
||||
xsltAttrTemplateProcess (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr target,
|
||||
xmlAttrPtr attr);
|
||||
XSLTPUBFUN xmlChar * XSLTCALL
|
||||
xsltAttrTemplateValueProcess (xsltTransformContextPtr ctxt,
|
||||
const xmlChar* attr);
|
||||
XSLTPUBFUN xmlChar * XSLTCALL
|
||||
xsltAttrTemplateValueProcessNode(xsltTransformContextPtr ctxt,
|
||||
const xmlChar* str,
|
||||
xmlNodePtr node);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_XSLT_TEMPLATES_H__ */
|
||||
|
||||
|
11958
libxslt/transform.c
11958
libxslt/transform.c
File diff suppressed because it is too large
Load Diff
4046
libxslt/variables.c
4046
libxslt/variables.c
File diff suppressed because it is too large
Load Diff
13592
libxslt/xslt.c
13592
libxslt/xslt.c
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
4485
libxslt/xsltutils.c
4485
libxslt/xsltutils.c
File diff suppressed because it is too large
Load Diff
@@ -1,307 +1,309 @@
|
||||
/*
|
||||
* Summary: set of utilities for the XSLT engine
|
||||
* Description: interfaces for the utilities module of the XSLT engine.
|
||||
* things like message handling, profiling, and other
|
||||
* generally useful routines.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_XSLTUTILS_H__
|
||||
#define __XML_XSLTUTILS_H__
|
||||
|
||||
#include <libxslt/xsltconfig.h>
|
||||
#ifdef HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/dict.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include "xsltexports.h"
|
||||
#include "xsltInternals.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* XSLT_TODO:
|
||||
*
|
||||
* Macro to flag unimplemented blocks.
|
||||
*/
|
||||
#define XSLT_TODO \
|
||||
xsltGenericError(xsltGenericErrorContext, \
|
||||
"Unimplemented block at %s:%d\n", \
|
||||
__FILE__, __LINE__);
|
||||
|
||||
/**
|
||||
* XSLT_STRANGE:
|
||||
*
|
||||
* Macro to flag that a problem was detected internally.
|
||||
*/
|
||||
#define XSLT_STRANGE \
|
||||
xsltGenericError(xsltGenericErrorContext, \
|
||||
"Internal error at %s:%d\n", \
|
||||
__FILE__, __LINE__);
|
||||
|
||||
/**
|
||||
* IS_XSLT_ELEM:
|
||||
*
|
||||
* Checks that the element pertains to XSLT namespace.
|
||||
*/
|
||||
#define IS_XSLT_ELEM(n) \
|
||||
(((n) != NULL) && ((n)->ns != NULL) && \
|
||||
(xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))
|
||||
|
||||
/**
|
||||
* IS_XSLT_NAME:
|
||||
*
|
||||
* Checks the value of an element in XSLT namespace.
|
||||
*/
|
||||
#define IS_XSLT_NAME(n, val) \
|
||||
(xmlStrEqual((n)->name, (const xmlChar *) (val)))
|
||||
|
||||
/**
|
||||
* IS_XSLT_REAL_NODE:
|
||||
*
|
||||
* Check that a node is a 'real' one: document, element, text or attribute.
|
||||
*/
|
||||
#define IS_XSLT_REAL_NODE(n) \
|
||||
(((n) != NULL) && \
|
||||
(((n)->type == XML_ELEMENT_NODE) || \
|
||||
((n)->type == XML_TEXT_NODE) || \
|
||||
((n)->type == XML_ATTRIBUTE_NODE) || \
|
||||
((n)->type == XML_DOCUMENT_NODE) || \
|
||||
((n)->type == XML_HTML_DOCUMENT_NODE) || \
|
||||
((n)->type == XML_PI_NODE)))
|
||||
|
||||
/*
|
||||
* Our own version of namespaced atributes lookup.
|
||||
*/
|
||||
XSLTPUBFUN xmlChar * XSLTCALL
|
||||
xsltGetNsProp (xmlNodePtr node,
|
||||
const xmlChar *name,
|
||||
const xmlChar *nameSpace);
|
||||
XSLTPUBFUN const xmlChar * XSLTCALL
|
||||
xsltGetCNsProp (xsltStylesheetPtr style,
|
||||
xmlNodePtr node,
|
||||
const xmlChar *name,
|
||||
const xmlChar *nameSpace);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltGetUTF8Char (const unsigned char *utf,
|
||||
int *len);
|
||||
|
||||
/*
|
||||
* XSLT Debug Tracing Tracing Types
|
||||
*/
|
||||
typedef enum {
|
||||
XSLT_TRACE_ALL = -1,
|
||||
XSLT_TRACE_NONE = 0,
|
||||
XSLT_TRACE_COPY_TEXT = 1<<0,
|
||||
XSLT_TRACE_PROCESS_NODE = 1<<1,
|
||||
XSLT_TRACE_APPLY_TEMPLATE = 1<<2,
|
||||
XSLT_TRACE_COPY = 1<<3,
|
||||
XSLT_TRACE_COMMENT = 1<<4,
|
||||
XSLT_TRACE_PI = 1<<5,
|
||||
XSLT_TRACE_COPY_OF = 1<<6,
|
||||
XSLT_TRACE_VALUE_OF = 1<<7,
|
||||
XSLT_TRACE_CALL_TEMPLATE = 1<<8,
|
||||
XSLT_TRACE_APPLY_TEMPLATES = 1<<9,
|
||||
XSLT_TRACE_CHOOSE = 1<<10,
|
||||
XSLT_TRACE_IF = 1<<11,
|
||||
XSLT_TRACE_FOR_EACH = 1<<12,
|
||||
XSLT_TRACE_STRIP_SPACES = 1<<13,
|
||||
XSLT_TRACE_TEMPLATES = 1<<14,
|
||||
XSLT_TRACE_KEYS = 1<<15,
|
||||
XSLT_TRACE_VARIABLES = 1<<16
|
||||
} xsltDebugTraceCodes;
|
||||
|
||||
/**
|
||||
* XSLT_TRACE:
|
||||
*
|
||||
* Control the type of xsl debugtrace messages emitted.
|
||||
*/
|
||||
#define XSLT_TRACE(ctxt,code,call) \
|
||||
if (ctxt->traceCode && (*(ctxt->traceCode) & code)) \
|
||||
call
|
||||
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltDebugSetDefaultTrace(xsltDebugTraceCodes val);
|
||||
XSLTPUBFUN xsltDebugTraceCodes XSLTCALL
|
||||
xsltDebugGetDefaultTrace(void);
|
||||
|
||||
/*
|
||||
* XSLT specific error and debug reporting functions.
|
||||
*/
|
||||
XSLTPUBVAR xmlGenericErrorFunc xsltGenericError;
|
||||
XSLTPUBVAR void *xsltGenericErrorContext;
|
||||
XSLTPUBVAR xmlGenericErrorFunc xsltGenericDebug;
|
||||
XSLTPUBVAR void *xsltGenericDebugContext;
|
||||
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltPrintErrorContext (xsltTransformContextPtr ctxt,
|
||||
xsltStylesheetPtr style,
|
||||
xmlNodePtr node);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltMessage (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr node,
|
||||
xmlNodePtr inst);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSetGenericErrorFunc (void *ctx,
|
||||
xmlGenericErrorFunc handler);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSetGenericDebugFunc (void *ctx,
|
||||
xmlGenericErrorFunc handler);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSetTransformErrorFunc (xsltTransformContextPtr ctxt,
|
||||
void *ctx,
|
||||
xmlGenericErrorFunc handler);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltTransformError (xsltTransformContextPtr ctxt,
|
||||
xsltStylesheetPtr style,
|
||||
xmlNodePtr node,
|
||||
const char *msg,
|
||||
...);
|
||||
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltSetCtxtParseOptions (xsltTransformContextPtr ctxt,
|
||||
int options);
|
||||
/*
|
||||
* Sorting.
|
||||
*/
|
||||
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltDocumentSortFunction (xmlNodeSetPtr list);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSetSortFunc (xsltSortFunc handler);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSetCtxtSortFunc (xsltTransformContextPtr ctxt,
|
||||
xsltSortFunc handler);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltDefaultSortFunction (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr *sorts,
|
||||
int nbsorts);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltDoSortFunction (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr * sorts,
|
||||
int nbsorts);
|
||||
XSLTPUBFUN xmlXPathObjectPtr * XSLTCALL
|
||||
xsltComputeSortResult (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr sort);
|
||||
|
||||
/*
|
||||
* QNames handling.
|
||||
*/
|
||||
|
||||
XSLTPUBFUN const xmlChar * XSLTCALL
|
||||
xsltSplitQName (xmlDictPtr dict,
|
||||
const xmlChar *name,
|
||||
const xmlChar **prefix);
|
||||
XSLTPUBFUN const xmlChar * XSLTCALL
|
||||
xsltGetQNameURI (xmlNodePtr node,
|
||||
xmlChar **name);
|
||||
|
||||
XSLTPUBFUN const xmlChar * XSLTCALL
|
||||
xsltGetQNameURI2 (xsltStylesheetPtr style,
|
||||
xmlNodePtr node,
|
||||
const xmlChar **name);
|
||||
|
||||
/*
|
||||
* Output, reuse libxml I/O buffers.
|
||||
*/
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltSaveResultTo (xmlOutputBufferPtr buf,
|
||||
xmlDocPtr result,
|
||||
xsltStylesheetPtr style);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltSaveResultToFilename (const char *URI,
|
||||
xmlDocPtr result,
|
||||
xsltStylesheetPtr style,
|
||||
int compression);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltSaveResultToFile (FILE *file,
|
||||
xmlDocPtr result,
|
||||
xsltStylesheetPtr style);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltSaveResultToFd (int fd,
|
||||
xmlDocPtr result,
|
||||
xsltStylesheetPtr style);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltSaveResultToString (xmlChar **doc_txt_ptr,
|
||||
int * doc_txt_len,
|
||||
xmlDocPtr result,
|
||||
xsltStylesheetPtr style);
|
||||
|
||||
/*
|
||||
* XPath interface
|
||||
*/
|
||||
XSLTPUBFUN xmlXPathCompExprPtr XSLTCALL
|
||||
xsltXPathCompile (xsltStylesheetPtr style,
|
||||
const xmlChar *str);
|
||||
|
||||
/*
|
||||
* Profiling.
|
||||
*/
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSaveProfiling (xsltTransformContextPtr ctxt,
|
||||
FILE *output);
|
||||
XSLTPUBFUN xmlDocPtr XSLTCALL
|
||||
xsltGetProfileInformation (xsltTransformContextPtr ctxt);
|
||||
|
||||
XSLTPUBFUN long XSLTCALL
|
||||
xsltTimestamp (void);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltCalibrateAdjust (long delta);
|
||||
|
||||
/**
|
||||
* XSLT_TIMESTAMP_TICS_PER_SEC:
|
||||
*
|
||||
* Sampling precision for profiling
|
||||
*/
|
||||
#define XSLT_TIMESTAMP_TICS_PER_SEC 100000l
|
||||
|
||||
/*
|
||||
* Hooks for the debugger.
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
XSLT_DEBUG_NONE = 0, /* no debugging allowed */
|
||||
XSLT_DEBUG_INIT,
|
||||
XSLT_DEBUG_STEP,
|
||||
XSLT_DEBUG_STEPOUT,
|
||||
XSLT_DEBUG_NEXT,
|
||||
XSLT_DEBUG_STOP,
|
||||
XSLT_DEBUG_CONT,
|
||||
XSLT_DEBUG_RUN,
|
||||
XSLT_DEBUG_RUN_RESTART,
|
||||
XSLT_DEBUG_QUIT
|
||||
} xsltDebugStatusCodes;
|
||||
|
||||
XSLTPUBVAR int xslDebugStatus;
|
||||
|
||||
typedef void (*xsltHandleDebuggerCallback) (xmlNodePtr cur, xmlNodePtr node,
|
||||
xsltTemplatePtr templ, xsltTransformContextPtr ctxt);
|
||||
typedef int (*xsltAddCallCallback) (xsltTemplatePtr templ, xmlNodePtr source);
|
||||
typedef void (*xsltDropCallCallback) (void);
|
||||
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSetDebuggerStatus (int value);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltGetDebuggerStatus (void);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltSetDebuggerCallbacks (int no, void *block);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xslAddCall (xsltTemplatePtr templ,
|
||||
xmlNodePtr source);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xslDropCall (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_XSLTUTILS_H__ */
|
||||
|
||||
|
||||
/*
|
||||
* Summary: set of utilities for the XSLT engine
|
||||
* Description: interfaces for the utilities module of the XSLT engine.
|
||||
* things like message handling, profiling, and other
|
||||
* generally useful routines.
|
||||
*
|
||||
* Copy: See Copyright for the status of this software.
|
||||
*
|
||||
* Author: Daniel Veillard
|
||||
*/
|
||||
|
||||
#ifndef __XML_XSLTUTILS_H__
|
||||
#define __XML_XSLTUTILS_H__
|
||||
|
||||
#include <libxslt/xsltconfig.h>
|
||||
#ifdef HAVE_STDARG_H
|
||||
#include <stdarg.h>
|
||||
#endif
|
||||
#include <libxml/xpath.h>
|
||||
#include <libxml/dict.h>
|
||||
#include <libxml/xmlerror.h>
|
||||
#include "xsltexports.h"
|
||||
#include "xsltInternals.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* XSLT_TODO:
|
||||
*
|
||||
* Macro to flag unimplemented blocks.
|
||||
*/
|
||||
#define XSLT_TODO \
|
||||
xsltGenericError(xsltGenericErrorContext, \
|
||||
"Unimplemented block at %s:%d\n", \
|
||||
__FILE__, __LINE__);
|
||||
|
||||
/**
|
||||
* XSLT_STRANGE:
|
||||
*
|
||||
* Macro to flag that a problem was detected internally.
|
||||
*/
|
||||
#define XSLT_STRANGE \
|
||||
xsltGenericError(xsltGenericErrorContext, \
|
||||
"Internal error at %s:%d\n", \
|
||||
__FILE__, __LINE__);
|
||||
|
||||
/**
|
||||
* IS_XSLT_ELEM:
|
||||
*
|
||||
* Checks that the element pertains to XSLT namespace.
|
||||
*/
|
||||
#define IS_XSLT_ELEM(n) \
|
||||
(((n) != NULL) && ((n)->ns != NULL) && \
|
||||
(xmlStrEqual((n)->ns->href, XSLT_NAMESPACE)))
|
||||
|
||||
/**
|
||||
* IS_XSLT_NAME:
|
||||
*
|
||||
* Checks the value of an element in XSLT namespace.
|
||||
*/
|
||||
#define IS_XSLT_NAME(n, val) \
|
||||
(xmlStrEqual((n)->name, (const xmlChar *) (val)))
|
||||
|
||||
/**
|
||||
* IS_XSLT_REAL_NODE:
|
||||
*
|
||||
* Check that a node is a 'real' one: document, element, text or attribute.
|
||||
*/
|
||||
#define IS_XSLT_REAL_NODE(n) \
|
||||
(((n) != NULL) && \
|
||||
(((n)->type == XML_ELEMENT_NODE) || \
|
||||
((n)->type == XML_TEXT_NODE) || \
|
||||
((n)->type == XML_CDATA_SECTION_NODE) || \
|
||||
((n)->type == XML_ATTRIBUTE_NODE) || \
|
||||
((n)->type == XML_DOCUMENT_NODE) || \
|
||||
((n)->type == XML_HTML_DOCUMENT_NODE) || \
|
||||
((n)->type == XML_COMMENT_NODE) || \
|
||||
((n)->type == XML_PI_NODE)))
|
||||
|
||||
/*
|
||||
* Our own version of namespaced atributes lookup.
|
||||
*/
|
||||
XSLTPUBFUN xmlChar * XSLTCALL
|
||||
xsltGetNsProp (xmlNodePtr node,
|
||||
const xmlChar *name,
|
||||
const xmlChar *nameSpace);
|
||||
XSLTPUBFUN const xmlChar * XSLTCALL
|
||||
xsltGetCNsProp (xsltStylesheetPtr style,
|
||||
xmlNodePtr node,
|
||||
const xmlChar *name,
|
||||
const xmlChar *nameSpace);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltGetUTF8Char (const unsigned char *utf,
|
||||
int *len);
|
||||
|
||||
/*
|
||||
* XSLT Debug Tracing Tracing Types
|
||||
*/
|
||||
typedef enum {
|
||||
XSLT_TRACE_ALL = -1,
|
||||
XSLT_TRACE_NONE = 0,
|
||||
XSLT_TRACE_COPY_TEXT = 1<<0,
|
||||
XSLT_TRACE_PROCESS_NODE = 1<<1,
|
||||
XSLT_TRACE_APPLY_TEMPLATE = 1<<2,
|
||||
XSLT_TRACE_COPY = 1<<3,
|
||||
XSLT_TRACE_COMMENT = 1<<4,
|
||||
XSLT_TRACE_PI = 1<<5,
|
||||
XSLT_TRACE_COPY_OF = 1<<6,
|
||||
XSLT_TRACE_VALUE_OF = 1<<7,
|
||||
XSLT_TRACE_CALL_TEMPLATE = 1<<8,
|
||||
XSLT_TRACE_APPLY_TEMPLATES = 1<<9,
|
||||
XSLT_TRACE_CHOOSE = 1<<10,
|
||||
XSLT_TRACE_IF = 1<<11,
|
||||
XSLT_TRACE_FOR_EACH = 1<<12,
|
||||
XSLT_TRACE_STRIP_SPACES = 1<<13,
|
||||
XSLT_TRACE_TEMPLATES = 1<<14,
|
||||
XSLT_TRACE_KEYS = 1<<15,
|
||||
XSLT_TRACE_VARIABLES = 1<<16
|
||||
} xsltDebugTraceCodes;
|
||||
|
||||
/**
|
||||
* XSLT_TRACE:
|
||||
*
|
||||
* Control the type of xsl debugtrace messages emitted.
|
||||
*/
|
||||
#define XSLT_TRACE(ctxt,code,call) \
|
||||
if (ctxt->traceCode && (*(ctxt->traceCode) & code)) \
|
||||
call
|
||||
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltDebugSetDefaultTrace(xsltDebugTraceCodes val);
|
||||
XSLTPUBFUN xsltDebugTraceCodes XSLTCALL
|
||||
xsltDebugGetDefaultTrace(void);
|
||||
|
||||
/*
|
||||
* XSLT specific error and debug reporting functions.
|
||||
*/
|
||||
XSLTPUBVAR xmlGenericErrorFunc xsltGenericError;
|
||||
XSLTPUBVAR void *xsltGenericErrorContext;
|
||||
XSLTPUBVAR xmlGenericErrorFunc xsltGenericDebug;
|
||||
XSLTPUBVAR void *xsltGenericDebugContext;
|
||||
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltPrintErrorContext (xsltTransformContextPtr ctxt,
|
||||
xsltStylesheetPtr style,
|
||||
xmlNodePtr node);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltMessage (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr node,
|
||||
xmlNodePtr inst);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSetGenericErrorFunc (void *ctx,
|
||||
xmlGenericErrorFunc handler);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSetGenericDebugFunc (void *ctx,
|
||||
xmlGenericErrorFunc handler);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSetTransformErrorFunc (xsltTransformContextPtr ctxt,
|
||||
void *ctx,
|
||||
xmlGenericErrorFunc handler);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltTransformError (xsltTransformContextPtr ctxt,
|
||||
xsltStylesheetPtr style,
|
||||
xmlNodePtr node,
|
||||
const char *msg,
|
||||
...);
|
||||
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltSetCtxtParseOptions (xsltTransformContextPtr ctxt,
|
||||
int options);
|
||||
/*
|
||||
* Sorting.
|
||||
*/
|
||||
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltDocumentSortFunction (xmlNodeSetPtr list);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSetSortFunc (xsltSortFunc handler);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSetCtxtSortFunc (xsltTransformContextPtr ctxt,
|
||||
xsltSortFunc handler);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltDefaultSortFunction (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr *sorts,
|
||||
int nbsorts);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltDoSortFunction (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr * sorts,
|
||||
int nbsorts);
|
||||
XSLTPUBFUN xmlXPathObjectPtr * XSLTCALL
|
||||
xsltComputeSortResult (xsltTransformContextPtr ctxt,
|
||||
xmlNodePtr sort);
|
||||
|
||||
/*
|
||||
* QNames handling.
|
||||
*/
|
||||
|
||||
XSLTPUBFUN const xmlChar * XSLTCALL
|
||||
xsltSplitQName (xmlDictPtr dict,
|
||||
const xmlChar *name,
|
||||
const xmlChar **prefix);
|
||||
XSLTPUBFUN const xmlChar * XSLTCALL
|
||||
xsltGetQNameURI (xmlNodePtr node,
|
||||
xmlChar **name);
|
||||
|
||||
XSLTPUBFUN const xmlChar * XSLTCALL
|
||||
xsltGetQNameURI2 (xsltStylesheetPtr style,
|
||||
xmlNodePtr node,
|
||||
const xmlChar **name);
|
||||
|
||||
/*
|
||||
* Output, reuse libxml I/O buffers.
|
||||
*/
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltSaveResultTo (xmlOutputBufferPtr buf,
|
||||
xmlDocPtr result,
|
||||
xsltStylesheetPtr style);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltSaveResultToFilename (const char *URI,
|
||||
xmlDocPtr result,
|
||||
xsltStylesheetPtr style,
|
||||
int compression);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltSaveResultToFile (FILE *file,
|
||||
xmlDocPtr result,
|
||||
xsltStylesheetPtr style);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltSaveResultToFd (int fd,
|
||||
xmlDocPtr result,
|
||||
xsltStylesheetPtr style);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltSaveResultToString (xmlChar **doc_txt_ptr,
|
||||
int * doc_txt_len,
|
||||
xmlDocPtr result,
|
||||
xsltStylesheetPtr style);
|
||||
|
||||
/*
|
||||
* XPath interface
|
||||
*/
|
||||
XSLTPUBFUN xmlXPathCompExprPtr XSLTCALL
|
||||
xsltXPathCompile (xsltStylesheetPtr style,
|
||||
const xmlChar *str);
|
||||
|
||||
/*
|
||||
* Profiling.
|
||||
*/
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSaveProfiling (xsltTransformContextPtr ctxt,
|
||||
FILE *output);
|
||||
XSLTPUBFUN xmlDocPtr XSLTCALL
|
||||
xsltGetProfileInformation (xsltTransformContextPtr ctxt);
|
||||
|
||||
XSLTPUBFUN long XSLTCALL
|
||||
xsltTimestamp (void);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltCalibrateAdjust (long delta);
|
||||
|
||||
/**
|
||||
* XSLT_TIMESTAMP_TICS_PER_SEC:
|
||||
*
|
||||
* Sampling precision for profiling
|
||||
*/
|
||||
#define XSLT_TIMESTAMP_TICS_PER_SEC 100000l
|
||||
|
||||
/*
|
||||
* Hooks for the debugger.
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
XSLT_DEBUG_NONE = 0, /* no debugging allowed */
|
||||
XSLT_DEBUG_INIT,
|
||||
XSLT_DEBUG_STEP,
|
||||
XSLT_DEBUG_STEPOUT,
|
||||
XSLT_DEBUG_NEXT,
|
||||
XSLT_DEBUG_STOP,
|
||||
XSLT_DEBUG_CONT,
|
||||
XSLT_DEBUG_RUN,
|
||||
XSLT_DEBUG_RUN_RESTART,
|
||||
XSLT_DEBUG_QUIT
|
||||
} xsltDebugStatusCodes;
|
||||
|
||||
XSLTPUBVAR int xslDebugStatus;
|
||||
|
||||
typedef void (*xsltHandleDebuggerCallback) (xmlNodePtr cur, xmlNodePtr node,
|
||||
xsltTemplatePtr templ, xsltTransformContextPtr ctxt);
|
||||
typedef int (*xsltAddCallCallback) (xsltTemplatePtr templ, xmlNodePtr source);
|
||||
typedef void (*xsltDropCallCallback) (void);
|
||||
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xsltSetDebuggerStatus (int value);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltGetDebuggerStatus (void);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xsltSetDebuggerCallbacks (int no, void *block);
|
||||
XSLTPUBFUN int XSLTCALL
|
||||
xslAddCall (xsltTemplatePtr templ,
|
||||
xmlNodePtr source);
|
||||
XSLTPUBFUN void XSLTCALL
|
||||
xslDropCall (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XML_XSLTUTILS_H__ */
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user