diff --git a/ChangeLog b/ChangeLog index 4aaf0c7a..553c5a0f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed May 2 14:04:34 CEST 2001 Daniel Veillard + + * libxslt/transform.c libxslt/xslt.c: fixed xsl:text processing + there can be multiple text and CDATA child + Wed May 2 10:55:56 CEST 2001 Daniel Veillard * tests/multiple/makefile.am: fixing #54015 diff --git a/libxslt/transform.c b/libxslt/transform.c index 052adc38..5162157f 100644 --- a/libxslt/transform.c +++ b/libxslt/transform.c @@ -877,9 +877,13 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, if (IS_XSLT_ELEM(cur)) { xsltStylePreCompPtr info = (xsltStylePreCompPtr) cur->_private; if (info == NULL) { - xsltGenericError(xsltGenericDebugContext, - "xsltApplyOneTemplate: %s was not compiled\n", - cur->name); + if (IS_XSLT_NAME(cur, "message")) { + xsltMessage(ctxt, node, cur); + } else { + xsltGenericError(xsltGenericDebugContext, + "xsltApplyOneTemplate: %s was not compiled\n", + cur->name); + } goto skip_children; } @@ -1388,17 +1392,18 @@ xsltCopy(xsltTransformContextPtr ctxt, xmlNodePtr node, void xsltText(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr inst, xsltStylePreCompPtr comp) { - xmlNodePtr copy; + if ((inst->children != NULL) && (comp != NULL)) { + xmlNodePtr text = inst->children; + xmlNodePtr copy; - if (inst->children != NULL) { - if (((inst->children->type != XML_TEXT_NODE) && - (inst->children->type != XML_CDATA_SECTION_NODE)) || - (inst->children->next != NULL)) { - xsltGenericError(xsltGenericErrorContext, - "xslt:text has content problem !\n"); - } else { - xmlNodePtr text = inst->children; - + while (text != NULL) { + if (((text->type != XML_TEXT_NODE) && + (text->type != XML_CDATA_SECTION_NODE)) || + (text->next != NULL)) { + xsltGenericError(xsltGenericErrorContext, + "xslt:text content problem\n"); + break; + } copy = xmlNewDocText(ctxt->output, text->content); if (comp->noescape) { #ifdef WITH_XSLT_DEBUG_PARSING @@ -1408,6 +1413,7 @@ xsltText(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED, copy->name = xmlStringTextNoenc; } xmlAddChild(ctxt->insert, copy); + text = text->next; } } } diff --git a/libxslt/xslt.c b/libxslt/xslt.c index b181cdc7..ed33bde7 100644 --- a/libxslt/xslt.c +++ b/libxslt/xslt.c @@ -976,37 +976,55 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xsltTemplatePtr ret, if (IS_XSLT_ELEM(cur)) { if (IS_XSLT_NAME(cur, "text")) { if (cur->children != NULL) { - if (((cur->children->type != XML_TEXT_NODE) && - (cur->children->type != XML_CDATA_SECTION_NODE)) || - (cur->children->next != NULL)) { - xsltGenericError(xsltGenericErrorContext, - "xsltParseTemplateContent: xslt:text content problem\n"); - style->errors++; - } else { - xmlChar *prop; - xmlNodePtr text = cur->children; + xmlChar *prop; + xmlNodePtr text = cur->children, next; + int noesc = 0; - prop = xmlGetNsProp(cur, - (const xmlChar *)"disable-output-escaping", - XSLT_NAMESPACE); - if (prop != NULL) { + prop = xmlGetNsProp(cur, + (const xmlChar *)"disable-output-escaping", + XSLT_NAMESPACE); + if (prop != NULL) { #ifdef WITH_XSLT_DEBUG_PARSING - xsltGenericDebug(xsltGenericDebugContext, - "Disable escaping: %s\n", text->content); + xsltGenericDebug(xsltGenericDebugContext, + "Disable escaping: %s\n", text->content); #endif - if (xmlStrEqual(prop, (const xmlChar *)"yes")) { - text->name = xmlStringTextNoenc; - } else if (!xmlStrEqual(prop, - (const xmlChar *)"no")){ - xsltGenericError(xsltGenericErrorContext, - "xslt:text: disable-output-escaping allow only yes or no\n"); - style->warnings++; + if (xmlStrEqual(prop, (const xmlChar *)"yes")) { + noesc = 1; + } else if (!xmlStrEqual(prop, + (const xmlChar *)"no")){ + xsltGenericError(xsltGenericErrorContext, + "xslt:text: disable-output-escaping allow only yes or no\n"); + style->warnings++; - } - xmlFree(prop); } - xmlUnlinkNode(text); - xmlAddPrevSibling(cur, text); + xmlFree(prop); + } + + while (text != NULL) { + if (((text->type != XML_TEXT_NODE) && + (text->type != XML_CDATA_SECTION_NODE)) || + (text->next != NULL)) { + xsltGenericError(xsltGenericErrorContext, + "xsltParseTemplateContent: xslt:text content problem\n"); + style->errors++; + break; + } + if (noesc) + text->name = xmlStringTextNoenc; + text = text->next; + } + + /* + * replace xsl:text by the list of childs + */ + if (text == NULL) { + text = cur->children; + while (text != NULL) { + next = text->next; + xmlUnlinkNode(text); + xmlAddPrevSibling(cur, text); + text = next; + } } } delete = cur;