views:

1741

answers:

5

I have an xslt sheet with some text similar to below:

<xsl:text>I am some text, and I want to be bold<xsl:text>

I would like some text to be bold, but this doesn't work.

<xsl:text>I am some text, and I want to be <strong>bold<strong> </xsl:text>

The deprecated b tag doesn't work either. How do I format text within an xsl:text tag?

+1  A: 

Try this:

<fo:inline font-style="bold"><xsl:text>Bold text</xsl:text></fo:inline>
aku
The poster wanted to output a strong element, not use XSL FO. Besides that, this does not work. xsl:text can only create text nodes.
jelovirt
Well, poster didn't say anything about XSL:FO, but you're right xsl:text should be inside of fo:inline
aku
A: 

<xsl:text disable-output-escaping="yes">I want to be <strong>bold<strong> </xsl:text>

David Medinets
A: 

XSL-FO formatting should be able to do that, see the W3Schools tutorial.

Joe Skora
The problem is not trying to generate HTML, the problem is misuse of xsl:text.
jelovirt
A: 

However, I don't think [using disable-output-escaping] this workaround is the best way to go. Perhaps you could learn more from w3schools' crash course on XLS.

Could you be more specific about why? That link to a crash course is nice but doesn't help with the particular problem the questioner wants to solve. I feel that using XSL-FO might be too complex for his needs.

David Medinets
+2  A: 

You don't. xsl:text can only contain text nodes and <strong> is an element node, not a string that starts with less-than character; XSLT is about creating node trees, not markup. So, you have to do

<xsl:text>I am some text, and I want to be </xsl:text>
<strong>bold<strong>
<xsl:text> </xsl:text>
jelovirt