mirror of
https://gitlab.gnome.org/GNOME/libxslt
synced 2025-11-06 23:49:25 +03:00
Some infrastructure work, and of course some debug:
- TODO: more stuff - libxslt/transform.c: context position and size in for-each - libxslt/xsltutils[ch] libxslt/makefile.am: added the util module and put Error and Debug routines - libxslt/xslt.c libxslt/transform.c libxslt/pattern.c: switched to use the Debug calls, cleanup - libxslt/xsltproc.c: added -v to enable debug printing Daniel
This commit is contained in:
10
ChangeLog
10
ChangeLog
@@ -1,3 +1,13 @@
|
|||||||
|
Wed Jan 17 14:25:25 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
|
* TODO: more stuff
|
||||||
|
* libxslt/transform.c: context position and size in for-each
|
||||||
|
* libxslt/xsltutils[ch] libxslt/makefile.am: added the util module
|
||||||
|
and put Error and Debug routines
|
||||||
|
* libxslt/xslt.c libxslt/transform.c libxslt/pattern.c: switched
|
||||||
|
to use the Debug calls, cleanup
|
||||||
|
* libxslt/xsltproc.c: added -v to enable debug printing
|
||||||
|
|
||||||
Tue Jan 16 17:17:17 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
Tue Jan 16 17:17:17 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
* TODO: started filling it :-(
|
* TODO: started filling it :-(
|
||||||
|
|||||||
6
TODO
6
TODO
@@ -2,6 +2,8 @@ Design:
|
|||||||
- should transforms for a given stylesheet be thread clean,
|
- should transforms for a given stylesheet be thread clean,
|
||||||
or can a stylesheet be enriched with document specific
|
or can a stylesheet be enriched with document specific
|
||||||
informations and cleaned up later ?
|
informations and cleaned up later ?
|
||||||
|
- seems that saving back XSLT stylesheet from a compiled form might
|
||||||
|
be a bit ugly ...
|
||||||
|
|
||||||
Import:
|
Import:
|
||||||
-> parse them
|
-> parse them
|
||||||
@@ -28,3 +30,7 @@ Error handling:
|
|||||||
-> check the version stuff, design a separate module for error interfacing
|
-> check the version stuff, design a separate module for error interfacing
|
||||||
and default handling, parsing vs. runtime, fatal / compat / warning,
|
and default handling, parsing vs. runtime, fatal / compat / warning,
|
||||||
and lack of optionnal features.
|
and lack of optionnal features.
|
||||||
|
|
||||||
|
Support Attribute value templates:
|
||||||
|
-> starts to be urgent. Design it in flexible ways but try to optimize
|
||||||
|
to handle most of it at the stylesheet parse time ...
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ lib_LTLIBRARIES = libxslt.la
|
|||||||
libxslt_la_SOURCES = \
|
libxslt_la_SOURCES = \
|
||||||
xslt.c \
|
xslt.c \
|
||||||
xslt.h \
|
xslt.h \
|
||||||
|
xsltutils.c \
|
||||||
|
xsltutils.h \
|
||||||
pattern.c \
|
pattern.c \
|
||||||
pattern.h \
|
pattern.h \
|
||||||
transform.c \
|
transform.c \
|
||||||
|
|||||||
@@ -21,25 +21,10 @@
|
|||||||
#include <libxml/parserInternals.h>
|
#include <libxml/parserInternals.h>
|
||||||
#include "xslt.h"
|
#include "xslt.h"
|
||||||
#include "xsltInternals.h"
|
#include "xsltInternals.h"
|
||||||
|
#include "xsltutils.h"
|
||||||
|
|
||||||
/* #define DEBUG_PARSING */
|
/* #define DEBUG_PARSING */
|
||||||
|
|
||||||
#define TODO \
|
|
||||||
xsltGenericError(xsltGenericErrorContext, \
|
|
||||||
"Unimplemented block at %s:%d\n", \
|
|
||||||
__FILE__, __LINE__);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To cleanup
|
|
||||||
*/
|
|
||||||
xmlChar *xmlSplitQName2(const xmlChar *name, xmlChar **prefix);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* There is no XSLT specific error reporting module yet
|
|
||||||
*/
|
|
||||||
#define xsltGenericError xmlGenericError
|
|
||||||
#define xsltGenericErrorContext xmlGenericErrorContext
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Types are private:
|
* Types are private:
|
||||||
*/
|
*/
|
||||||
@@ -901,7 +886,7 @@ xsltCompilePattern(const xmlChar *pattern) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_PARSING
|
#ifdef DEBUG_PARSING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltCompilePattern : parsing '%s'\n", pattern);
|
"xsltCompilePattern : parsing '%s'\n", pattern);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1057,12 +1042,12 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur) {
|
|||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_PARSING
|
#ifdef DEBUG_PARSING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltAddTemplate: created template hash\n");
|
"xsltAddTemplate: created template hash\n");
|
||||||
#endif
|
#endif
|
||||||
xmlHashAddEntry(style->templatesHash, name, pat);
|
xmlHashAddEntry(style->templatesHash, name, pat);
|
||||||
#ifdef DEBUG_PARSING
|
#ifdef DEBUG_PARSING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltAddTemplate: added new hash %s\n", name);
|
"xsltAddTemplate: added new hash %s\n", name);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
@@ -1070,7 +1055,7 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur) {
|
|||||||
if (list == NULL) {
|
if (list == NULL) {
|
||||||
xmlHashAddEntry(style->templatesHash, name, pat);
|
xmlHashAddEntry(style->templatesHash, name, pat);
|
||||||
#ifdef DEBUG_PARSING
|
#ifdef DEBUG_PARSING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltAddTemplate: added new hash %s\n", name);
|
"xsltAddTemplate: added new hash %s\n", name);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
@@ -1082,7 +1067,7 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur) {
|
|||||||
pat->next = list;
|
pat->next = list;
|
||||||
xmlHashUpdateEntry(style->templatesHash, name, pat, NULL);
|
xmlHashUpdateEntry(style->templatesHash, name, pat, NULL);
|
||||||
#ifdef DEBUG_PARSING
|
#ifdef DEBUG_PARSING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltAddTemplate: added head hash for %s\n", name);
|
"xsltAddTemplate: added head hash for %s\n", name);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
@@ -1161,7 +1146,7 @@ xsltGetTemplate(xsltStylesheetPtr style, xmlNodePtr node) {
|
|||||||
list = (xsltCompMatchPtr) xmlHashLookup(style->templatesHash, name);
|
list = (xsltCompMatchPtr) xmlHashLookup(style->templatesHash, name);
|
||||||
if (list == NULL) {
|
if (list == NULL) {
|
||||||
#ifdef DEBUG_MATCHING
|
#ifdef DEBUG_MATCHING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltGetTemplate: empty set for %s\n", name);
|
"xsltGetTemplate: empty set for %s\n", name);
|
||||||
#endif
|
#endif
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|||||||
@@ -26,43 +26,16 @@
|
|||||||
#include <libxml/HTMLtree.h>
|
#include <libxml/HTMLtree.h>
|
||||||
#include "xslt.h"
|
#include "xslt.h"
|
||||||
#include "xsltInternals.h"
|
#include "xsltInternals.h"
|
||||||
|
#include "xsltutils.h"
|
||||||
#include "pattern.h"
|
#include "pattern.h"
|
||||||
#include "transform.h"
|
#include "transform.h"
|
||||||
|
|
||||||
#define DEBUG_PROCESS
|
#define DEBUG_PROCESS
|
||||||
|
|
||||||
/*
|
|
||||||
* To cleanup
|
|
||||||
*/
|
|
||||||
xmlChar *xmlSplitQName2(const xmlChar *name, xmlChar **prefix);
|
|
||||||
void xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* There is no XSLT specific error reporting module yet
|
|
||||||
*/
|
|
||||||
#define xsltGenericError xmlGenericError
|
|
||||||
#define xsltGenericErrorContext xmlGenericErrorContext
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Useful macros
|
* Useful macros
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TODO \
|
|
||||||
xsltGenericError(xsltGenericErrorContext, \
|
|
||||||
"Unimplemented block at %s:%d\n", \
|
|
||||||
__FILE__, __LINE__);
|
|
||||||
|
|
||||||
#define STRANGE \
|
|
||||||
xsltGenericError(xsltGenericErrorContext, \
|
|
||||||
"Internal error at %s:%d\n", \
|
|
||||||
__FILE__, __LINE__);
|
|
||||||
|
|
||||||
#define IS_XSLT_ELEM(n) \
|
|
||||||
((n)->ns != NULL) && (xmlStrEqual((n)->ns->href, XSLT_NAMESPACE))
|
|
||||||
|
|
||||||
#define IS_XSLT_NAME(n, val) \
|
|
||||||
(xmlStrEqual((n)->name, (const xmlChar *) (val)))
|
|
||||||
|
|
||||||
#define IS_BLANK_NODE(n) \
|
#define IS_BLANK_NODE(n) \
|
||||||
(((n)->type == XML_TEXT_NODE) && (xsltIsBlank((n)->content)))
|
(((n)->type == XML_TEXT_NODE) && (xsltIsBlank((n)->content)))
|
||||||
|
|
||||||
@@ -286,7 +259,7 @@ xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltValueOf: select %s\n", prop);
|
"xsltValueOf: select %s\n", prop);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -325,7 +298,7 @@ xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
else
|
else
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltValueOf: result %s\n", res->stringval);
|
"xsltValueOf: result %s\n", res->stringval);
|
||||||
#endif
|
#endif
|
||||||
error:
|
error:
|
||||||
@@ -469,7 +442,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltDefaultProcessOneNode: skipping node type %d\n",
|
"xsltDefaultProcessOneNode: skipping node type %d\n",
|
||||||
node->type);
|
node->type);
|
||||||
#endif
|
#endif
|
||||||
@@ -478,7 +451,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
|
|||||||
node = node->next;
|
node = node->next;
|
||||||
if (delete != NULL) {
|
if (delete != NULL) {
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltDefaultProcessOneNode: removing ignorable blank node\n");
|
"xsltDefaultProcessOneNode: removing ignorable blank node\n");
|
||||||
#endif
|
#endif
|
||||||
xmlUnlinkNode(delete);
|
xmlUnlinkNode(delete);
|
||||||
@@ -505,7 +478,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltApplyTemplates: node: %s\n", node->name);
|
"xsltApplyTemplates: node: %s\n", node->name);
|
||||||
#endif
|
#endif
|
||||||
prop = xmlGetNsProp(inst, (const xmlChar *)"select", XSLT_NAMESPACE);
|
prop = xmlGetNsProp(inst, (const xmlChar *)"select", XSLT_NAMESPACE);
|
||||||
@@ -541,7 +514,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
*/
|
*/
|
||||||
if (insert == NULL) {
|
if (insert == NULL) {
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltApplyOneTemplate: insert == NULL !\n");
|
"xsltApplyOneTemplate: insert == NULL !\n");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
@@ -552,7 +525,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
*/
|
*/
|
||||||
if (delete != NULL) {
|
if (delete != NULL) {
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltApplyOneTemplate: removing ignorable blank node\n");
|
"xsltApplyOneTemplate: removing ignorable blank node\n");
|
||||||
#endif
|
#endif
|
||||||
xmlUnlinkNode(delete);
|
xmlUnlinkNode(delete);
|
||||||
@@ -580,9 +553,13 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
ctxt->insert = insert;
|
ctxt->insert = insert;
|
||||||
xsltAttribute(ctxt, node, cur);
|
xsltAttribute(ctxt, node, cur);
|
||||||
ctxt->insert = oldInsert;
|
ctxt->insert = oldInsert;
|
||||||
|
} else if (IS_XSLT_NAME(cur, "element")) {
|
||||||
|
ctxt->insert = insert;
|
||||||
|
xsltAttribute(ctxt, node, cur);
|
||||||
|
ctxt->insert = oldInsert;
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltApplyOneTemplate: found xslt:%s\n", cur->name);
|
"xsltApplyOneTemplate: found xslt:%s\n", cur->name);
|
||||||
#endif
|
#endif
|
||||||
TODO
|
TODO
|
||||||
@@ -596,7 +573,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
*/
|
*/
|
||||||
if (!(IS_BLANK_NODE(cur))) {
|
if (!(IS_BLANK_NODE(cur))) {
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltApplyOneTemplate: copy text %s\n", cur->content);
|
"xsltApplyOneTemplate: copy text %s\n", cur->content);
|
||||||
#endif
|
#endif
|
||||||
copy = xmlCopyNode(cur, 0);
|
copy = xmlCopyNode(cur, 0);
|
||||||
@@ -611,7 +588,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
} else if (cur->type == XML_ELEMENT_NODE) {
|
} else if (cur->type == XML_ELEMENT_NODE) {
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltApplyOneTemplate: copy node %s\n", cur->name);
|
"xsltApplyOneTemplate: copy node %s\n", cur->name);
|
||||||
#endif
|
#endif
|
||||||
copy = xsltCopyNode(ctxt, cur, insert);
|
copy = xsltCopyNode(ctxt, cur, insert);
|
||||||
@@ -683,7 +660,7 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltIf: test %s\n", prop);
|
"xsltIf: test %s\n", prop);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -713,7 +690,7 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
doit = res->boolval;
|
doit = res->boolval;
|
||||||
else {
|
else {
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltIf: test didn't evaluate to a boolean\n");
|
"xsltIf: test didn't evaluate to a boolean\n");
|
||||||
#endif
|
#endif
|
||||||
goto error;
|
goto error;
|
||||||
@@ -721,7 +698,7 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltIf: test evaluate to %d\n", doit);
|
"xsltIf: test evaluate to %d\n", doit);
|
||||||
#endif
|
#endif
|
||||||
if (doit) {
|
if (doit) {
|
||||||
@@ -753,7 +730,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
xmlNodePtr replacement;
|
xmlNodePtr replacement;
|
||||||
xmlNodeSetPtr list = NULL, oldlist;
|
xmlNodeSetPtr list = NULL, oldlist;
|
||||||
xmlXPathParserContextPtr xpathParserCtxt;
|
xmlXPathParserContextPtr xpathParserCtxt;
|
||||||
int i;
|
int i, oldProximityPosition, oldContextSize;
|
||||||
|
|
||||||
if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
|
if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
|
||||||
return;
|
return;
|
||||||
@@ -765,7 +742,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltForEach: select %s\n", prop);
|
"xsltForEach: select %s\n", prop);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -794,7 +771,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
list = res->nodesetval;
|
list = res->nodesetval;
|
||||||
else {
|
else {
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltForEach: select didn't evaluate to a node list\n");
|
"xsltForEach: select didn't evaluate to a node list\n");
|
||||||
#endif
|
#endif
|
||||||
goto error;
|
goto error;
|
||||||
@@ -802,7 +779,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltForEach: select evaluate to %d nodes\n", list->nodeNr);
|
"xsltForEach: select evaluate to %d nodes\n", list->nodeNr);
|
||||||
#endif
|
#endif
|
||||||
/* TODO: handle and skip the xsl:sort */
|
/* TODO: handle and skip the xsl:sort */
|
||||||
@@ -810,11 +787,17 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
|
|
||||||
oldlist = ctxt->nodeList;
|
oldlist = ctxt->nodeList;
|
||||||
ctxt->nodeList = list;
|
ctxt->nodeList = list;
|
||||||
|
oldContextSize = ctxt->xpathCtxt->contextSize;
|
||||||
|
oldProximityPosition = ctxt->xpathCtxt->proximityPosition;
|
||||||
|
ctxt->xpathCtxt->contextSize = list->nodeNr;
|
||||||
for (i = 0;i < list->nodeNr;i++) {
|
for (i = 0;i < list->nodeNr;i++) {
|
||||||
ctxt->node = list->nodeTab[i];
|
ctxt->node = list->nodeTab[i];
|
||||||
|
ctxt->xpathCtxt->proximityPosition = i + 1;
|
||||||
xsltApplyOneTemplate(ctxt, list->nodeTab[i], replacement);
|
xsltApplyOneTemplate(ctxt, list->nodeTab[i], replacement);
|
||||||
}
|
}
|
||||||
ctxt->nodeList = oldlist;
|
ctxt->nodeList = oldlist;
|
||||||
|
ctxt->xpathCtxt->contextSize = oldContextSize;
|
||||||
|
ctxt->xpathCtxt->proximityPosition = oldProximityPosition;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (xpathParserCtxt != NULL)
|
if (xpathParserCtxt != NULL)
|
||||||
@@ -843,10 +826,10 @@ xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
|
|||||||
if (template == NULL) {
|
if (template == NULL) {
|
||||||
#ifdef DEBUG_PROCESS
|
#ifdef DEBUG_PROCESS
|
||||||
if (node->type == XML_DOCUMENT_NODE)
|
if (node->type == XML_DOCUMENT_NODE)
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltProcessOneNode: no template found for /\n");
|
"xsltProcessOneNode: no template found for /\n");
|
||||||
else
|
else
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltProcessOneNode: no template found for %s\n", node->name);
|
"xsltProcessOneNode: no template found for %s\n", node->name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -22,45 +22,20 @@
|
|||||||
#include "xslt.h"
|
#include "xslt.h"
|
||||||
#include "xsltInternals.h"
|
#include "xsltInternals.h"
|
||||||
#include "pattern.h"
|
#include "pattern.h"
|
||||||
|
#include "xsltutils.h"
|
||||||
|
|
||||||
/* #define DEBUG_PARSING */
|
#define DEBUG_PARSING
|
||||||
|
|
||||||
/*
|
|
||||||
* To cleanup
|
|
||||||
*/
|
|
||||||
xmlChar *xmlSplitQName2(const xmlChar *name, xmlChar **prefix);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* There is no XSLT specific error reporting module yet
|
|
||||||
*/
|
|
||||||
#define xsltGenericError xmlGenericError
|
|
||||||
#define xsltGenericErrorContext xmlGenericErrorContext
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Useful macros
|
* Useful macros
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define IS_XSLT_ELEM(n) \
|
|
||||||
((n)->ns != NULL) && (xmlStrEqual((n)->ns->href, XSLT_NAMESPACE))
|
|
||||||
|
|
||||||
#define IS_XSLT_NAME(n, val) \
|
|
||||||
(xmlStrEqual((n)->name, (const xmlChar *) (val)))
|
|
||||||
|
|
||||||
#define IS_BLANK(c) (((c) == 0x20) || ((c) == 0x09) || ((c) == 0xA) || \
|
#define IS_BLANK(c) (((c) == 0x20) || ((c) == 0x09) || ((c) == 0xA) || \
|
||||||
((c) == 0x0D))
|
((c) == 0x0D))
|
||||||
|
|
||||||
#define IS_BLANK_NODE(n) \
|
#define IS_BLANK_NODE(n) \
|
||||||
(((n)->type == XML_TEXT_NODE) && (xsltIsBlank((n)->content)))
|
(((n)->type == XML_TEXT_NODE) && (xsltIsBlank((n)->content)))
|
||||||
|
|
||||||
#define TODO \
|
|
||||||
xsltGenericError(xsltGenericErrorContext, \
|
|
||||||
"Unimplemented block at %s:%d\n", \
|
|
||||||
__FILE__, __LINE__);
|
|
||||||
|
|
||||||
#define STRANGE \
|
|
||||||
xsltGenericError(xsltGenericErrorContext, \
|
|
||||||
"Internal error at %s:%d\n", \
|
|
||||||
__FILE__, __LINE__);
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
@@ -354,7 +329,7 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur) {
|
|||||||
element = xmlStrndup(element, end - element);
|
element = xmlStrndup(element, end - element);
|
||||||
if (element) {
|
if (element) {
|
||||||
#ifdef DEBUG_PARSING
|
#ifdef DEBUG_PARSING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"add cdata section output element %s\n", element);
|
"add cdata section output element %s\n", element);
|
||||||
#endif
|
#endif
|
||||||
xmlHashAddEntry(style->stripSpaces, element, "cdata");
|
xmlHashAddEntry(style->stripSpaces, element, "cdata");
|
||||||
@@ -405,7 +380,7 @@ xsltParseStylesheetPreserveSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
|
|||||||
element = xmlStrndup(element, end - element);
|
element = xmlStrndup(element, end - element);
|
||||||
if (element) {
|
if (element) {
|
||||||
#ifdef DEBUG_PARSING
|
#ifdef DEBUG_PARSING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"add preserved space element %s\n", element);
|
"add preserved space element %s\n", element);
|
||||||
#endif
|
#endif
|
||||||
xmlHashAddEntry(style->stripSpaces, element, "preserve");
|
xmlHashAddEntry(style->stripSpaces, element, "preserve");
|
||||||
@@ -455,7 +430,7 @@ xsltParseStylesheetStripSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
|
|||||||
element = xmlStrndup(element, end - element);
|
element = xmlStrndup(element, end - element);
|
||||||
if (element) {
|
if (element) {
|
||||||
#ifdef DEBUG_PARSING
|
#ifdef DEBUG_PARSING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"add stripped space element %s\n", element);
|
"add stripped space element %s\n", element);
|
||||||
#endif
|
#endif
|
||||||
xmlHashAddEntry(style->stripSpaces, element, "strip");
|
xmlHashAddEntry(style->stripSpaces, element, "strip");
|
||||||
@@ -491,7 +466,7 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xsltTemplatePtr ret,
|
|||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
if (delete != NULL) {
|
if (delete != NULL) {
|
||||||
#ifdef DEBUG_PARSING
|
#ifdef DEBUG_PARSING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltParseStylesheetTemplate: removing ignorable blank node\n");
|
"xsltParseStylesheetTemplate: removing ignorable blank node\n");
|
||||||
#endif
|
#endif
|
||||||
xmlUnlinkNode(delete);
|
xmlUnlinkNode(delete);
|
||||||
@@ -553,7 +528,7 @@ skip_children:
|
|||||||
}
|
}
|
||||||
if (delete != NULL) {
|
if (delete != NULL) {
|
||||||
#ifdef DEBUG_PARSING
|
#ifdef DEBUG_PARSING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltParseStylesheetTemplate: removing ignorable blank node\n");
|
"xsltParseStylesheetTemplate: removing ignorable blank node\n");
|
||||||
#endif
|
#endif
|
||||||
xmlUnlinkNode(delete);
|
xmlUnlinkNode(delete);
|
||||||
@@ -720,7 +695,7 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
|
|||||||
}
|
}
|
||||||
if (!(IS_XSLT_ELEM(cur))) {
|
if (!(IS_XSLT_ELEM(cur))) {
|
||||||
#ifdef DEBUG_PARSING
|
#ifdef DEBUG_PARSING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltParseStylesheetTop : found foreign element %s\n",
|
"xsltParseStylesheetTop : found foreign element %s\n",
|
||||||
cur->name);
|
cur->name);
|
||||||
#endif
|
#endif
|
||||||
@@ -740,7 +715,7 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
|
|||||||
}
|
}
|
||||||
if (!(IS_XSLT_ELEM(cur))) {
|
if (!(IS_XSLT_ELEM(cur))) {
|
||||||
#ifdef DEBUG_PARSING
|
#ifdef DEBUG_PARSING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltParseStylesheetTop : found foreign element %s\n",
|
"xsltParseStylesheetTop : found foreign element %s\n",
|
||||||
cur->name);
|
cur->name);
|
||||||
#endif
|
#endif
|
||||||
@@ -783,7 +758,7 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
|
|||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_PARSING
|
#ifdef DEBUG_PARSING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"parsed %d templates\n", templates);
|
"parsed %d templates\n", templates);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -822,9 +797,11 @@ xsltParseStylesheetDoc(xmlDocPtr doc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret->doc = doc;
|
ret->doc = doc;
|
||||||
if ((IS_XSLT_ELEM(cur)) && (IS_XSLT_NAME(cur, "stylesheet"))) {
|
if ((IS_XSLT_ELEM(cur)) &&
|
||||||
|
((IS_XSLT_NAME(cur, "stylesheet")) ||
|
||||||
|
(IS_XSLT_NAME(cur, "transform")))) {
|
||||||
#ifdef DEBUG_PARSING
|
#ifdef DEBUG_PARSING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltParseStylesheetDoc : found stylesheet\n");
|
"xsltParseStylesheetDoc : found stylesheet\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -845,7 +822,7 @@ xsltParseStylesheetDoc(xmlDocPtr doc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_PARSING
|
#ifdef DEBUG_PARSING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltParseStylesheetDoc : document is stylesheet\n");
|
"xsltParseStylesheetDoc : document is stylesheet\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -893,7 +870,7 @@ xsltParseStylesheetFile(const xmlChar* filename) {
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
#ifdef DEBUG_PARSING
|
#ifdef DEBUG_PARSING
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltParseStylesheetFile : parse %s\n", filename);
|
"xsltParseStylesheetFile : parse %s\n", filename);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include <libxslt/xslt.h>
|
#include <libxslt/xslt.h>
|
||||||
#include <libxslt/xsltInternals.h>
|
#include <libxslt/xsltInternals.h>
|
||||||
#include <libxslt/transform.h>
|
#include <libxslt/transform.h>
|
||||||
|
#include <libxslt/xsltutils.h>
|
||||||
|
|
||||||
static int debug = 0;
|
static int debug = 0;
|
||||||
|
|
||||||
@@ -24,8 +25,13 @@ main(int argc, char **argv) {
|
|||||||
|
|
||||||
LIBXML_TEST_VERSION
|
LIBXML_TEST_VERSION
|
||||||
for (i = 1; i < argc ; i++) {
|
for (i = 1; i < argc ; i++) {
|
||||||
if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
|
if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) {
|
||||||
debug++;
|
debug++;
|
||||||
|
} else if ((!strcmp(argv[i], "-v")) ||
|
||||||
|
(!strcmp(argv[i], "-verbose")) ||
|
||||||
|
(!strcmp(argv[i], "--verbose"))) {
|
||||||
|
xsltSetGenericDebugFunc(stderr, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
xmlSubstituteEntitiesDefault(1);
|
xmlSubstituteEntitiesDefault(1);
|
||||||
for (i = 1; i < argc ; i++) {
|
for (i = 1; i < argc ; i++) {
|
||||||
|
|||||||
120
libxslt/xsltutils.c
Normal file
120
libxslt/xsltutils.c
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
* xsltutils.c: Utilities for the XSL Transformation 1.0 engine
|
||||||
|
*
|
||||||
|
* Reference:
|
||||||
|
* http://www.w3.org/TR/1999/REC-xslt-19991116
|
||||||
|
*
|
||||||
|
* See Copyright for the status of this software.
|
||||||
|
*
|
||||||
|
* Daniel.Veillard@imag.fr
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "xsltconfig.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#include <libxml/xmlmemory.h>
|
||||||
|
#include <libxml/tree.h>
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
|
#include "xsltutils.h"
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* *
|
||||||
|
* Handling of out of context errors *
|
||||||
|
* *
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xsltGenericErrorDefaultFunc:
|
||||||
|
* @ctx: an error context
|
||||||
|
* @msg: the message to display/transmit
|
||||||
|
* @...: extra parameters for the message display
|
||||||
|
*
|
||||||
|
* Default handler for out of context error messages.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xsltGenericErrorDefaultFunc(void *ctx, const char *msg, ...) {
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
if (xsltGenericErrorContext == NULL)
|
||||||
|
xsltGenericErrorContext = (void *) stderr;
|
||||||
|
|
||||||
|
va_start(args, msg);
|
||||||
|
vfprintf((FILE *)xsltGenericErrorContext, msg, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlGenericErrorFunc xsltGenericError = xsltGenericErrorDefaultFunc;
|
||||||
|
void *xsltGenericErrorContext = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xsltSetGenericErrorFunc:
|
||||||
|
* @ctx: the new error handling context
|
||||||
|
* @handler: the new handler function
|
||||||
|
*
|
||||||
|
* Function to reset the handler and the error context for out of
|
||||||
|
* context error messages.
|
||||||
|
* This simply means that @handler will be called for subsequent
|
||||||
|
* error messages while not parsing nor validating. And @ctx will
|
||||||
|
* be passed as first argument to @handler
|
||||||
|
* One can simply force messages to be emitted to another FILE * than
|
||||||
|
* stderr by setting @ctx to this file handle and @handler to NULL.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xsltSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
|
||||||
|
xsltGenericErrorContext = ctx;
|
||||||
|
if (handler != NULL)
|
||||||
|
xsltGenericError = handler;
|
||||||
|
else
|
||||||
|
xsltGenericError = xsltGenericErrorDefaultFunc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xsltGenericDebugDefaultFunc:
|
||||||
|
* @ctx: an error context
|
||||||
|
* @msg: the message to display/transmit
|
||||||
|
* @...: extra parameters for the message display
|
||||||
|
*
|
||||||
|
* Default handler for out of context error messages.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xsltGenericDebugDefaultFunc(void *ctx, const char *msg, ...) {
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
if (xsltGenericDebugContext == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
va_start(args, msg);
|
||||||
|
vfprintf((FILE *)xsltGenericDebugContext, msg, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlGenericErrorFunc xsltGenericDebug = xsltGenericDebugDefaultFunc;
|
||||||
|
void *xsltGenericDebugContext = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xsltSetGenericDebugFunc:
|
||||||
|
* @ctx: the new error handling context
|
||||||
|
* @handler: the new handler function
|
||||||
|
*
|
||||||
|
* Function to reset the handler and the error context for out of
|
||||||
|
* context error messages.
|
||||||
|
* This simply means that @handler will be called for subsequent
|
||||||
|
* error messages while not parsing nor validating. And @ctx will
|
||||||
|
* be passed as first argument to @handler
|
||||||
|
* One can simply force messages to be emitted to another FILE * than
|
||||||
|
* stderr by setting @ctx to this file handle and @handler to NULL.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xsltSetGenericDebugFunc(void *ctx, xmlGenericErrorFunc handler) {
|
||||||
|
xsltGenericDebugContext = ctx;
|
||||||
|
if (handler != NULL)
|
||||||
|
xsltGenericDebug = handler;
|
||||||
|
else
|
||||||
|
xsltGenericDebug = xsltGenericDebugDefaultFunc;
|
||||||
|
}
|
||||||
|
|
||||||
63
libxslt/xsltutils.h
Normal file
63
libxslt/xsltutils.h
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* xsltutils.h: interfaces for the utilities module of the XSLT engine
|
||||||
|
*
|
||||||
|
* See Copyright for the status of this software.
|
||||||
|
*
|
||||||
|
* Daniel.Veillard@w3.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __XML_XSLTUTILS_H__
|
||||||
|
#define __XML_XSLTUTILS_H__
|
||||||
|
|
||||||
|
#include <libxml/xpath.h>
|
||||||
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* To cleanup
|
||||||
|
*/
|
||||||
|
xmlChar *xmlSplitQName2(const xmlChar *name, xmlChar **prefix);
|
||||||
|
void xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Useful macros
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define TODO \
|
||||||
|
xsltGenericError(xsltGenericErrorContext, \
|
||||||
|
"Unimplemented block at %s:%d\n", \
|
||||||
|
__FILE__, __LINE__);
|
||||||
|
|
||||||
|
#define STRANGE \
|
||||||
|
xsltGenericError(xsltGenericErrorContext, \
|
||||||
|
"Internal error at %s:%d\n", \
|
||||||
|
__FILE__, __LINE__);
|
||||||
|
|
||||||
|
#define IS_XSLT_ELEM(n) \
|
||||||
|
((n)->ns != NULL) && (xmlStrEqual((n)->ns->href, XSLT_NAMESPACE))
|
||||||
|
|
||||||
|
#define IS_XSLT_NAME(n, val) \
|
||||||
|
(xmlStrEqual((n)->name, (const xmlChar *) (val)))
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XSLT specific error and debug reporting functions
|
||||||
|
*/
|
||||||
|
extern xmlGenericErrorFunc xsltGenericError;
|
||||||
|
extern void *xsltGenericErrorContext;
|
||||||
|
extern xmlGenericErrorFunc xsltGenericDebug;
|
||||||
|
extern void *xsltGenericDebugContext;
|
||||||
|
|
||||||
|
void xsltSetGenericErrorFunc (void *ctx,
|
||||||
|
xmlGenericErrorFunc handler);
|
||||||
|
void xsltSetGenericDebugFunc (void *ctx,
|
||||||
|
xmlGenericErrorFunc handler);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __XML_XSLTUTILS_H__ */
|
||||||
|
|
||||||
Reference in New Issue
Block a user