Question

I have these escaped tags in my XML file: <strong> --> The whole xml is like this:

<test>
<TEST2>
     <li>&lt;strong&gt;blablablabla</li>
</TEST2>
<test>

I want to show the text in strong and bold letters (like this) and I want to show the list-item bullet. Now I only manage to show the text in strong and bold letters OR I can show the list-item bullet, but I never managed to show them both correctly. So my question is: how can I show them both in the right manner?

First, I tried <xsl:value-of select="/test/TEST2" disable-output-escaping="yes" />, which showed me the text in italic and bold version, but then, it did not output the list item bullets, because it just outputted the raw <li> tag...

Then, I tried <xsl:copy-of-select="/test/TEST">, which showed the list bullets, but this time, it also outputted the raw <strong> and <em> tags.

Besides, copy-of select, combined with disable-output-escaping did not work.

What should I do to show them both correctly?

Sample outputs:

*<em><strong>blalblblbal</strong></em> if I use the second one.

If I use the first one:

blalblblbal

Was it helpful?

Solution

Well use

<xsl:template match="li">
  <xsl:copy>
    <xsl:value-of select="." disable-output-escaping="yes"/>
  </xsl:copy>
</xsl:template>

of course with other templates for ancestors of li generating a ol or ul as needed and processing child elements e.g.

<xsl:template match="test">
  <ul>
    <xsl:apply-templates/>
  </ul>
</xsl:template>

But disable-output-escaping is not supported for instance for client-side XSLT in Mozilla browsers. And generally XSLT processors do not need to support it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top