Re: [xsl] Simple template matching problem

Subject: Re: [xsl] Simple template matching problem
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Mon, 07 May 2007 23:40:49 +0200
Steve wrote:
I have a problem with the below templates. The first template
*ideally* displays a bunch of input fields, based on the table's
structure as defined by $invTable.

The second template *ideally* creates a single form control (there are
several besides 'varchar'/'float')

My problem is that when the top template is "Records/Record" I'm
getting infinite recursion loop. When I use match "Records" all is
fine. I suspect its because of a template mismatch.

You suspect correct. You match for "Records/Record", which translates as: "Any element 'Record' that has a parent of 'Records' ". However, you seem to think of it as "Any element 'Records' with one or more 'Record' elements as children".


What you need is: match="Records[Record]" (you need a predicate, not a child specification).


<xsl:template match="Records/Record"> <xsl:apply-templates select="$invTable[COLUMN_NAME='beginDate']"> <xsl:with-param name="value" select="//beginDate" />

btw, why do you need this? First of all, it is not there in the source, secondly (assuming your sample source is different than your real source), if the data is there, you can get it from the matching templates as well (or the matching templates have different sources, but the same elements, in which case I recommend that you switch modes as well, to keep from accidental infinite recursion).


   </xsl:apply-templates>
</xsl:template>

<xsl:template match="Record[DATA_TYPE='varchar' or DATA_TYPE='float']">
   <appropriateInputBox />
</xsl:template>




Cheers,
-- Abel

Current Thread