xsl-list
[Top] [All Lists]

RE: Order of processing templates

2003-02-21 08:52:29
Karl,

When you say the second template is processed first, do you mean that:

<xsl:apply-templates 
select="xml/s:Schema/s:ElementType/s:AttributeType[check='true']"/>

is matching on:

<xsl:template match="xml/s:Schema/s:ElementType/s:AttributeType[where!='']">

???

If this is the case, make certain that the predicates in your XPaths are not 
evaluating to the same value.  Regardless, have you tried assigning a mode to 
your templates?  An example of mode could be:

<xsl:template match="/">
        select
        <xsl:apply-templates 
select="xml/s:Schema/s:ElementType/s:AttributeType[check='true']" 
mode="first"/> from
        <xsl:value-of select="$table"/>
        <xsl:apply-templates 
select="xml/s:Schema/s:ElementType/s:AttributeType[where!='']" mode="second"/>
</xsl:template>

<xsl:template match="xml/s:Schema/s:ElementType/s:AttributeType[check='true']" 
mode="first">
        <xsl:value-of select="@name"/>
        <xsl:if test="position()!=last()">,</xsl:if>
</xsl:template>

<xsl:template match="xml/s:Schema/s:ElementType/s:AttributeType[where!='']" 
mode="second">
        <xsl:if test="position()=1">
        where
        </xsl:if>
        <xsl:value-of select="@name"/>=
        <xsl:value-of select="where"/>
</xsl:template>

Jim

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list