Re: [xsl] Passing HTML elements to a Template

Subject: Re: [xsl] Passing HTML elements to a Template
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Sun, 6 Jul 2008 20:46:20 +0530
It will help us if you can share, whether you are using XSLT 1.0 or
2.0 and the XSLT processor you are using.

I tested the following 1.0 stylesheet with Xalan-J 2.7.1,

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                       version="1.0">

<xsl:output method="html" indent="yes" />

<xsl:template match="/">
  <html>
    <body>
       <xsl:call-template name="output_value">
         <xsl:with-param name="value">
           <b>Text</b>
         </xsl:with-param>
       </xsl:call-template>
    </body>
  </html>
</xsl:template>

<xsl:template name="output_value">
  <xsl:param name="value" />

  <xsl:copy-of select="$value" />
</xsl:template>

</xsl:stylesheet>

and I get output:

<html>
<body>
<b>Text</b>
</body>
</html>

But if I do,

<xsl:template name="output_value">
  <xsl:param name="value" />

  <xsl:value-of select="$value" />
</xsl:template>

I get output,

<html>
<body>Text</body>
</html>

(now, the <b> tags are stripped and we get only the string value of
the 'b' element. This is because we are using xsl:value-of and not
xsl:copy-of).

I think you do not get the desired output (as you want), because you
have some problem in the body of template, output_value. Could you
please share the template definition with us.


On Sun, Jul 6, 2008 at 8:12 PM, Mark Anderson
<mark.anderson@xxxxxxxxxxxxxxxxxxx> wrote:
> Hi All
>
>
> I have an XSL that converts XML to HTML. The table contains many columns and a lot of style changes between columns. I have created a template that I call with the data to be inserted in each column. However, depending on data elsewhere in the XML I may need to make some values bold. Below is a simple example of what I would like to use is:
>
>  <xsl:call-template name="output_value"><xsl:with-param name="value"><b>Text</b></xsl:with-param></xsl:call-template>
>
> The <b></b> tags are stripped out though. Is there any way arround this?
>
> Regards
>
> Mark


-- 
Regards,
Mukul Gandhi

Current Thread