1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-07-29 15:41:13 +03:00

Fixes the problems exposed by #73880 those ought to be computed at

* libxslt/pattern.c: Fixes the problems exposed by #73880
  those ought to be computed at stylesheet compile time, not
  at run-time, and the computation was wrong.
* libxslt/transform.c: get rid of fake nodes coming from node-set
  transformations. At least if they are still produced they will
  become easy to spot as resulting document won't be well-formed.
Daniel
This commit is contained in:
Daniel Veillard
2002-03-08 13:55:08 +00:00
parent cc0e7a04fd
commit f503baafa1
5 changed files with 65 additions and 30 deletions

View File

@ -1,3 +1,12 @@
Fri Mar 8 14:51:59 CET 2002 Daniel Veillard <daniel@veillard.com>
* libxslt/pattern.c: Fixes the problems exposed by #73880
those ought to be computed at stylesheet compile time, not
at run-time, and the computation was wrong.
* libxslt/transform.c: get rid of fake nodes coming from node-set
transformations. At least if they are still produced they will
become easy to spot as resulting document won't be well-formed.
Thu Mar 7 17:01:21 CET 2002 Daniel Veillard <daniel@veillard.com>
* libxslt/extensions.c: fixed bug #73791 related to extension

View File

@ -268,6 +268,9 @@ xsltCompMatchAdd(xsltParserContextPtr ctxt, xsltCompMatchPtr comp,
comp->steps[comp->nbStep].lenExtra =
xsltAllocateExtra(ctxt->style);
}
if (op == XSLT_OP_PREDICATE) {
comp->steps[comp->nbStep].comp = xmlXPathCompile(value);
}
comp->nbStep++;
return (0);
}
@ -286,6 +289,7 @@ xsltSwapTopCompMatch(xsltCompMatchPtr comp) {
if (j > 0) {
register xmlChar *tmp;
register xsltOp op;
register xmlXPathCompExprPtr expr;
i = j - 1;
tmp = comp->steps[i].value;
comp->steps[i].value = comp->steps[j].value;
@ -296,6 +300,9 @@ xsltSwapTopCompMatch(xsltCompMatchPtr comp) {
op = comp->steps[i].op;
comp->steps[i].op = comp->steps[j].op;
comp->steps[j].op = op;
expr = comp->steps[i].comp;
comp->steps[i].comp = comp->steps[j].comp;
comp->steps[j].comp = expr;
}
}
@ -313,6 +320,7 @@ xsltReverseCompMatch(xsltCompMatchPtr comp) {
while (j > i) {
register xmlChar *tmp;
register xsltOp op;
register xmlXPathCompExprPtr expr;
tmp = comp->steps[i].value;
comp->steps[i].value = comp->steps[j].value;
comp->steps[j].value = tmp;
@ -322,6 +330,9 @@ xsltReverseCompMatch(xsltCompMatchPtr comp) {
op = comp->steps[i].op;
comp->steps[i].op = comp->steps[j].op;
comp->steps[j].op = op;
expr = comp->steps[i].comp;
comp->steps[i].comp = comp->steps[j].comp;
comp->steps[j].comp = expr;
j--;
i++;
}
@ -800,22 +811,9 @@ xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
if (step->value == NULL)
goto wrong_index;
if (step->comp == NULL) {
step->comp = xmlXPathCompile(step->value);
if (step->comp == NULL)
goto wrong_index;
}
if (comp->nsList == NULL) {
int j = 0;
comp->nsList = xmlGetNsList(node->doc, node);
if (comp->nsList != NULL) {
while (comp->nsList[j] != NULL)
j++;
}
comp->nsNr = j;
}
if (!xsltEvalXPathPredicate(ctxt, step->comp, comp->nsList,
comp->nsNr))
goto wrong_index;
@ -1618,7 +1616,7 @@ xsltCompilePattern(const xmlChar *pattern, xmlDocPtr doc,
xsltTransformContextPtr runtime) {
xsltParserContextPtr ctxt = NULL;
xsltCompMatchPtr element, first = NULL, previous = NULL;
int current, start, end, level;
int current, start, end, level, j;
if (pattern == NULL) {
xsltPrintErrorContext(NULL, NULL, node); /* TODO */
@ -1677,6 +1675,14 @@ xsltCompilePattern(const xmlChar *pattern, xmlDocPtr doc,
goto error;
ctxt->cur = &(ctxt->base)[current - start];
element->pattern = ctxt->base;
element->nsList = xmlGetNsList(doc, node);
j = 0;
if (element->nsList != NULL) {
while (element->nsList[j] != NULL)
j++;
}
element->nsNr = j;
#ifdef WITH_XSLT_DEBUG_PATTERN
xsltGenericDebug(xsltGenericDebugContext,

View File

@ -654,6 +654,13 @@ xsltCopyTree(xsltTransformContextPtr ctxt, xmlNodePtr node,
case XML_XINCLUDE_END:
return(NULL);
}
if (xmlStrEqual(node->name, (const xmlChar *) "fake node libxslt")) {
if (node->children != NULL)
copy = xsltCopyTreeList(ctxt, node->children, insert);
else
copy = NULL;
return(copy);
}
copy = xmlCopyNode(node, 0);
copy->doc = ctxt->output;
if (copy != NULL) {
@ -1009,6 +1016,16 @@ xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node,
xsltTemplatePtr template;
xmlNodePtr oldNode;
if (xmlStrEqual(node->name, BAD_CAST "fake node libxslt")) {
xmlNodePtr children;
children = node->children;
while (children != NULL) {
xsltProcessOneNode(ctxt, children, params);
children = children->next;
}
return;
}
template = xsltGetTemplate(ctxt, node, NULL);
/*
* If no template is found, apply the default rule.
@ -1951,6 +1968,9 @@ xsltCopy(xsltTransformContextPtr ctxt, xmlNodePtr node,
case XML_HTML_DOCUMENT_NODE:
break;
case XML_ELEMENT_NODE:
if (xmlStrEqual(node->name, BAD_CAST "fake node libxslt"))
return;
#ifdef WITH_XSLT_DEBUG_PROCESS
xsltGenericDebug(xsltGenericDebugContext,
"xsltCopy: node %s\n", node->name);
@ -2717,9 +2737,9 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
}
}
/* no break on purpose */
case XML_ELEMENT_NODE:
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
case XML_ELEMENT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_PI_NODE:
case XML_COMMENT_NODE:

View File

@ -359,7 +359,7 @@ xsltEvalVariable(xsltTransformContextPtr ctxt, xsltStackElemPtr elem,
xmlNodePtr oldInsert;
container = xmlNewDocNode(ctxt->document->doc, NULL,
(const xmlChar *) "fake", NULL);
(const xmlChar *) "fake node libxslt", NULL);
if (container == NULL)
return(NULL);
@ -485,7 +485,7 @@ xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt) {
xmlNodePtr oldInsert;
container = xmlNewDocNode(ctxt->document->doc, NULL,
(const xmlChar *) "fake", NULL);
(const xmlChar *) "fake node libxslt", NULL);
if (container == NULL)
return(NULL);

View File

@ -27,8 +27,6 @@ mylibs = \
$(top_builddir)/libxslt/libxslt.la \
$(top_builddir)/libexslt/libexslt.la
all: libxsltmod.so libxslt.py $(PYTHONSODV)
LDADD = -lxslt -lexslt
CFLAGS = -Wall -g
@ -39,9 +37,18 @@ libxsltmod_so_SOURCES =
libxsltmod_so_LDFLAGS = $(mylibs) $(LIBS) -shared -Wl,-soname,libxsltmod.so
noinst_LTLIBRARIES = libxsltmodule.la
libxsltmodule_la_SOURCES = libxslt.c types.c libxslt-py.c
libxsltmodule_la_SOURCES = $(srcdir)/libxslt.c $(srcdir)/types.c $(srcdir)/libxslt-py.c
libxsltmod.so: $(libxsltmodule_la_OBJECTS)
GENERATE = generator.py
API_DESC = $(top_srcdir)/doc/libxslt-api.xml $(srcdir)/libxslt-python-api.xml
GENERATED= $(srcdir)/libxsltclass.py \
$(srcdir)/libxslt-export.c \
$(srcdir)/libxslt-py.c \
$(srcdir)/libxslt-py.h
all: $(GENERATED) libxsltmod.so libxslt.py $(PYTHONSODV)
libxsltmod.so: $(libxsltmodule_la_OBJECTS) libxsltmodule.la
-(rm -f .libs/libxsltmod.so; \
$(LINK) -o $@ $(libxsltmodule_la_OBJECTS) $(libxsltmod_so_LDFLAGS);\
if [ -r .libs/libxsltmod.so ] ; then cp .libs/libxsltmod.so . ; fi)
@ -57,13 +64,6 @@ install-data-local:
-@(for doc in $(DOCS) ; \
do @INSTALL@ -m 0644 $$doc $(DESTDIR)$(DOCS_DIR) ; done)
GENERATE = generator.py
API_DESC = $(top_srcdir)/doc/libxslt-api.xml $(srcdir)/libxslt-python-api.xml
GENERATED= $(srcdir)/libxsltclass.py \
$(srcdir)/libxslt-export.c \
$(srcdir)/libxslt-py.c \
$(srcdir)/libxslt-py.h
$(GENERATED): $(srcdir)/$(GENERATE) $(API_DESC)
cd $(srcdir) && $(PYTHON) $(GENERATE)