mirror of
https://gitlab.gnome.org/GNOME/libxslt
synced 2025-11-08 11:02:18 +03:00
More general work, added for-each:
- test/Makefile.am test/REC*/Makefile.am: added first test - libxslt/pattern.c libxslt/transform.c libxslt/xslt.c: cleanup of nodes at reading of stylesheet, added support for xsl:for-each and fixed a few recursion bugs Daniel
This commit is contained in:
@@ -477,7 +477,7 @@ xsltParseStylesheetStripSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
|
||||
void
|
||||
xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
|
||||
xsltTemplatePtr ret;
|
||||
xmlNodePtr cur;
|
||||
xmlNodePtr cur, delete;
|
||||
xmlChar *prop;
|
||||
|
||||
if (template == NULL)
|
||||
@@ -539,6 +539,65 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Clean-up the template content from unwanted ignorable blank nodes
|
||||
* This content comes from the stylesheet
|
||||
* For stylesheets, the set of whitespace-preserving
|
||||
* element names consists of just xsl:text.
|
||||
*/
|
||||
cur = template->children;
|
||||
delete = NULL;
|
||||
while (cur != NULL) {
|
||||
if (delete != NULL) {
|
||||
#ifdef DEBUG_PARSING
|
||||
xsltGenericError(xsltGenericErrorContext,
|
||||
"xsltParseStylesheetTemplate: removing ignorable blank node\n");
|
||||
#endif
|
||||
xmlUnlinkNode(delete);
|
||||
xmlFreeNode(delete);
|
||||
delete = NULL;
|
||||
}
|
||||
if (IS_XSLT_ELEM(cur)) {
|
||||
if (IS_XSLT_NAME(cur, "text"))
|
||||
goto skip_children;
|
||||
} else if (cur->type == XML_TEXT_NODE) {
|
||||
if (IS_BLANK_NODE(cur)) {
|
||||
delete = cur;
|
||||
}
|
||||
} else if (cur->type != XML_ELEMENT_NODE) {
|
||||
delete = cur;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip to next node
|
||||
*/
|
||||
if (cur->children != NULL) {
|
||||
if (cur->children->type != XML_ENTITY_DECL) {
|
||||
cur = cur->children;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
skip_children:
|
||||
if (cur->next != NULL) {
|
||||
cur = cur->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
do {
|
||||
cur = cur->parent;
|
||||
if (cur == NULL)
|
||||
break;
|
||||
if (cur == template) {
|
||||
cur = NULL;
|
||||
break;
|
||||
}
|
||||
if (cur->next != NULL) {
|
||||
cur = cur->next;
|
||||
break;
|
||||
}
|
||||
} while (cur != NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find and handle the params
|
||||
*/
|
||||
@@ -726,22 +785,24 @@ xsltParseStylesheetDoc(xmlDocPtr doc) {
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
ret->doc = doc;
|
||||
if ((IS_XSLT_ELEM(cur)) && (IS_XSLT_NAME(cur, "stylesheet"))) {
|
||||
#ifdef DEBUG_PARSING
|
||||
xsltGenericError(xsltGenericErrorContext,
|
||||
"xsltParseStylesheetDoc : found stylesheet\n");
|
||||
#endif
|
||||
|
||||
xsltParseStylesheetTop(ret, cur);
|
||||
} else {
|
||||
|
||||
TODO /* lookup the stylesheet element down in the tree */
|
||||
/*
|
||||
* the document itself is the template.
|
||||
*/
|
||||
#ifdef DEBUG_PARSING
|
||||
xsltGenericError(xsltGenericErrorContext,
|
||||
"xsltParseStylesheetDoc : root is not stylesheet\n");
|
||||
xsltFreeStylesheet(ret);
|
||||
return(NULL);
|
||||
"xsltParseStylesheetDoc : document is stylesheet\n");
|
||||
#endif
|
||||
TODO
|
||||
}
|
||||
ret->doc = doc;
|
||||
|
||||
xsltParseStylesheetTop(ret, cur);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user