Re: Standardizing HTML look-and-feel in XSL (named templates)

Subject: Re: Standardizing HTML look-and-feel in XSL (named templates)
From: "S.Ramaswamy" <srswamy@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 08 Dec 1999 10:27:14 +0530
Bernie H. wrote:
> 
> I'm having trouble figuring out the best way to define a standardized HTML look-and-feel across my entire XSL page.  For example, I want to define a named template ("TABLE_CELL") that wraps a <TD></TD> set around whatever calls it.  I want to use this for all my XML elements so that I can change the BGCOLOR attribute in it and have the change apply throughout.
> 
> <xsl:template name="TABLE_CELL">
>    <TD BGCOLOR="#000000">
>       <xsl:value-of select="."/>
>    </TD>
> </xsl:template>
> 

Well you need to pass a parameter indicating whether you need BOLD or
not because you can only append to the result tree. So you need to get
all the things (BGCOLOR and BOLD etc.) at one go and then write to the
output  

  <xsl:template name="TABLE_CELL">
   <xsl:param name="BOLD" />
   <xsl:when test='BOLD = "Y"'>
     <TD BGCOLOR="#000000">
        <B>
          <xsl:value-of select="."/>
        </B>
     </TD>
   </xsl:when>
   <xsl:otherwise>
     <TD BGCOLOR="#000000">
        <xsl:value-of select="."/>
     </TD>
    </xsl:otherwise>
  </xsl:choose>
 </xsl:template>

 Now if you want with BOLD you would say

   <xsl:call-template name="TABLE_CELL">
      <xsl:with-param name="BOLD" select='"Y"' />
   </xsl:call-template>   

 and if you do not want BOLD then

   <xsl:call-template name="TABLE_CELL">
      <xsl:with-param name="BOLD" select='"N"' />
   </xsl:call-template>   

> However, the <xsl:call-template> call seems to be very restrictive.  For example, if I want to also periodically use this hypothetical "BOLD" named template to wrap <B></B> tags...
> 
> <xsl:template name="BOLD">
>    <B>
>       <xsl:value-of select="."/>
>    </B>
> </xsl:template>
> 
> ... I can't.  My lame attempt so far looks like this:
> 
> <xsl:template match="NAME">
>    <xsl:call-template name="TABLE_CELL">
>       <xsl:call-template name="BOLD"/>
>    </xsl:call-template>
> </xsl:template>
> 
> ... but it only executes the "TABLE_CELL" named template.
> 
> Has anyone else tried to do this type of thing before?  Am I thinking about this problem the wrong way?
> 
> For the sake of this argument, I'm sticking with pure XSL Transformations (i.e. no "fo:" formatting namespace>.
> 
> Thanks,
> Bernie
> bernie@xxxxxxxxxxxxxx
> 
> _________________________________
> Breakbeat Era/ES Sports Contest Givaway
> http://www.platform.net/ads/100699breakbeatera/
> 
> Win a platstation:
> SignUP at http://www.platform.net
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

-- 
==--==--==--==--==--==--==--==--==--==--==--==--==--==
S.Ramaswamy
Matrix Infotech Syndicate
D-7, Poorti, Vikaspuri, New Delhi, 110018, India
PHONE:    +91-11-5610050,   FAX: +91-11-5535103  
WEB         http://MatrixInfotech.HyperMart.Net
==--==--==--==--==--==--==--==--==--==--==--==--==--==


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


Current Thread