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:
@@ -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
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
if (IS_XSLT_NAME(cur, "message")) {
|
||||||
|
xsltMessage(ctxt, node, cur);
|
||||||
|
} else {
|
||||||
xsltGenericError(xsltGenericDebugContext,
|
xsltGenericError(xsltGenericDebugContext,
|
||||||
"xsltApplyOneTemplate: %s was not compiled\n",
|
"xsltApplyOneTemplate: %s was not compiled\n",
|
||||||
cur->name);
|
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) {
|
||||||
|
if ((inst->children != NULL) && (comp != NULL)) {
|
||||||
|
xmlNodePtr text = inst->children;
|
||||||
xmlNodePtr copy;
|
xmlNodePtr copy;
|
||||||
|
|
||||||
if (inst->children != NULL) {
|
while (text != NULL) {
|
||||||
if (((inst->children->type != XML_TEXT_NODE) &&
|
if (((text->type != XML_TEXT_NODE) &&
|
||||||
(inst->children->type != XML_CDATA_SECTION_NODE)) ||
|
(text->type != XML_CDATA_SECTION_NODE)) ||
|
||||||
(inst->children->next != NULL)) {
|
(text->next != NULL)) {
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericError(xsltGenericErrorContext,
|
||||||
"xslt:text has content problem !\n");
|
"xslt:text content problem\n");
|
||||||
} else {
|
break;
|
||||||
xmlNodePtr text = inst->children;
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -976,15 +976,9 @@ 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) &&
|
|
||||||
(cur->children->type != XML_CDATA_SECTION_NODE)) ||
|
|
||||||
(cur->children->next != NULL)) {
|
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
|
||||||
"xsltParseTemplateContent: xslt:text content problem\n");
|
|
||||||
style->errors++;
|
|
||||||
} else {
|
|
||||||
xmlChar *prop;
|
xmlChar *prop;
|
||||||
xmlNodePtr text = cur->children;
|
xmlNodePtr text = cur->children, next;
|
||||||
|
int noesc = 0;
|
||||||
|
|
||||||
prop = xmlGetNsProp(cur,
|
prop = xmlGetNsProp(cur,
|
||||||
(const xmlChar *)"disable-output-escaping",
|
(const xmlChar *)"disable-output-escaping",
|
||||||
@@ -995,7 +989,7 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xsltTemplatePtr ret,
|
|||||||
"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,
|
||||||
@@ -1005,8 +999,32 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xsltTemplatePtr ret,
|
|||||||
}
|
}
|
||||||
xmlFree(prop);
|
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);
|
xmlUnlinkNode(text);
|
||||||
xmlAddPrevSibling(cur, text);
|
xmlAddPrevSibling(cur, text);
|
||||||
|
text = next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete = cur;
|
delete = cur;
|
||||||
|
|||||||
Reference in New Issue
Block a user