C
Christian Rühl
I suspect I know what causes your problem. More on that
Yes, you did!
Uff, I didn't expect that there were two infinite recursions... That's
why I always got the same error message no matter what I changed to
get rid of "the infinite one".
Aaaaaaah, now things get more clear to me!
I already played it through on paper, but I didn't know where the
infinite recursions came from. As said before, I didn't even realize
that there were two of them.
Well, I guess I need a little more experience...
I'll be knocking off now, but I will try a new version tomorrow.
Once again, thank you! You're a great help! Have a good one!
below.
Yes, you did!
Uh, no, not really. First of all, this template would be
invoked when you are processing top element in your 'tree'
document. And your second template application would start
processing from the root node of 'tree' document again,
*whammo* infinite recursion. Replace select="$treeDoc" with
select="*" (you want to process all the children of top
element here, not the whole document once again).
But wait, it gets worse. Your 'archive' document contains
contains a top element as well. That element would match
this very same template, *whammo* infinite recursion.
Basically, there are two ways around that:
Uff, I didn't expect that there were two infinite recursions... That's
why I always got the same error message no matter what I changed to
get rid of "the infinite one".
1. Use modes. You can use mode attributes on
xsl:apply-templates and xsl:template elements to
manually specify different rules for superficially
similar scenarios (such as 'top' element having
different semantics in different documents).
2. Change your template so that it matches 'top' element
in 'tree' document, but not in 'archive' document. In
your sample documents this is trivial:
<xsl:template match="top[product]">
This only matches top elements that have product
element children.
Aaaaaaah, now things get more clear to me!
I strongly recommend taking a very small XML document, a
small transformation, and doing the transformation on
paper. This is going to take half an hour to figure out,
but once you go through this (and once your results match
those that actual XSLT processors produce), you'll have a
much more clear mental picture of how XSLT stylesheets are
processed, and believe me, this is going to be immensely
helpful.
I already played it through on paper, but I didn't know where the
infinite recursions came from. As said before, I didn't even realize
that there were two of them.
Well, I guess I need a little more experience...
I'll be knocking off now, but I will try a new version tomorrow.
Once again, thank you! You're a great help! Have a good one!