- From: Tony Graham <Tony.Graham@MenteithConsulting.com>
- Date: Mon, 05 May 2008 12:04:30 +0100
- To: www-xsl-fo@w3.org
On Fri, May 02 2008 14:55:45 +0100, jean.stachler@crown.com wrote:
...
> Below is an excerpt of the code that I have, this is the error statement in
> the Java debugger:
>
> Open quote is expected for attribute "holdnum" associated with an element
> type "xsl:when".
...
> <!--At this point want to check the value of the holdnum
> variable
> if the value is equal to 1, than do this part otherwise go on
> down
> to the next when statement and check if it matches, if it
> does, execute,
> else go to the next statement.-->
>
> <xsl:variable name= "holdnum" select="numitemtotal" />
> <xsl:choose>
> <xsl:when holdnum = '1' >
<xsl:when test="$holdnum = 1">
where:
- The 'test' attribute has the XPath expression to be evaluated.
- The '$' is required for the variable reference.
- Quoting the '1' isn't strictly necessary since it can be evaluated as
a number. Evaluating it as a string as you have done may be
infinitesimally faster since it would save doing two conversions.
- You could just as easily do "numitemtotal = 1"
- There are almost certainly ways of doing what you want without state
variables and without repeating so much FO markup. For example
(untested):
<xsl:variable name="cell1">
<xsl:choose>
<xsl:when test="numitemtotal = 1">
<xsl:value-of select="header/column9"/>
</xsl:when>
<xsl:when test="numitemtotal = 2">
<xsl:value-of select="header/column19"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="header/column39"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="cell2">
<xsl:choose>
<xsl:when test="numitemtotal = 1">
<xsl:value-of select="header/column10"/>
</xsl:when>
<xsl:when test="numitemtotal = 2">
<xsl:value-of select="header/column20"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="header/column40"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<fo:table-row >
<fo:table-cell border="solid black 0.5px"
empty-cells="hide">
<fo:block >
<xsl:value-of select="$cell1"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border="solid black 0.5px"
empty-cells="hide">
<fo:block>
<xsl:value-of select="$cell2"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
Regards,
Tony Graham Tony.Graham@MenteithConsulting.com
Director W3C XSL FO SG Invited Expert
Menteith Consulting Ltd
XML, XSL and XSLT consulting, programming and training
Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
Registered in Ireland - No. 428599 http://www.menteithconsulting.com
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
xmlroff XSL Formatter http://xmlroff.org
xslide Emacs mode http://www.menteith.com/wiki/xslide
Unicode: A Primer urn:isbn:0-7645-4625-2
Received on Monday, 5 May 2008 11:05:01 UTC