[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xslt 2.0 challenge

Subject: Re: xslt 2.0 challenge
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 8 Apr 2004 14:54:56 +0100
xsl ends with
DaveP wrote

  Now there's a feature that would help out XSL-FO!
  Arithmetic that catered for 100mm+25mm and added them with a common unit!



<x>
<a>
  <c width='10m'/> 
  <c width='3mm'/>
  <c width='4mm'/>
  <c width='6cm'/>
</a>
<a>
  <c width='2mm'/>
  <c width='3mm'/>
  <c width='4.3mm'/>
  <c width='3in'/>
  <c width='3pt'/>
</a>
</x>





<xsl:stylesheet
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:x="data:,x"
 version="2.0">

<xsl:template match="a">
 [<xsl:value-of select="x:sum-widths(c/@width)"/>]
</xsl:template>

<xsl:function name="x:sum-widths">
 <xsl:param name="x"/>
<xsl:value-of select="
 format-number(sum(for $i in $x
 return
  if (ends-with($i,'mm')) then number(substring-before($i,'mm')) else
  if (ends-with($i,'cm')) then 10*number(substring-before($i,'cm')) else
  if (ends-with($i,'m')) then 100*number(substring-before($i,'m')) else
  if (ends-with($i,'in')) then 25.4*number(substring-before($i,'in')) else
  if (ends-with($i,'ft')) then  304.8*number(substring-before($i,'ft')) else
  if (ends-with($i,'pt')) then 25.4*number(substring-before($i,'pt')) div 72 else
      $i),'#.0#mm')
 "/> 
</xsl:function>

</xsl:stylesheet>


$ saxon7 lengths.xml lengths.xsl
<?xml version="1.0" encoding="UTF-8"?>

 [1067.0mm]


 [86.56mm]


-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.