summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2001-04-16 14:10:45 +0000
committerDaniel Veillard <veillard@src.gnome.org>2001-04-16 14:10:45 +0000
commitbdcd6346ff23d5c1cfe23be8b6bda0917ef1aa2f (patch)
tree3e3aade77a04f7c394f415402424184f887b469c
parentc17245fdb0906cd24c7e7830b172f746fd75be12 (diff)
downloadlibxslt-bdcd6346ff23d5c1cfe23be8b6bda0917ef1aa2f.tar.gz
libxslt-bdcd6346ff23d5c1cfe23be8b6bda0917ef1aa2f.tar.bz2
libxslt-bdcd6346ff23d5c1cfe23be8b6bda0917ef1aa2f.zip
- libxslt/keys.c libxslt/preproc.c libxslt/templates.c
libxslt/transform.c libxslt/variables.c libxslt/xsltInternals.h: fixed for the most part the namespace handling problem in XPath expression computations. - test/doc/ tests/general: added bug 5 and 6 Daniel
-rw-r--r--ChangeLog8
-rw-r--r--TODO27
-rw-r--r--libxslt/keys.c5
-rw-r--r--libxslt/preproc.c19
-rw-r--r--libxslt/templates.c6
-rw-r--r--libxslt/transform.c16
-rw-r--r--libxslt/variables.c5
-rw-r--r--libxslt/xsltInternals.h2
-rw-r--r--tests/XSLTMark/summarize.out6
-rw-r--r--tests/docs/bug-5-.xml475
-rw-r--r--tests/docs/bug-6-.xml6
-rw-r--r--tests/general/bug-5-.out126
-rw-r--r--tests/general/bug-5-.xsl158
-rw-r--r--tests/general/bug-6-.out4
-rw-r--r--tests/general/bug-6-.xsl31
15 files changed, 877 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index af7cdcb1..20d7c814 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Tue Apr 17 10:10:56 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+ * libxslt/keys.c libxslt/preproc.c libxslt/templates.c
+ libxslt/transform.c libxslt/variables.c libxslt/xsltInternals.h:
+ fixed for the most part the namespace handling problem in XPath
+ expression computations.
+ * test/doc/ tests/general: added bug 5 and 6
+
Thu Apr 12 14:40:22 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* libxslt/xslt.c: applied William M. Brack patch fixing the
diff --git a/TODO b/TODO
index 25883ca1..8c4dfcf6 100644
--- a/TODO
+++ b/TODO
@@ -4,10 +4,6 @@
* *
********
-Leak:
- - find and fix memleak in xmlspec
- => this is new ...
-
Doc:
- manpage and doc for xsltproc
@@ -19,17 +15,14 @@ Design:
be a bit ugly ...
Embedding Stylesheets:
- - example in 2.7 would force to validate
+ - example in 2.7 would force to validate, we do it by default now
Import:
-Extra functions:
- -> document() should not be a problem since Result Tree Fragments are
- implemented
- => started, incomplete
ID and Key support:
- -> Id should be simple, key will probably requires some hash tables.
+ -> done but namespace support in keys is not defined
+ -> make sure keys are recomputed on new document input
Pattern tester:
-> try to optimize for ID scan and tests.
@@ -44,7 +37,8 @@ Error handling:
-> catch recursion end of 5.4 ...
Support Attribute value templates:
- -> optimization by checking their existence at stylesheet parse time.
+ -> namespace support for attribute value templates is not done, need
+ a small API redesign
Sorting:
-> add support for imbricated sorts
@@ -57,6 +51,14 @@ Sorting:
* *
********
+ID and Key support:
+ -> Done
+
+Extra functions:
+ -> document() should not be a problem since Result Tree Fragments are
+ implemented
+ => Done
+
Templates:
-> check the built-in template rule for attributes
-> make sure @xxx matches are applied
@@ -83,6 +85,9 @@ Support Attribute value templates:
to handle most of it at the stylesheet parse time ...
=> Done for the most part need to check all attributes in XSLT constructs
using them and use the dedicated readin function.
+ -> optimization by checking their existence at stylesheet parse time.
+ => done when building the preproc function
+
Separate util module:
-> macros, config, verbosity ?
diff --git a/libxslt/keys.c b/libxslt/keys.c
index f7ce9233..0fd61f54 100644
--- a/libxslt/keys.c
+++ b/libxslt/keys.c
@@ -316,9 +316,12 @@ xsltInitCtxtKey(xsltTransformContextPtr ctxt, xsltDocumentPtr doc,
if (comp == NULL)
goto error;
ctxt->document = doc;
- ctxt->node = (xmlNodePtr) doc->doc;
ctxt->xpathCtxt->node = (xmlNodePtr) doc->doc;
position = ctxt->xpathCtxt->proximityPosition;
+ ctxt->node = (xmlNodePtr) doc->doc;
+ /* TODO : clarify the use of namespaces in keys evaluation */
+ ctxt->xpathCtxt->namespaces = NULL;
+ ctxt->xpathCtxt->nsNr = 0;
res = xmlXPathCompiledEval(comp, ctxt->xpathCtxt);
ctxt->xpathCtxt->proximityPosition = position;
xmlXPathFreeCompExpr(comp);
diff --git a/libxslt/preproc.c b/libxslt/preproc.c
index 4f2f9f6d..e0f08cb7 100644
--- a/libxslt/preproc.c
+++ b/libxslt/preproc.c
@@ -160,6 +160,8 @@ xsltFreeStylePreComp(xsltStylePreCompPtr comp) {
xmlFree(comp->numdata.format);
if (comp->comp != NULL)
xmlXPathFreeCompExpr(comp->comp);
+ if (comp->nsList != NULL)
+ xmlFree(comp->nsList);
memset(comp, -1, sizeof(xsltStylePreComp));
@@ -921,6 +923,8 @@ xsltStylePreCompute(xsltTransformContextPtr ctxt, xmlNodePtr inst) {
if (inst->_private != NULL)
return;
if (IS_XSLT_ELEM(inst)) {
+ xsltStylePreCompPtr cur;
+
if (IS_XSLT_NAME(inst, "apply-templates")) {
xsltApplyTemplatesComp(ctxt, inst);
} else if (IS_XSLT_NAME(inst, "value-of")) {
@@ -968,6 +972,21 @@ xsltStylePreCompute(xsltTransformContextPtr ctxt, xmlNodePtr inst) {
xsltGenericError(xsltGenericDebugContext,
"xsltStylePreCompute: unknown xslt:%s\n", inst->name);
}
+ /*
+ * Add the namespace lookup here, this code can be shared by
+ * all precomputations.
+ */
+ cur = inst->_private;
+ if (cur != NULL) {
+ int i = 0;
+
+ cur->nsList = xmlGetNsList(inst->doc, inst);
+ if (cur->nsList != NULL) {
+ while (cur->nsList[i] != NULL)
+ i++;
+ }
+ cur->nsNr = i;
+ }
} else {
if (IS_XSLT_NAME(inst, "document")) {
xsltDocumentComp(ctxt, inst);
diff --git a/libxslt/templates.c b/libxslt/templates.c
index b038ae73..96a54fa7 100644
--- a/libxslt/templates.c
+++ b/libxslt/templates.c
@@ -54,6 +54,9 @@ xsltEvalXPathPredicate(xsltTransformContextPtr ctxt,
position = ctxt->xpathCtxt->proximityPosition;
ctxt->xpathCtxt->node = ctxt->node;
+ /* TODO: do we need to propagate the namespaces here ? */
+ ctxt->xpathCtxt->namespaces = NULL;
+ ctxt->xpathCtxt->nsNr = 0;
res = xmlXPathCompiledEval(comp, ctxt->xpathCtxt);
ctxt->xpathCtxt->proximityPosition = position;
if (res != NULL) {
@@ -89,6 +92,9 @@ xsltEvalXPathString(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp) {
xmlXPathObjectPtr res;
ctxt->xpathCtxt->node = ctxt->node;
+ /* TODO: do we need to propagate the namespaces here ? */
+ ctxt->xpathCtxt->namespaces = NULL;
+ ctxt->xpathCtxt->nsNr = 0;
res = xmlXPathCompiledEval(comp, ctxt->xpathCtxt);
if (res != NULL) {
if (res->type != XPATH_STRING)
diff --git a/libxslt/transform.c b/libxslt/transform.c
index fabfc45a..60f319c0 100644
--- a/libxslt/transform.c
+++ b/libxslt/transform.c
@@ -1224,6 +1224,8 @@ xsltSort(xsltTransformContextPtr ctxt, xmlNodePtr node,
ctxt->xpathCtxt->proximityPosition = i + 1;
ctxt->node = list->nodeTab[i];
ctxt->xpathCtxt->node = ctxt->node;
+ ctxt->xpathCtxt->namespaces = comp->nsList;
+ ctxt->xpathCtxt->nsNr = comp->nsNr;
res = xmlXPathCompiledEval(comp->comp, ctxt->xpathCtxt);
if (res != NULL) {
if (res->type != XPATH_STRING)
@@ -1740,6 +1742,8 @@ xsltCopyOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
oldProximityPosition = ctxt->xpathCtxt->proximityPosition;
oldContextSize = ctxt->xpathCtxt->contextSize;
ctxt->xpathCtxt->node = node;
+ ctxt->xpathCtxt->namespaces = comp->nsList;
+ ctxt->xpathCtxt->nsNr = comp->nsNr;
res = xmlXPathCompiledEval(comp->comp, ctxt->xpathCtxt);
ctxt->xpathCtxt->proximityPosition = oldProximityPosition;
ctxt->xpathCtxt->contextSize = oldContextSize;
@@ -1833,6 +1837,8 @@ xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
oldProximityPosition = ctxt->xpathCtxt->proximityPosition;
oldContextSize = ctxt->xpathCtxt->contextSize;
ctxt->xpathCtxt->node = node;
+ ctxt->xpathCtxt->namespaces = comp->nsList;
+ ctxt->xpathCtxt->nsNr = comp->nsNr;
res = xmlXPathCompiledEval(comp->comp, ctxt->xpathCtxt);
ctxt->xpathCtxt->proximityPosition = oldProximityPosition;
ctxt->xpathCtxt->contextSize = oldContextSize;
@@ -2032,6 +2038,8 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
oldProximityPosition = ctxt->xpathCtxt->proximityPosition;
oldContextSize = ctxt->xpathCtxt->contextSize;
ctxt->xpathCtxt->node = node;
+ ctxt->xpathCtxt->namespaces = comp->nsList;
+ ctxt->xpathCtxt->nsNr = comp->nsNr;
res = xmlXPathCompiledEval(comp->comp, ctxt->xpathCtxt);
ctxt->xpathCtxt->contextSize = oldContextSize;
ctxt->xpathCtxt->proximityPosition = oldProximityPosition;
@@ -2241,6 +2249,8 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node,
oldProximityPosition = ctxt->xpathCtxt->proximityPosition;
oldContextSize = ctxt->xpathCtxt->contextSize;
ctxt->xpathCtxt->node = node;
+ ctxt->xpathCtxt->namespaces = comp->nsList;
+ ctxt->xpathCtxt->nsNr = comp->nsNr;
res = xmlXPathCompiledEval(xpathComp, ctxt->xpathCtxt);
xmlXPathFreeCompExpr(xpathComp);
ctxt->xpathCtxt->proximityPosition = oldProximityPosition;
@@ -2340,6 +2350,8 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr node,
oldContextSize = ctxt->xpathCtxt->contextSize;
oldProximityPosition = ctxt->xpathCtxt->proximityPosition;
ctxt->xpathCtxt->node = node;
+ ctxt->xpathCtxt->namespaces = comp->nsList;
+ ctxt->xpathCtxt->nsNr = comp->nsNr;
res = xmlXPathCompiledEval(comp->comp, ctxt->xpathCtxt);
ctxt->xpathCtxt->contextSize = oldContextSize;
ctxt->xpathCtxt->proximityPosition = oldProximityPosition;
@@ -2411,9 +2423,11 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr node,
"xsltForEach: select %s\n", comp->select);
#endif
- ctxt->xpathCtxt->node = node;
oldProximityPosition = ctxt->xpathCtxt->proximityPosition;
oldContextSize = ctxt->xpathCtxt->contextSize;
+ ctxt->xpathCtxt->node = node;
+ ctxt->xpathCtxt->namespaces = comp->nsList;
+ ctxt->xpathCtxt->nsNr = comp->nsNr;
res = xmlXPathCompiledEval(comp->comp, ctxt->xpathCtxt);
ctxt->xpathCtxt->contextSize = oldContextSize;
ctxt->xpathCtxt->proximityPosition = oldProximityPosition;
diff --git a/libxslt/variables.c b/libxslt/variables.c
index 172de6ec..1e5c9e31 100644
--- a/libxslt/variables.c
+++ b/libxslt/variables.c
@@ -259,9 +259,12 @@ int oldProximityPosition, oldContextSize;
comp = xmlXPathCompile(elem->select);
if (comp == NULL)
return(-1);
- ctxt->xpathCtxt->node = (xmlNodePtr) ctxt->node;
oldProximityPosition = ctxt->xpathCtxt->proximityPosition;
oldContextSize = ctxt->xpathCtxt->contextSize;
+ ctxt->xpathCtxt->node = (xmlNodePtr) ctxt->node;
+ /* TODO: do we need to propagate the namespaces here ? */
+ ctxt->xpathCtxt->namespaces = NULL;
+ ctxt->xpathCtxt->nsNr = 0;
result = xmlXPathCompiledEval(comp, ctxt->xpathCtxt);
ctxt->xpathCtxt->contextSize = oldContextSize;
ctxt->xpathCtxt->proximityPosition = oldProximityPosition;
diff --git a/libxslt/xsltInternals.h b/libxslt/xsltInternals.h
index 46035a3f..bc730c08 100644
--- a/libxslt/xsltInternals.h
+++ b/libxslt/xsltInternals.h
@@ -260,6 +260,8 @@ struct _xsltStylePreComp {
xsltNumberData numdata; /* number */
xmlXPathCompExprPtr comp; /* a precompiled XPath expression */
+ xmlNsPtr *nsList; /* the namespaces in scope */
+ int nsNr; /* the number of namespaces in scope */
};
/*
diff --git a/tests/XSLTMark/summarize.out b/tests/XSLTMark/summarize.out
index 52bce4c1..cb6e2aab 100644
--- a/tests/XSLTMark/summarize.out
+++ b/tests/XSLTMark/summarize.out
@@ -3,7 +3,7 @@
100 elements,
137 text nodes,
131 attributes.
- </total><analysis><description>Recognized as xslt stylesheet:</description><stats>0 templates,
- 0 variables,
- 0 value-of's,
+ </total><analysis><description>Recognized as xslt stylesheet:</description><stats>7 templates,
+ 1 variables,
+ 2 value-of's,
</stats></analysis></summary>
diff --git a/tests/docs/bug-5-.xml b/tests/docs/bug-5-.xml
new file mode 100644
index 00000000..f5a34ecd
--- /dev/null
+++ b/tests/docs/bug-5-.xml
@@ -0,0 +1,475 @@
+<?xml version="1.0"?>
+<XMLDATA>
+<RUNDATE>Wed Apr 4 23:00:55 2001 GMT</RUNDATE>
+<GROUP type="PRODUCT" name="Apple">
+<GROUP type="ACTION" name="PICK">
+<GROUP type="REC" name="Non-Recurring">
+<ROW>
+<NUM>1</NUM>
+<PRODUCT>Apple</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Birch</SEGMENT>
+<PREV>0</PREV>
+<AREV>50</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+<GROUP type="ACTION" name="EAT">
+<GROUP type="REC" name="Non-Recurring">
+<ROW>
+<NUM>6</NUM>
+<PRODUCT>Apple</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Pine</SEGMENT>
+<PREV>0</PREV>
+<AREV>0</AREV>
+<ACTION>EAT</ACTION>
+</ROW>
+<ROW>
+<NUM>60</NUM>
+<PRODUCT>Apple</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Elm</SEGMENT>
+<PREV>0</PREV>
+<AREV>0</AREV>
+<ACTION>EAT</ACTION>
+</ROW>
+<ROW>
+<NUM>2</NUM>
+<PRODUCT>Apple</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Birch</SEGMENT>
+<PREV>0</PREV>
+<AREV>0</AREV>
+<ACTION>EAT</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+<GROUP type="ACTION" name="SQUEEZE">
+<GROUP type="REC" name="Recurring">
+<ROW>
+<NUM>7</NUM>
+<PRODUCT>Apple</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Pine</SEGMENT>
+<PREV>19250</PREV>
+<AREV>16.61</AREV>
+<ACTION>SQUEEZE</ACTION>
+</ROW>
+<ROW>
+<NUM>96</NUM>
+<PRODUCT>Apple</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Elm</SEGMENT>
+<PREV>220000</PREV>
+<AREV>11.76</AREV>
+<ACTION>SQUEEZE</ACTION>
+</ROW>
+<ROW>
+<NUM>6</NUM>
+<PRODUCT>Apple</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Birch</SEGMENT>
+<PREV>16500</PREV>
+<AREV>7.16</AREV>
+<ACTION>SQUEEZE</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+</GROUP>
+<GROUP type="PRODUCT" name="Orange">
+<GROUP type="ACTION" name="PICK">
+<GROUP type="REC" name="Non-Recurring">
+<ROW>
+<NUM>34</NUM>
+<PRODUCT>Orange</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Pine</SEGMENT>
+<PREV>0</PREV>
+<AREV>1420</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+<ROW>
+<NUM>1</NUM>
+<PRODUCT>Orange</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Almond</SEGMENT>
+<PREV>0</PREV>
+<AREV>25</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+<ROW>
+<NUM>8</NUM>
+<PRODUCT>Orange</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Birch</SEGMENT>
+<PREV>0</PREV>
+<AREV>300</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+<ROW>
+<NUM>186</NUM>
+<PRODUCT>Orange</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Elm</SEGMENT>
+<PREV>0</PREV>
+<AREV>6555</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+</GROUP>
+<GROUP type="REC" name="Recurring">
+<ROW>
+<NUM>36</NUM>
+<PRODUCT>Orange</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Pine</SEGMENT>
+<PREV>171000</PREV>
+<AREV>221.3</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+<ROW>
+<NUM>240</NUM>
+<PRODUCT>Orange</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Elm</SEGMENT>
+<PREV>950000</PREV>
+<AREV>1412.34</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+<ROW>
+<NUM>8</NUM>
+<PRODUCT>Orange</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Birch</SEGMENT>
+<PREV>38000</PREV>
+<AREV>30.84</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+<GROUP type="ACTION" name="EAT">
+<GROUP type="REC" name="Non-Recurring">
+<ROW>
+<NUM>34</NUM>
+<PRODUCT>Orange</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Pine</SEGMENT>
+<PREV>0</PREV>
+<AREV>0</AREV>
+<ACTION>EAT</ACTION>
+</ROW>
+<ROW>
+<NUM>1</NUM>
+<PRODUCT>Orange</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Almond</SEGMENT>
+<PREV>0</PREV>
+<AREV>0</AREV>
+<ACTION>EAT</ACTION>
+</ROW>
+<ROW>
+<NUM>62</NUM>
+<PRODUCT>Orange</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Elm</SEGMENT>
+<PREV>0</PREV>
+<AREV>0</AREV>
+<ACTION>EAT</ACTION>
+</ROW>
+<ROW>
+<NUM>4</NUM>
+<PRODUCT>Orange</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Birch</SEGMENT>
+<PREV>0</PREV>
+<AREV>0</AREV>
+<ACTION>EAT</ACTION>
+</ROW>
+</GROUP>
+<GROUP type="REC" name="Recurring">
+<ROW>
+<NUM>8</NUM>
+<PRODUCT>Orange</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Birch</SEGMENT>
+<PREV>0</PREV>
+<AREV>0</AREV>
+<ACTION>EAT</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+<GROUP type="ACTION" name="SQUEEZE">
+<GROUP type="REC" name="Recurring">
+<ROW>
+<NUM>36</NUM>
+<PRODUCT>Orange</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Pine</SEGMENT>
+<PREV>171000</PREV>
+<AREV>221.3</AREV>
+<ACTION>SQUEEZE</ACTION>
+</ROW>
+<ROW>
+<NUM>80</NUM>
+<PRODUCT>Orange</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Elm</SEGMENT>
+<PREV>380000</PREV>
+<AREV>470.78</AREV>
+<ACTION>SQUEEZE</ACTION>
+</ROW>
+<ROW>
+<NUM>4</NUM>
+<PRODUCT>Orange</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Birch</SEGMENT>
+<PREV>19000</PREV>
+<AREV>15.42</AREV>
+<ACTION>SQUEEZE</ACTION>
+</ROW>
+<ROW>
+<NUM>3</NUM>
+<PRODUCT>Orange</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Almond</SEGMENT>
+<PREV>14250</PREV>
+<AREV>23.25</AREV>
+<ACTION>SQUEEZE</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+</GROUP>
+<GROUP type="PRODUCT" name="Banana">
+<GROUP type="ACTION" name="PICK">
+<GROUP type="REC" name="Non-Recurring">
+<ROW>
+<NUM>2</NUM>
+<PRODUCT>Banana</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Elm</SEGMENT>
+<PREV>0</PREV>
+<AREV>100</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+</GROUP>
+<GROUP type="REC" name="Recurring">
+<ROW>
+<NUM>1</NUM>
+<PRODUCT>Banana</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Pine</SEGMENT>
+<PREV>12250</PREV>
+<AREV>12.25</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+<ROW>
+<NUM>6</NUM>
+<PRODUCT>Banana</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Elm</SEGMENT>
+<PREV>73500</PREV>
+<AREV>78.4</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+<ROW>
+<NUM>1</NUM>
+<PRODUCT>Banana</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Almond</SEGMENT>
+<PREV>12250</PREV>
+<AREV>12.25</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+<GROUP type="ACTION" name="EAT">
+<GROUP type="REC" name="Recurring">
+<ROW>
+<NUM>1</NUM>
+<PRODUCT>Banana</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Almond</SEGMENT>
+<PREV>12250</PREV>
+<AREV>0</AREV>
+<ACTION>EAT</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+</GROUP>
+<GROUP type="PRODUCT" name="Nectarine">
+<GROUP type="ACTION" name="SQUEEZE">
+<GROUP type="REC" name="Recurring">
+<ROW>
+<NUM>1</NUM>
+<PRODUCT>Nectarine</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Pine</SEGMENT>
+<PREV>5950</PREV>
+<AREV>-5.95</AREV>
+<ACTION>SQUEEZE</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+</GROUP>
+<GROUP type="PRODUCT" name="Pineapple">
+<GROUP type="ACTION" name="PICK">
+<GROUP type="REC" name="Non-Recurring">
+<ROW>
+<NUM>1</NUM>
+<PRODUCT>Pineapple</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Pine</SEGMENT>
+<PREV>0</PREV>
+<AREV>50</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+</GROUP>
+<GROUP type="REC" name="Recurring">
+<ROW>
+<NUM>2</NUM>
+<PRODUCT>Pineapple</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Pine</SEGMENT>
+<PREV>17500</PREV>
+<AREV>8.75</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+<ROW>
+<NUM>1</NUM>
+<PRODUCT>Pineapple</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Birch</SEGMENT>
+<PREV>6250</PREV>
+<AREV>10</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+<GROUP type="ACTION" name="EAT">
+<GROUP type="REC" name="Non-Recurring">
+<ROW>
+<NUM>1</NUM>
+<PRODUCT>Pineapple</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Elm</SEGMENT>
+<PREV>0</PREV>
+<AREV>0</AREV>
+<ACTION>EAT</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+<GROUP type="ACTION" name="SQUEEZE">
+<GROUP type="REC" name="Recurring">
+<ROW>
+<NUM>2</NUM>
+<PRODUCT>Pineapple</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Elm</SEGMENT>
+<PREV>12500</PREV>
+<AREV>4.38</AREV>
+<ACTION>SQUEEZE</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+</GROUP>
+<GROUP type="PRODUCT" name="Coconut">
+<GROUP type="ACTION" name="PICK">
+<GROUP type="REC" name="Recurring">
+<ROW>
+<NUM>1</NUM>
+<PRODUCT>Coconut</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Elm</SEGMENT>
+<PREV>13750</PREV>
+<AREV>17.87</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+</GROUP>
+<GROUP type="PRODUCT" name="Guava">
+<GROUP type="ACTION" name="SQUEEZE">
+<GROUP type="REC" name="Recurring">
+<ROW>
+<NUM>1</NUM>
+<PRODUCT>Guava</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Pine</SEGMENT>
+<PREV>14995</PREV>
+<AREV>-19.49</AREV>
+<ACTION>SQUEEZE</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+</GROUP>
+<GROUP type="PRODUCT" name="Pear">
+<GROUP type="ACTION" name="PICK">
+<GROUP type="REC" name="Recurring">
+<ROW>
+<NUM>1</NUM>
+<PRODUCT>Pear</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Pine</SEGMENT>
+<PREV>29995</PREV>
+<AREV>38.99</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+</GROUP>
+<GROUP type="PRODUCT" name="Raisin">
+<GROUP type="ACTION" name="EAT">
+<GROUP type="REC" name="Non-Recurring">
+<ROW>
+<NUM>17</NUM>
+<PRODUCT>Raisin</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Oak</SEGMENT>
+<PREV>0</PREV>
+<AREV>0</AREV>
+<ACTION>EAT</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+<GROUP type="ACTION" name="SQUEEZE">
+<GROUP type="REC" name="Recurring">
+<ROW>
+<NUM>15</NUM>
+<PRODUCT>Raisin</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Oak</SEGMENT>
+<PREV>299925</PREV>
+<AREV>227.95</AREV>
+<ACTION>SQUEEZE</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+</GROUP>
+<GROUP type="PRODUCT" name="Fig">
+<GROUP type="ACTION" name="PICK">
+<GROUP type="REC" name="Non-Recurring">
+<ROW>
+<NUM>1</NUM>
+<PRODUCT>Fig</PRODUCT>
+<REC>Non-Recurring</REC>
+<SEGMENT>Oak</SEGMENT>
+<PREV>0</PREV>
+<AREV>50</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+</GROUP>
+<GROUP type="REC" name="Recurring">
+<ROW>
+<NUM>2</NUM>
+<PRODUCT>Fig</PRODUCT>
+<REC>Recurring</REC>
+<SEGMENT>Oak</SEGMENT>
+<PREV>74990</PREV>
+<AREV>86.24</AREV>
+<ACTION>PICK</ACTION>
+</ROW>
+</GROUP>
+</GROUP>
+</GROUP>
+</XMLDATA>
diff --git a/tests/docs/bug-6-.xml b/tests/docs/bug-6-.xml
new file mode 100644
index 00000000..e0222812
--- /dev/null
+++ b/tests/docs/bug-6-.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+
+<document xmlns="http://my/namespace">
+ <name>Title of my document</name>
+</document>
+
diff --git a/tests/general/bug-5-.out b/tests/general/bug-5-.out
new file mode 100644
index 00000000..b6dd1255
--- /dev/null
+++ b/tests/general/bug-5-.out
@@ -0,0 +1,126 @@
+<?xml version="1.0"?>
+<html><head><title>Churn by Product</title><style type="text/css"> .PROD {background-color:cyan}
+ .PROD * {background-color:cyan}
+ .ACT {background-color:green;font-weight:bold}
+ .ACT * {background-color:green;font-weight:bold}
+ .NR {background-color:yellow;color:blue}
+ .NR * {background-color:yellow;color:blue}
+ .RC {background-color:yellow;color:red}
+ .RC * {background-color:yellow;color:red}
+
+ </style></head><body><h1><center>Churn by Product</center></h1><table width="100%"><tr><td width="50%" align="left" valign="top">
+ Run Date: Wed Apr 4 23:00:55 2001 GMT<br/>
+ Parameters:
+ </td><td align="right" valign="top"><table><tr><th>Legend</th></tr><tr class="PROD"><td>Product</td></tr><tr class="ACT"><td>Action</td></tr><tr class="NR"><td>Non-Recurring</td></tr><tr class="RC"><td>Recurring</td></tr></table></td></tr></table><table align="center"><tr class="
+PROD
+"><td>Apple</td><td>Proj. Rev: 255750</td><td>Actual Rev: 85.53</td></tr><tr class="
+ACT
+"><td>PICK</td><td>Proj. Rev: 0</td><td>Act. Rev: 50</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+ACT
+"><td>EAT</td><td>Proj. Rev: 0</td><td>Act. Rev: 0</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+ACT
+"><td>SQUEEZE</td><td>Proj. Rev: 255750</td><td>Act. Rev: 35.53</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+PROD
+"/><tr class="
+PROD
+"><td>Orange</td><td>Proj. Rev: 1743250</td><td>Actual Rev: 10695.229999999</td></tr><tr class="
+ACT
+"><td>PICK</td><td>Proj. Rev: 1159000</td><td>Act. Rev: 9964.479999999</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+ACT
+"><td>EAT</td><td>Proj. Rev: 0</td><td>Act. Rev: 0</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+ACT
+"><td>SQUEEZE</td><td>Proj. Rev: 584250</td><td>Act. Rev: 730.749999999</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+PROD
+"/><tr class="
+PROD
+"><td>Banana</td><td>Proj. Rev: 110250</td><td>Actual Rev: 202.9</td></tr><tr class="
+ACT
+"><td>PICK</td><td>Proj. Rev: 98000</td><td>Act. Rev: 202.9</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+ACT
+"><td>EAT</td><td>Proj. Rev: 12250</td><td>Act. Rev: 0</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+PROD
+"/><tr class="
+PROD
+"><td>Nectarine</td><td>Proj. Rev: 5950</td><td>Actual Rev: -5.95</td></tr><tr class="
+ACT
+"><td>SQUEEZE</td><td>Proj. Rev: 5950</td><td>Act. Rev: -5.95</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+PROD
+"/><tr class="
+PROD
+"><td>Pineapple</td><td>Proj. Rev: 36250</td><td>Actual Rev: 73.129999999</td></tr><tr class="
+ACT
+"><td>PICK</td><td>Proj. Rev: 23750</td><td>Act. Rev: 68.75</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+ACT
+"><td>EAT</td><td>Proj. Rev: 0</td><td>Act. Rev: 0</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+ACT
+"><td>SQUEEZE</td><td>Proj. Rev: 12500</td><td>Act. Rev: 4.379999999</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+PROD
+"/><tr class="
+PROD
+"><td>Coconut</td><td>Proj. Rev: 13750</td><td>Actual Rev: 17.87</td></tr><tr class="
+ACT
+"><td>PICK</td><td>Proj. Rev: 13750</td><td>Act. Rev: 17.87</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+PROD
+"/><tr class="
+PROD
+"><td>Guava</td><td>Proj. Rev: 14995</td><td>Actual Rev: -19.489999999</td></tr><tr class="
+ACT
+"><td>SQUEEZE</td><td>Proj. Rev: 14995</td><td>Act. Rev: -19.489999999</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+PROD
+"/><tr class="
+PROD
+"><td>Pear</td><td>Proj. Rev: 29995</td><td>Actual Rev: 38.99</td></tr><tr class="
+ACT
+"><td>PICK</td><td>Proj. Rev: 29995</td><td>Act. Rev: 38.99</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+PROD
+"/><tr class="
+PROD
+"><td>Raisin</td><td>Proj. Rev: 299925</td><td>Actual Rev: 227.949999999</td></tr><tr class="
+ACT
+"><td>EAT</td><td>Proj. Rev: 0</td><td>Act. Rev: 0</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+ACT
+"><td>SQUEEZE</td><td>Proj. Rev: 299925</td><td>Act. Rev: 227.949999999</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+PROD
+"/><tr class="
+PROD
+"><td>Fig</td><td>Proj. Rev: 74990</td><td>Actual Rev: 136.24</td></tr><tr class="
+ACT
+"><td>PICK</td><td>Proj. Rev: 74990</td><td>Act. Rev: 136.24</td></tr><tr><td valign="top"/><td valign="top"/></tr><tr class="
+ACT
+"/><tr class="
+PROD
+"/></table></body></html>
diff --git a/tests/general/bug-5-.xsl b/tests/general/bug-5-.xsl
new file mode 100644
index 00000000..b0fe9f82
--- /dev/null
+++ b/tests/general/bug-5-.xsl
@@ -0,0 +1,158 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:variable name="ACTIONgrid" select="//GROUP[@type='REC' and not(@name=preceding::GROUP[@type='REC']/@name)]/@name"/>
+<xsl:template match='/'>
+ <html>
+ <head>
+ <title>Churn by Product</title>
+ <style type="text/css"> .PROD {background-color:cyan}
+ .PROD * {background-color:cyan}
+ .ACT {background-color:green;font-weight:bold}
+ .ACT * {background-color:green;font-weight:bold}
+ .NR {background-color:yellow;color:blue}
+ .NR * {background-color:yellow;color:blue}
+ .RC {background-color:yellow;color:red}
+ .RC * {background-color:yellow;color:red}
+
+ </style>
+ </head>
+ <body>
+ <h1><center>Churn by Product</center></h1>
+ <table width="100%">
+ <tr>
+ <td width="50%" align="left" valign="top">
+ Run Date: <xsl:value-of select="XMLDATA/RUNDATE"/><br/>
+ Parameters:
+ </td>
+ <td align="right" valign="top">
+ <table><tr><th>Legend</th></tr><tr class="PROD"><td>Product</td></tr>
+<tr class="ACT"><td>Action</td></tr>
+<tr class="NR"><td>Non-Recurring</td></tr>
+<tr class="RC"><td>Recurring</td></tr>
+
+ </table>
+ </td>
+ </tr>
+ </table>
+ <table align="center"><xsl:apply-templates select="/XMLDATA/GROUP"/></table>
+ </body>
+ </html>
+ </xsl:template><xsl:template match="GROUP[@type='PRODUCT']">
+ <tr>
+<xsl:attribute name="class">
+PROD
+</xsl:attribute>
+
+ <td><xsl:value-of select='.//ROW[1]/PRODUCT'/></td>
+ <td>Proj. Rev: <xsl:value-of select='sum(.//ROW/PREV)'/></td>
+ <td>Actual Rev: <xsl:value-of select='sum(.//ROW/AREV)'/></td>
+ </tr>
+ <xsl:apply-templates select='GROUP'/>
+ <tr>
+<xsl:attribute name="class">
+PROD
+</xsl:attribute>
+
+ </tr>
+</xsl:template>
+
+<xsl:template match="GROUP[@type='ACTION']">
+ <xsl:variable name='grp' select='.'/>
+ <tr>
+<xsl:attribute name="class">
+ACT
+</xsl:attribute>
+
+ <td><xsl:value-of select='.//ROW[1]/ACTION'/></td>
+ <td>Proj. Rev: <xsl:value-of select='sum(.//ROW/PREV)'/></td>
+ <td>Act. Rev: <xsl:value-of select='sum(.//ROW/AREV)'/></td>
+ </tr>
+ <tr>
+ <xsl:for-each select='$ACTIONgrid'>
+ <xsl:sort select='.'/>
+ <td valign='top'>
+ <xsl:apply-templates select='$grp/GROUP[@name=current()]'/>
+ </td>
+ </xsl:for-each>
+ </tr>
+ <tr>
+<xsl:attribute name="class">
+ACT
+</xsl:attribute>
+
+ </tr>
+</xsl:template>
+
+<xsl:template match="GROUP[@type='REC']">
+ <table>
+ <tr>
+<xsl:attribute name="class">
+
+ <xsl:choose>
+ <xsl:when test="@name='Recurring'">RC</xsl:when>
+ <xsl:otherwise>NR</xsl:otherwise>
+ </xsl:choose>
+
+</xsl:attribute>
+
+ <td><xsl:value-of select='.//ROW[1]/REC'/></td>
+ <td>Number: <xsl:value-of select='sum(.//ROW/NUM)'/></td>
+ <td>Proj. Rev: <xsl:value-of select='sum(.//ROW/PREV)'/></td>
+ <td>Act. Rev: <xsl:value-of select='sum(.//ROW/AREV)'/></td>
+ </tr>
+ <tr>
+ <td>Segment</td>
+ <td>Number</td>
+ <td>Proj. Rev</td>
+ <td>Act. Rev</td>
+ </tr>
+ <xsl:apply-templates select='ROW'/>
+ <tr>
+<xsl:attribute name="class">
+
+ <xsl:choose>
+ <xsl:when test="@name='Recurring'">RC</xsl:when>
+ <xsl:otherwise>NR</xsl:otherwise>
+ </xsl:choose>
+
+</xsl:attribute>
+
+ </tr>
+ </table>
+</xsl:template>
+
+
+<xsl:template match='ROW'>
+ <tr>
+
+ <xsl:apply-templates select='SEGMENT'/>
+ <xsl:apply-templates select='NUM'/>
+ <xsl:apply-templates select='PREV'/>
+ <xsl:apply-templates select='AREV'/>
+ </tr>
+</xsl:template>
+
+<xsl:template match='SEGMENT'>
+ <td>
+ <xsl:value-of select='.'/>
+ </td>
+</xsl:template>
+
+<xsl:template match='NUM'>
+ <td>
+ <xsl:value-of select='.'/>
+ </td>
+</xsl:template>
+
+<xsl:template match='PREV'>
+ <td>
+ <xsl:value-of select='.'/>
+ </td>
+</xsl:template>
+
+<xsl:template match='AREV'>
+ <td>
+ <xsl:value-of select='.'/>
+ </td>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/tests/general/bug-6-.out b/tests/general/bug-6-.out
new file mode 100644
index 00000000..e3f13ac3
--- /dev/null
+++ b/tests/general/bug-6-.out
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Title of my document</title></head><body><h1>Title of my document</h1>
+
+<hr/></body></html>
diff --git a/tests/general/bug-6-.xsl b/tests/general/bug-6-.xsl
new file mode 100644
index 00000000..33100d78
--- /dev/null
+++ b/tests/general/bug-6-.xsl
@@ -0,0 +1,31 @@
+<?xml version= "1.0"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:my="http://my/namespace"
+ xmlns="http://www.w3.org/1999/xhtml">
+
+ <!-- Root Node -->
+ <xsl:template match="/">
+ <html>
+ <head>
+ <title><xsl:value-of select="my:document/my:name"/></title>
+ </head>
+ <xsl:apply-templates/>
+ </html>
+ </xsl:template>
+
+ <!-- Header and Body for the Document -->
+ <xsl:template match="my:document">
+ <body>
+ <h1><xsl:value-of select="my:name"/></h1>
+ <xsl:apply-templates/>
+ <hr/>
+ </body>
+ </xsl:template>
+
+ <!--Don't display name-->
+ <xsl:template match="my:name">
+ </xsl:template>
+
+</xsl:stylesheet>