[xsl] Order of processing templates

Subject: [xsl] Order of processing templates
From: "Karl Stubsjoen" <karl@xxxxxxxxxxxxx>
Date: Thu, 20 Feb 2003 00:36:12 -0700
Hello,

How does one *best* control the flow/process by which templates are
followed?  I assumed that it would be a top to bottom processing mechanism,
but it does not necessarily seem so.
So far, I have bee taking advantage of the XPATH syntax and am doing well at
looping through different collections of nodes.  However, just recently, I
had two template calls one after each other, but the 2nd one processed
first.  This is a big nono, since I'm dependent on the order in which these
output.

Should I be using <xsl:for-each...> opposed to straight xpath matches?
Here is a snipet of the XSL where the 2nd apply-template fired before the
first:

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

    <xsl:template
match="xml/s:Schema/s:ElementType/s:AttributeType[check='true']">
        <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!='']">
     <xsl:if test="position()=1">
        where
        </xsl:if>
        <xsl:value-of select="@name"/>=
  <xsl:value-of select="where"/>
    </xsl:template>


Thanks for the help!
Karl


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


Current Thread