This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Library functions


>Is the following piece
>of psedo code has the correct idea:
>
>    <fo:block
>            border-before-width = "floor(4.2 div 2.0)*1.0in"
>   </fo:block>

To tell an XSLT processor to evaluate an expression, you put curly braces
around it to make it an attribute value template. The string showing the
units ("in") will just confuse it when it's trying to do the math, so append
that to the result of the calculation by putting it after the right brace.
(After all, you're telling the FO processor about the units, not the XSLT
processor, which won't know what to do with them.) This gives you the
following:

  <fo:block border-before-width = "{floor(4.2 div 2.0)}in"/>

I wrote something for XML.com demonstrating the use of various math
functions in XSLT; see http://www.xml.com/pub/a/2001/05/07/xsltmath.html.
(It's an excerpt from my book.)
Note that the examples in the column don't use attribute value templates
because the XSLT processor assumes that the value of an xsl:value-of
element's select attribute is an expression to be evaluated. For this
reason, you would have to add the "in" units string as a text node outside
of the xsl:value-of element.

Bob DuCharme            www.snee.com/bob             <bob@  
snee.com>      see http://www.snee.com/bob/xsltquickly for
info on new book "XSLT Quickly" from Manning Publications.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]