How to specify a conditional test in a choose element?

Here should go questions about transforming XML with XSLT and FOP.
chymical
Posts: 16
Joined: Wed Nov 24, 2010 12:37 pm

How to specify a conditional test in a choose element?

Post by chymical »

Hi,

I am creating a PDF and want to use a logo on the cover that depends on information in the booktitlealt element of the ditamap. This is what I have done:

<xsl:variable name ="logotype">
<xsl copy-of select="/bookmap/booktitle/booktitlealt'/>
</xsl:variable>

<xsl:choose>
<xsl:when test="contains($logotype,'Windows')">
<fo:external-graphic-------------/>
</xsl:when>
<xsl:when test="contains($logotype,'Unix')">
<fo:external-graphic-------------/>
</xsl:when>
<xsl:otherwise>
<fo:external-graphic-------------/>
</xsl:otherwise>
</xsl:choose>

When I publish the PDF, the logo used is always the one in the otherwise section, even though I know that the booktitlealt contains Windows or Unix. Can anyone tell me what I am doing wrong?

Thanks,

John
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: How to specify a conditional test in a choose element?

Post by sorin_ristache »

Hello,

Is that a DITA OT transformation that you run in Oxygen? If not please specify the name and version of the XSLT processor that runs the transformation.

In either case: what is the message displayed by an xsl:message inserted before xsl:choose?

Code: Select all

<xsl:message>LOGOTYPE = <xsl:value-of select="$logotype"/></xsl:message>

<xsl:choose>
<xsl:when test="contains($logotype,'Windows')">
<fo:external-graphic-------------/>
</xsl:when>
<xsl:when test="contains($logotype,'Unix')">
<fo:external-graphic-------------/>
</xsl:when>
<xsl:otherwise>
<fo:external-graphic-------------/>
</xsl:otherwise>
</xsl:choose>

Regards,
Sorin
chymical
Posts: 16
Joined: Wed Nov 24, 2010 12:37 pm

Re: How to specify a conditional test in a choose element?

Post by chymical »

Hi,

I solved this by using the maptitle variable that was already defined, so I would guess that my definition of the logotype variable was wrong...
Post Reply