roeygol
roeygol

Reputation: 5048

XSL: How to use HTML tags inside stylesheet?

I got this code in my XSL stylesheet:

<xsl:for-each select="report:column-names/report:column">
    <fo:table-cell display-align="center" font-size="9pt">
        <fo:block font-family="{$font.family}" font-weight="bold">
            <xsl:value-of select="." disable-output-escaping="yes" /> <--problematic value
        </fo:block>
    </fo:table-cell>
</xsl:for-each>

In the problematic value that I mentioned, I got values that I want to wrap with bdi html tag.

I tried to just put bdi and I didn't see my value, like this:

<bdi><xsl:value-of select="." disable-output-escaping="yes" /></bdi>

How can apply this tag for my values?

Upvotes: 0

Views: 481

Answers (1)

Tony Graham
Tony Graham

Reputation: 8068

You cannot mix HTML and XSL-FO. XSL-FO is an XML vocabulary that is defined for formatting. The original purpose of XSLT was to transform arbitrary XML vocabularies (the 'X' in 'XML' comes from 'Extensible', after all) into the standard formatting vocabulary. That's what you've been doing with the XSLT in your question.

The description of Unicode BIDI Processing in XSL 1.1 is at https://www.w3.org/TR/xsl11/#d0e4879. The applicable FO is fo:bidi-override (https://www.w3.org/TR/xsl11/#fo_bidi-override), and the applicable properties are direction (https://www.w3.org/TR/xsl11/#direction) and unicode-bidi (https://www.w3.org/TR/xsl11/#unicode-bidi).

You so far haven't shown the content of a report:column element, but it looks like you want:

<fo:bidi-override unicode-bidi="embed" direction="rtl">
  <xsl:value-of select="." disable-output-escaping="yes" />
</fo:bidi-override>

Without seeing a report:column element, the embed and rtl are just guesses.

(Using disable-output-escaping is seldom a good idea, but we can't see how bad an idea it is in this case without seeing a report:column element that needs it.)

Upvotes: 2

Related Questions