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>
* tests/multiple/makefile.am: fixing #54015

View File

@@ -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) {
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;
if ((inst->children != NULL) && (comp != NULL)) {
xmlNodePtr text = inst->children;
xmlNodePtr copy;
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;
}
}
}

View File

@@ -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;