Re: [xsl] how to make all xsl:value-of outputs bold

Subject: Re: [xsl] how to make all xsl:value-of outputs bold
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Wed, 14 Mar 2007 12:18:03 +0100
nick humphrey wrote:
hi, i've been googling a lot and am relatively still an xsl newbie. i
was wondering how to make all the xsl:value-of outputs in my xslt to
output in bold, with only using like one line at the top of the xslt
file. is that possible? as opposed to wrapping all of them in span
tags...

With XSLT it is the other way around. You don't change the way xsl:value-of works, but you create rules that react on input nodes that, when encountered, can do whatever you want. I.e.:


<xsl:template match="Via">
  <fo:block style="font-weight:bold">
     <xsl:value-of select="." />
  </fo:block>
</xsl:template>

Now, depending on how you define your apply-templates, every "Via" node will become bold.

If, however, all you are after is creating every fo:block that is in your current stylesheet to become bold, I think you are better of setting the outermost element to have a style that includes bold. Then, your XSL-FO processor will take care of the rest.

I wonder where you get the idea that "only using like one line at the top of the xslt file" could change your output. That is not the way XSLT works. One-liners are something more common in Perl and are very powerful, but don't look for them in XSLT (but you can place your whole XSLT in one line, if that's what you're after).

Cheers,
-- Abel Braaksma
  http://www.nuntia.nl

Current Thread