Re: [xsl] Replicating an attribute class?

Subject: Re: [xsl] Replicating an attribute class?
From: JBryant@xxxxxxxxx
Date: Wed, 24 Aug 2005 09:26:29 -0500
Thus:

> <xsl:attribute name="class">
> <xsl:call-template name="tabColour">
> <xsl:with-param name="tabName" select="@name"/>
> </xsl:call-template>
> </xsl:attribute>

becomes:

<xsl:variable name="class">
  <xsl:call-template name="tabColour">
    <xsl:with-param name="tabName" select="@name"/>
  </xsl:call-template>
</xsl:variable>

<xsl:attribute name="class">
  <xsl:value-of select="$class"/>
</xsl:attribute>

Then your other template can do something that value, too:

<xsl:template match="???">
  <table width="100%" class="$class">
    <tr>
      <xsl:apply-templates>
        <xsl:with-param name="type" select="'column'"/>
      </xsl:apply-templates>
    </tr>
  </table>
</xsl:template>

I just guessed as to where to put the class. Perhaps you'd put it in rows 
or cells instead, depending on what you do with that value in your CSS 
stylesheet.

Note: The variable needs to be in scope wherever you plan to use it. If 
it's inside a template, it's not in scope inside another template. As a 
result, you probably need to make it a global variable.

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)





Aaron Johnson <Aaron2.Johnson@xxxxxxxxx> 
08/24/2005 09:09 AM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
"xsl-list@xxxxxxxxxxxxxxxxxxxxxx" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
cc

Subject
Re: [xsl] Replicating an attribute class?







Hi Jay...

Thanks for your input, I thought a variable of some kind would be
appropriate but I don't know how to implement it...

Aaron

..................................................................

Aaron Johnson
GUI / XSLT development
Academic Technologies Group [ATG]
University of the West of England
0117 3281051 [ext: 81051]
atg.uwe.ac.uk/aaron

SECURITY POLICY:

Please note that ATG will only accept
e-mail attachments in the following
formats: 

.asp,.bin,.doc,.gif,.html,.jpg,.mdb,.png,
.psd,.shtml,.sdf,.sit,.xls,.xml,.xsd,.xsl,.zip,

..................................................................

This communication is intended solely
for the use of the individual(s) to whom
it is addressed. Any opinions presented
are those of the author and do not
necessarily represent the University of
the West of England, Bristol.
..................................................................


> From: <JBryant@xxxxxxxxx>
> Reply-To: "xsl-list@xxxxxxxxxxxxxxxxxxxxxx" 
<xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Date: Wed, 24 Aug 2005 09:10:26 -0500
> To: "xsl-list@xxxxxxxxxxxxxxxxxxxxxx" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Subject: Re: [xsl] Replicating an attribute class?
> 
> Hi, Aaron,
> 
> You could put the results of the tabColour template in a variable and 
then
> use the value of that variable in both you xsl:attribute instruction and
> in your other template.
> 
> Jay Bryant
> Bryant Communication Services
> (presently consulting at Synergistic Solution Technologies)
> 
> 
> 
> 
> Aaron Johnson <Aaron2.Johnson@xxxxxxxxx>
> 08/24/2005 08:57 AM
> Please respond to
> xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> 
> 
> To
> "xsl-list@xxxxxxxxxxxxxxxxxxxxxx" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> cc
> 
> Subject
> [xsl] Replicating an attribute class?
> 
> 
> 
> 
> 
> 
> Hello...
> 
> I have:
> 
> <xsl:attribute name="class">
> <xsl:call-template name="tabColour">
> <xsl:with-param name="tabName" select="@name"/>
> </xsl:call-template>
> </xsl:attribute>
> 
> Which calls this template:
> 
> <xsl:template name="tabColour">
>         <xsl:param name="tabName"/>
> 
>         <xsl:choose>
>             <xsl:when test="($tabName = 'Home')">redTab</xsl:when>
>             <xsl:when test="($tabName =
> 'Re-enrolment')">blueTab</xsl:when>
>             <xsl:when test="($tabName = 
'myDetails')">greenTab</xsl:when>
>             <xsl:when test="($tabName = 'myEmail')">yellowTab</xsl:when>
>             <xsl:otherwise>white</xsl:otherwise>
>         </xsl:choose>
>     </xsl:template>
> 
> And adds a css class to the output.
> 
> <td nowrap="nowrap" class="redTab">
> 
> Is there a way I can apply which ever class is chosen to table data in
> anther template so that the css class "?????????" ends up the same as 
the
> chosen tab?
> 
> This is the other template:
> 
>    <table width="100%">
>             <tr>
>                 <xsl:apply-templates>
>                     <xsl:with-param name="type" select="'column'"/>
>                 </xsl:apply-templates>
>             </tr>
>         </table>
>     </xsl:template>
> 
> Thank you!
> 
> ..................................................................
> 
> Aaron Johnson
> GUI / XSLT development
> Academic Technologies Group [ATG]
> University of the West of England
> 0117 3281051 [ext: 81051]
> atg.uwe.ac.uk/aaron
> 
> SECURITY POLICY:
> 
> Please note that ATG will only accept
> e-mail attachments in the following
> formats: 
> 
> .asp,.bin,.doc,.gif,.html,.jpg,.mdb,.png,
> .psd,.shtml,.sdf,.sit,.xls,.xml,.xsd,.xsl,.zip,
> 
> ..................................................................
> 
> This communication is intended solely
> for the use of the individual(s) to whom
> it is addressed. Any opinions presented
> are those of the author and do not
> necessarily represent the University of
> the West of England, Bristol.
> ..................................................................
> 
> 
> 
> This email has been independently scanned for viruses and any virus
> software has been removed using McAfee anti-virus software
> 
> 
> 
> This incoming email to UWE has been independently scanned for viruses 
and any
> virus detected has been removed using McAfee anti-virus software



This email has been independently scanned for viruses and any virus 
software has been removed using McAfee anti-virus software

Current Thread