How do I format text in between xsl:text tags?
Asked Answered
M

5

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?

Mendelson answered 17/9, 2008 at 1:18 Comment(4)
BeerDNA, did you just edit this question to remove angle brackets showing wrong?Probst
I'd forgotten to put the code tags around it and everything was garbled and the formatting was terrible for about the first 90 seconds of life. Apologize to those who clicked quickly and saw the garbage.Mendelson
as just answered, it should be </strong>, both in the question and the accepted answerMuseum
You can check my answer here: enter link description hereDiscombobulate
R
7

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>
Runck answered 17/9, 2008 at 6:25 Comment(0)
B
8

Try this:

<fo:inline font-weight="bold"><xsl:text>Bold text</xsl:text></fo:inline>
Bayly answered 17/9, 2008 at 1:23 Comment(3)
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.Runck
Well, poster didn't say anything about XSL:FO, but you're right xsl:text should be inside of fo:inlineBayly
This worked: <fo:inline font-weight="bold"><xsl:text>Catalog Number: </xsl:text></fo:inline>Ainslie
R
7

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>
Runck answered 17/9, 2008 at 6:25 Comment(0)
L
3

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

Lukin answered 17/9, 2008 at 1:25 Comment(0)
L
0

The answer for this depends on how much formatting is needed in the content and also where you get content from. If you have less content and less formatting then you can use what jelovirt suggested

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

However if your content has large formatting then what David Medinets suggests is better way to do it

<xsl:text disable-output-escaping="yes">

We have some instructions to print on UI. The set of instructions is huge and of course we read those from XML file.

In such cases the above method is easy to use and maintain too. That is because the content is provided by technical writers. They have no knowledge of XSL. They know using HTML tags and they can easily edit the XML file.

Landowska answered 20/6, 2011 at 11:48 Comment(0)
D
0

the correct way to use the strong tag is

<strong>This text is strong</strong>

not <strong> at the end

Here is the information reference: https://www.w3schools.com/html/html_formatting.asp

Discombobulate answered 11/12, 2019 at 19:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.