1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-11-08 11:02:18 +03:00

- libxslt/transform.c libxslt/xslt.c: fixed xsl:text processing

there can be multiple text and CDATA child
Daniel
This commit is contained in:
Daniel Veillard
2001-05-02 12:05:43 +00:00
parent 3b126325ee
commit a99c85235d
3 changed files with 68 additions and 39 deletions

View File

@@ -1,3 +1,8 @@
Wed May 2 14:04:34 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* 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 <Daniel.Veillard@imag.fr> Wed May 2 10:55:56 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* tests/multiple/makefile.am: fixing #54015 * tests/multiple/makefile.am: fixing #54015

View File

@@ -877,9 +877,13 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
if (IS_XSLT_ELEM(cur)) { if (IS_XSLT_ELEM(cur)) {
xsltStylePreCompPtr info = (xsltStylePreCompPtr) cur->_private; xsltStylePreCompPtr info = (xsltStylePreCompPtr) cur->_private;
if (info == NULL) { if (info == NULL) {
xsltGenericError(xsltGenericDebugContext, if (IS_XSLT_NAME(cur, "message")) {
"xsltApplyOneTemplate: %s was not compiled\n", xsltMessage(ctxt, node, cur);
cur->name); } else {
xsltGenericError(xsltGenericDebugContext,
"xsltApplyOneTemplate: %s was not compiled\n",
cur->name);
}
goto skip_children; goto skip_children;
} }
@@ -1388,17 +1392,18 @@ xsltCopy(xsltTransformContextPtr ctxt, xmlNodePtr node,
void void
xsltText(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED, xsltText(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED,
xmlNodePtr inst, xsltStylePreCompPtr comp) { xmlNodePtr inst, xsltStylePreCompPtr comp) {
xmlNodePtr copy; if ((inst->children != NULL) && (comp != NULL)) {
xmlNodePtr text = inst->children;
if (inst->children != NULL) { xmlNodePtr copy;
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); copy = xmlNewDocText(ctxt->output, text->content);
if (comp->noescape) { if (comp->noescape) {
#ifdef WITH_XSLT_DEBUG_PARSING #ifdef WITH_XSLT_DEBUG_PARSING
@@ -1408,6 +1413,7 @@ xsltText(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED,
copy->name = xmlStringTextNoenc; copy->name = xmlStringTextNoenc;
} }
xmlAddChild(ctxt->insert, copy); xmlAddChild(ctxt->insert, copy);
text = text->next;
} }
} }
} }

View File

@@ -976,37 +976,55 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xsltTemplatePtr ret,
if (IS_XSLT_ELEM(cur)) { if (IS_XSLT_ELEM(cur)) {
if (IS_XSLT_NAME(cur, "text")) { if (IS_XSLT_NAME(cur, "text")) {
if (cur->children != NULL) { if (cur->children != NULL) {
if (((cur->children->type != XML_TEXT_NODE) && xmlChar *prop;
(cur->children->type != XML_CDATA_SECTION_NODE)) || xmlNodePtr text = cur->children, next;
(cur->children->next != NULL)) { int noesc = 0;
xsltGenericError(xsltGenericErrorContext,
"xsltParseTemplateContent: xslt:text content problem\n");
style->errors++;
} else {
xmlChar *prop;
xmlNodePtr text = cur->children;
prop = xmlGetNsProp(cur, prop = xmlGetNsProp(cur,
(const xmlChar *)"disable-output-escaping", (const xmlChar *)"disable-output-escaping",
XSLT_NAMESPACE); XSLT_NAMESPACE);
if (prop != NULL) { if (prop != NULL) {
#ifdef WITH_XSLT_DEBUG_PARSING #ifdef WITH_XSLT_DEBUG_PARSING
xsltGenericDebug(xsltGenericDebugContext, xsltGenericDebug(xsltGenericDebugContext,
"Disable escaping: %s\n", text->content); "Disable escaping: %s\n", text->content);
#endif #endif
if (xmlStrEqual(prop, (const xmlChar *)"yes")) { if (xmlStrEqual(prop, (const xmlChar *)"yes")) {
text->name = xmlStringTextNoenc; noesc = 1;
} else if (!xmlStrEqual(prop, } else if (!xmlStrEqual(prop,
(const xmlChar *)"no")){ (const xmlChar *)"no")){
xsltGenericError(xsltGenericErrorContext, xsltGenericError(xsltGenericErrorContext,
"xslt:text: disable-output-escaping allow only yes or no\n"); "xslt:text: disable-output-escaping allow only yes or no\n");
style->warnings++; style->warnings++;
}
xmlFree(prop);
} }
xmlUnlinkNode(text); xmlFree(prop);
xmlAddPrevSibling(cur, text); }
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; delete = cur;