[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Simple template matching problem

Subject: Re: Simple template matching problem
From: Steve <subsume@xxxxxxxxx>
Date: Mon, 7 May 2007 16:52:20 -0400
Re:  Simple template matching problem
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.

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

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


Variable $invTable uses select="document('xml.xml')/Records/Record" on the following XML.

xml.xml

<Records>
  <Record>
     <COLUMN_NAME>beginDate</COLUMN_NAME>
     <DATA_TYPE>varchar</DATA_TYPE>
  </Record>
</Records>

On 5/7/07, Abel Braaksma <abel.online@xxxxxxxxx> wrote:
Steve wrote:
> I want a template to match the root node of either default.xml or
> record.xml
>
> Right now it only succesfully matches record.xml
>
> default.xml
>
> <root>
>   <stuff />
> </root>
>
> record.xml
>
> <Records>
>   <Record />
> </Records>
>
> Current xsl:
>
> <xsl:template match="root | Records">
>  hey, hey. We are, in fact, the monkeys.
> </xsl:template>

I suppose you are missing something like:

<xsl:apply-templates select="document('record.xml')/*" />

the match itself in your code is correct for either. Can you send
something more of your code? In addition, look through your stylesheet
for something like match="/Records" or something like
match="Records[@id]" which both may have a higher precedence which can
be a reason for not matching 'Records' in the first place.

Another way to try your code is (carefully) replacing your
apply-templates with copy-of to see if you really select something in
apply-templates, or that you have some error in the namespace prefix,
the absence of one, or anything else that can be a cause of
non-selection (missing CamelCase?).

Cheers,
-- Abel

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.