Hi all,
before I'm going to feed jira with a possibly invalid bugreport, I'd like
to ask for the developer's opinions here.
What I want to do is wrapping a long sequence of template calls into a
loop, like in the following example.
Beginning with a stylesheet of the form:
<xsl:stylesheet...>
<xsl:template name="T1"> ...
<xsl:param name="P1" .../>
<xsl:param name="P2" .../>
... <!-- maybe a dozen params -->
</xsl:template>
<xsl:template match=...>
<xsl:call-template name="T1">
<xsl:with-param name="P1" select="value1_p1"/>
<xsl:with-param name="P2" select="value1_p2"/>
...
</xsl:call-template>
<xsl:call-template name="T1">
<xsl:with-param name="P1" select="value2_p1"/>
<xsl:with-param name="P2" select="value2_p2"/>
...
</xsl:call-template>
... <!-- maybe some dozens template calls -->
</xsl:template>
</xsl:stylesheet>
I'd like to reduce the code length by one magnitude:
<xsl:stylesheet...>
<xsl:variable name="globalSettings">
<elem attr1="value1_p1" attr2="value1_p2" .../>
<elem attr1="value2_p1" attr2="value2_p2" .../>
... <!-- maybe some dozens entries here -->
</xsl:variable>
<xsl:template name="T1"> ...
<xsl:param name="P1" .../>
<xsl:param name="P2" .../>
... <!-- maybe a dozen params -->
</xsl:template>
<xsl:template match=...>
<xsl:for-each select="$globalSettings/elem">
<xsl:call-template name="T1">
<xsl:with-param name="P1" select="@attr1"/>
<xsl:with-param name="P2" select="@attr2"/>
...
</xsl:call-template>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Unfortunately, Xalan doesn't like the for-each evaluation of my
globalSettings variable. The error message is like:
XSLT Error: The expression does not evaluate to a node-set.
Now, I'm wondering, if I'm doing a mistake here. Reading e.g.
http://www.w3.org/TR/xslt.html#variables, I can't find any hint that
this construct would be forbidden (but I can't find any 'positive'
example, either).
The main reason why I want to do 'loop rolling' here is that I plan to
have a couple of different templates that would make use of this
construct with all the same global variable. If I want to make some
(consistent) changes in the parameter values of the template calls, I
only need to make the required changes with the global variable, instead
of querying hundreds of lines of code.
My questions here are
- is 'loop rolling' a legal concept with XSLT?
- is the reaction of Xalan (The expression does not evaluate to a
node-set.) a bug - or a feature?
Thanks in advance,
cheers,
Axel
--
Humboldt-Universität zu Berlin
Institut für Informatik
Signalverarbeitung und Mustererkennung
Dipl.-Inf. Axel Weiß
Rudower Chaussee 25
12489 Berlin-Adlershof
+49-30-2093-3050
** www.freesp.de **
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]