atom feed21 messages in com.mulberrytech.lists.xsl-list[xsl] XSLT verbosity (atan2)
FromSent OnAttachments
Jones Mark Mr (ITCS)Mar 18, 2008 7:29 am 
Andrew WelchMar 18, 2008 8:27 am 
Jones Mark Mr (ITCS)Mar 18, 2008 9:32 am 
Martin HonnenMar 18, 2008 9:37 am 
David CarlisleMar 18, 2008 9:37 am 
Jones Mark Mr (ITCS)Mar 18, 2008 10:10 am 
acMar 18, 2008 10:10 pm 
acMar 18, 2008 10:25 pm 
Mukul GandhiMar 19, 2008 1:28 am 
Michael KayMar 19, 2008 2:15 am 
Michael KayMar 19, 2008 2:21 am 
David CarlisleMar 19, 2008 3:01 am 
Patrick BergeronMar 19, 2008 7:17 am 
David CarlisleMar 19, 2008 7:28 am 
Wendell PiezMar 19, 2008 9:44 am 
Michael KayMar 19, 2008 10:21 am 
acMar 19, 2008 10:33 am 
Ken TamMar 19, 2008 9:49 pm 
Dimitre NovatchevMar 19, 2008 10:38 pm 
Dimitre NovatchevMar 20, 2008 6:34 am 
Michael KayMar 20, 2008 7:31 am 
Subject:[xsl] XSLT verbosity (atan2)
From:Patrick Bergeron (pber@innobec.com)
Date:Mar 19, 2008 7:17:51 am
List:com.mulberrytech.lists.xsl-list

Hello,

I'm trying to make a small template that concisely implements atan2, but returns the values in degrees and handles the case where DX is zero. So far, I have:

<xsl:template name="my_atan2"> <xsl:param name="dx" /> <xsl:param name="dy" />

<xsl:variable name="rad" > <xsl:choose> <xsl:when test="dx != 0"> <xsl:value-of select="exsl:atan2(dx, dy)" /> </xsl:when>

<xsl:when test="(dx = 0) and (dy &gt; 0)"> <xsl:value-of select="$my_pi" /> </xsl:when>

<xsl:when test="(dx = 0) and (dy &lt; 0)"> <xsl:value-of select="$my_pi * 3" /> </xsl:when> </xsl:choose> </xsl:variable>

<xsl:choose> <xsl:when test="$rad &lt; 0"> <xsl:value-of select="($rad * 180 div $my_pi) + 360" /> </xsl:when>

<xsl:otherwise> <xsl:value-of select="($rad * 180 div $my_pi)" /> </xsl:otherwise> </xsl:choose> </xsl:template>

Is there a way to express this in only a few lines without all the verbosity?