A.2 XSL-FO language features similar to XSLT and XPath

A.2 XSL-FO language features similar to XSLT and XPath

The expression language is very close, but not identical.

  • The operators are the same;

  • there is a wider set of operands in XSL-FO than in XPath.

Nuances of differences can make writing in XSLT confusing;

  • this may trigger stylesheet errors.

Consider the situation of arithmetic calculations with lengths, as shown in Example A-1.

Example A-1 An illustration of uses of the expression language with lengths
 Line 01 <xsl:template name="test">      02 <xsl:variable name="num" select="100"/>      03 <xsl:variable name="medium-font" select="'10pt'"/>      04       05 <block space-before.optimum="10pt div 2">      06   First test: <xsl:value-of select="$num div 2"/>      07 </block>      08       09 <block space-before.optimum="{$medium-font} div 2">      10   Second test      11 </block>      12       13 <block space-before.optimum="{$medium-font div 2}">      14   Third test      15 </block>      16       17 <block>      18   <xsl:attribute name="space-before.optimum">      19     <xsl:value-of select="$medium-font div 2"/>      20   </xsl:attribute>      21   Fourth test      22 </block>      23       24 <block>      25   <xsl:attribute name="space-before.optimum">      26     <xsl:value-of select="$medium-font"/> div 2<xsl:text/>      27   </xsl:attribute>      28   Fifth test      29 </block>      30 </xsl:template> 

There will be no spacing in the third and fourth tests.

  • The arithmetic calculation yields the result of NaN because a length is not a number in XSLT, as opposed to XSL-FO.

    • XSLT cannot do arithmetic operations with string operands.

  • A formatter may not report an error and assume a value of for NaN since it is a valid number in the floating point arithmetic.

    • There is no indication to the stylesheet writer that anything is wrong, yet results are not as expected.

Definitive XSL-FO
Definitive XSL-FO
ISBN: 0131403745
EAN: 2147483647
Year: 2002
Pages: 99
Authors: G. Ken Holman

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net