xsl-list
[Top] [All Lists]

Re: Calling templates based on node contents

2004-08-18 05:31:42
Given your descriptive element names it sounds like you just want a <xsl:choose> statement based on <contentFieldStyle> within the template matching the contentField (as a way of breaking the <xsl:choose> lists into manageable chunks.)

e.g.

<xsl:template match='contentField'>
<xsl:choose>
   <xsl:when test='contentFieldStyle="style1"'>
      <xsl:call-template name='contentFieldStyle1''/>
   <xsl:when>
   <xsl:when test='contentFieldStyle="style2"'>
      <xsl:call-template name='contentFieldStyle2''/>
   <xsl:when>
...
   <xsl:otherwise>
      <xsl:call-template name='contentFieldDefault''/>
   <xsl:otherwise>
</xsl:choose>
</xsl:template>

Or - if the templates only involve a small amount of code - embed the code rather than calling a template. And - you could use modes instead of individually named templates if you wanted to.


Ben Gazzard wrote:

yeah... should of been a little more clearer... sorry...

basically trying to find a way of doing this:

<xsl:call-template name="concat(contentFieldElement, '_', contentFieldStyle)" />

(which i know isn't valid, unfortunatly)

but with xsl:apply-template which ive not really looked at properly yet...



-----Original Message-----
From: David Carlisle [mailto:davidc(_at_)nag(_dot_)co(_dot_)uk]
Sent: 18 August 2004 13:07
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Calling templates based on node contents



 very simple HTML...

 from the <xsl:template match="." mode="defaultField_A"> template:
 <a class="defaultField_A" href="Default url text -- please update">Default text -- 
please update</a>

yes but that doesnt tell us how you want the output to depend on teh
input.
<xsl:template match="." is _very_ strange construct it matches any node whatsoever, so really
disables the entire template matching process (which is why you were
having difficulties I expect)

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--


This e-mail and any attached files are for the exclusive use of the addressee 
and may contain privileged and/or confidential information. If you receive this 
e-mail in error you should not disclose the contents to any other person nor 
take copies but should delete it and telephone us immediately on +44(0)20 7557 
6100.

TEQUILA\ London Limited does not make any warranty as to the accuracy or 
completeness of this e-mail and we accept no liability for its content or use. 
Any opinions expressed in this e-mail are those of the author and do not 
necessarily reflect the opinions of TEQUILA\ London Limited.

TEQUILA\ London Limited operates within the parameters set by the Data 
Protection Act 1998 with regard to the use of personal information including 
e-mail addresses. We accept no liability for the forwarding of this e-mail to 
other parties that may result in unsolicited e-mails being received by those 
whose email addresses appear in this e-mail.

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--

--
Datalucid Limited
8 Eileen Road
South Norwood
London SE25 5EJ
United Kingdom

/
tel :0208-239-6810
mob: 0794-725-9760
email: mike(_dot_)trotman(_at_)datalucid(_dot_)com

UK Co. Reg:   4383635
VAT Reg.:   798 7531 60

/