- should transforms for a given stylesheet be thread clean,
or can a stylesheet be enriched with document specific
informations and cleaned up later ?
- => currently stylesheet manipulation is not reentrant.
- seems that saving back XSLT stylesheet from a compiled form might
be a bit ugly ...
Pattern tester:
-> try to optimize for ID scan and tests.
+ -> also put fast lookup for "text()", "comment()", "node()"
+ based patterns lists.
Pattern scanner:
-> add error checks on all returns
-> handle unions
- -> compute priority
Error handling:
-> check the version stuff, design a separate module for error interfacing
level.
=> Done with a trick, text node name is different, requires > 2.2.11
+Pattern scanner:
+ -> compute priority
+ => done
continue;
if (!xmlStrEqual(step->value, node->name))
return(0);
- /* TODO: Handle namespace ... */
+
+ /* Namespace test */
+ if (node->ns == NULL) {
+ if (step->value2 != NULL)
+ return(0);
+ } else if (node->ns->href != NULL) {
+ if (step->value2 == NULL)
+ return(0);
+ if (!xmlStrEqual(step->value2, node->ns->href))
+ return(0);
+ }
continue;
case XSLT_OP_CHILD:
TODO /* Handle OP_CHILD */
continue;
if (!xmlStrEqual(step->value, node->name))
return(0);
- /* TODO: Handle namespace ... */
+
+ /* Namespace test */
+ if (node->ns == NULL) {
+ if (step->value2 != NULL)
+ return(0);
+ } else if (node->ns->href != NULL) {
+ if (step->value2 == NULL)
+ return(0);
+ if (!xmlStrEqual(step->value2, node->ns->href))
+ return(0);
+ }
continue;
case XSLT_OP_PARENT:
node = node->parent;
continue;
if (!xmlStrEqual(step->value, node->name))
return(0);
- /* TODO: Handle namespace ... */
+ /* Namespace test */
+ if (node->ns == NULL) {
+ if (step->value2 != NULL)
+ return(0);
+ } else if (node->ns->href != NULL) {
+ if (step->value2 == NULL)
+ return(0);
+ if (!xmlStrEqual(step->value2, node->ns->href))
+ return(0);
+ }
continue;
case XSLT_OP_ANCESTOR:
/* TODO: implement coalescing of ANCESTOR/NODE ops */
if (node == NULL)
return(0);
if (xmlStrEqual(step->value, node->name)) {
- /* TODO: Handle namespace ... */
- break;
+ /* Namespace test */
+ if (node->ns == NULL) {
+ if (step->value2 == NULL)
+ break;
+ } else if (node->ns->href != NULL) {
+ if ((step->value2 != NULL) &&
+ (xmlStrEqual(step->value2, node->ns->href)))
+ break;
+ }
}
}
if (node == NULL)
TODO /* Handle Keys, might be done differently */
break;
case XSLT_OP_NS:
- TODO /* Handle Namespace */
+ /* Namespace test */
+ if (node->ns == NULL) {
+ if (step->value != NULL)
+ return(0);
+ } else if (node->ns->href != NULL) {
+ if (step->value == NULL)
+ return(0);
+ if (!xmlStrEqual(step->value, node->ns->href))
+ return(0);
+ }
break;
case XSLT_OP_ALL:
- TODO /* Handle * */
+ switch (node->type) {
+ case XML_DOCUMENT_NODE:
+ case XML_HTML_DOCUMENT_NODE:
+ case XML_ELEMENT_NODE:
+ break;
+ default:
+ return(0);
+ }
break;
case XSLT_OP_PREDICATE:
TODO /* Handle Predicate */
break;
case XSLT_OP_PI:
- TODO /* Handle PI() */
+ if (node->type != XML_PI_NODE)
+ return(0);
+ if (step->value == NULL) {
+ if (!xmlStrEqual(step->value, node->name))
+ return(0);
+ }
break;
case XSLT_OP_COMMENT:
- TODO /* Handle Comments() */
+ if (node->type != XML_COMMENT_NODE)
+ return(0);
break;
case XSLT_OP_TEXT:
- TODO /* Handle Text() */
+ if ((node->type != XML_TEXT_NODE) &&
+ (node->type != XML_CDATA_SECTION_NODE))
+ return(0);
break;
case XSLT_OP_NODE:
- TODO /* Handle Node() */
+ switch (node->type) {
+ case XML_DOCUMENT_NODE:
+ case XML_HTML_DOCUMENT_NODE:
+ case XML_ELEMENT_NODE:
+ case XML_CDATA_SECTION_NODE:
+ case XML_PI_NODE:
+ case XML_COMMENT_NODE:
+ case XML_TEXT_NODE:
+ case XML_ATTRIBUTE_NODE:
+ break;
+ default:
+ return(0);
+ }
break;
}
}
}
NEXT;
PUSH(XSLT_OP_COMMENT, NULL, NULL);
- } else if (xmlStrEqual(name, (const xmlChar *)"comment")) {
+ } else if (xmlStrEqual(name, (const xmlChar *)"node")) {
NEXT;
SKIP_BLANKS;
if (CUR != ')') {
int
xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur) {
xsltCompMatchPtr pat, list;
- const xmlChar *name;
+ const xmlChar *name = NULL;
xmlChar *p, *pattern, tmp;
if ((style == NULL) || (cur == NULL))