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

Re: less than zero

Subject: Re: less than zero
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Wed, 31 Jul 2002 13:00:55 +0200
download less than zero
Hello Sascha,

I think it's another problem.

sascha wrote:
I want to check if a value ( $leftmargin ) is less than 0 -
check my example please.

"$wert" is ok, "$leftmargin" is ok too but the xsl:if does not work.:

<xsl:variable name="notesleftmargin"><xsl:value-of
select="ancestor::dxl:richtext//dxl:pardef[@id=$pabid]/@leftmargin"/></xsl:v
ariable>

(Here you create a Result Tree Fragment, which shows similar behaviour to a string, but must converted first. Use (like in the following variable declarations) <xsl:variable name="notesleftmargin" select="ancestor::dxl:richtext//dxl:pardef[@id=$pabid]/@leftmargin"/>.)


<xsl:variable name="wert" select="substring-before($notesleftmargin,'in')"/>
<xsl:variable name="leftmargin" select="$wert - 1"></xsl:variable>

<xsl:if test="number($leftmargin) &lt; 0"><xsl:variable name="leftmargin"
select="0"></xsl:variable></xsl:if>

With this construct the variable is only in scope in the <xsl:if>, but not outside of it. You have to change it to the following:


<xsl:variable name="correct-leftmargin">
  <xsl:choose>
    <xsl:when test="number($leftmargin) &lt; 0">0</xsl:when>
    <xsl:otherwise><xsl:value-of select="$leftmargin"/></xsl:otherwise>
  </xsl:choose>
</xsl:variable>

Furthermore you can not reassign a value to a variable. Therefore I changed the name of the second one.

<xsl:attribute name="margin-left"><xsl:value-of
select="concat($leftmargin,'in')"/></xsl:attribute>

but this does not work.
why?

sascha

Regards,


Joerg



--

System Development
VIRBUS AG
Fon  +49(0)341-979-7419
Fax  +49(0)341-979-7409
joerg.heinicke@xxxxxxxxx
www.virbus.de


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



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.