Hi Peter,

As you discovered, XSLT selects only one template for each match, even when more than one applies.  You'll need to write a more general template to handle all your permutations, something like this:

<xsl:template match="d:para[@role]">
  <fo:block>
    <xsl:if test="contains(@role, 'bg-danger')">
      <xsl:attribute name="background-color">red</xsl:attribute>
    </xsl:if>
    <xsl:if test="contains(@role, 'xx-small')">
      <xsl:attribute name="font-size">xx-small</xsl:attribute>
    </xsl:if>
    <xsl:apply-templates/>
  </fo:block>
</xsl:template>


Bob Stayton
Sagehill Enterprises
[email protected]

On 10/12/2018 7:16 AM, Peter Fleck wrote:
I have a number of templates that add some formatting to xsl:fo, they are in the format of:

 <xsl:template match="d:para[contains(@role,'bg-danger')]" priority="9">
    <fo:block background-color="red">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>

  <xsl:template match="d:para[contains(@role,'xx-small')]" priority="9">
    <fo:block font-size="xx-small">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>

I want to be able to combine these various templates, something like this:

<para role="bg-danger xx-small">..</para>

But only the last "role" in the list gets applied to the output. Is this combining of roles feasible or do I need to write a combo template (for each combination)?

  <xsl:template match="d:para[contains(@role,'bg-danger_xx-small')]" priority="9">
    <fo:block background-color="red" font-size="xx-small">
      <xsl:apply-templates/>
    </fo:block>
  </xsl:template>

<para role="bg-danger_xx-small">..</para>

Thanks,

Peter


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]




Reply via email to