How do I check if weight is less than 50 pounds or greater t

Here should go questions about transforming XML with XSLT and FOP.
winkimjr2
Posts: 62
Joined: Thu Jun 26, 2014 9:00 pm

How do I check if weight is less than 50 pounds or greater t

Post by winkimjr2 »

I am wondering how to change my xslt code so that it checks if height and weight. I want to check if the weight is less than 50 pounds or greater than 499 pounds then this will not be displayed in the output.
And for the height I want to check if height is less than 48 inches or greater than 95 inches then this will not be displayed in the output.
Weight xslt code

xslt code for height

Code: Select all

<xsl:if test="HeightFeet">
<nc:PersonHeightMeasure>
<nc:MeasureText>
<xsl:choose>
<xsl:when test="HeightFeet">
<xsl:value-of select="(HeightFeet*12)+HeightInches"/>
</xsl:when>
</xsl:choose>
</nc:MeasureText>
<nc:MeasureUnitText>
<xsl:text>inches</xsl:text>
</nc:MeasureUnitText>
<nc:LengthUnitCode>
<xsl:text>INH</xsl:text>
</nc:LengthUnitCode>
</nc:PersonHeightMeasure>
</xsl:if>
winkimjr2
Posts: 62
Joined: Thu Jun 26, 2014 9:00 pm

Re: How do I check if weight is less than 50 pounds or great

Post by winkimjr2 »

Code for weight

Code: Select all

<xsl:if test="WeightPounds">
<nc:PersonWeightMeasure>
<nc:MeasureText>
<xsl:choose>
<xsl:when test="WeightPounds">
<xsl:value-of select="WeightPounds"/>
</xsl:when>
/xsl:choose>
</nc:MeasureText>
<nc:MeasureUnitText>
<xsl:text>pounds</xsl:text>
</nc:MeasureUnitText>
<nc:WeightUnitCode>
<xsl:text>LBR</xsl:text>
</nc:WeightUnitCode>
</nc:PersonWeightMeasure>
</xsl:if>
adrian
Posts: 2854
Joined: Tue May 17, 2005 4:01 pm

Re: How do I check if weight is less than 50 pounds or great

Post by adrian »

Hi,

You can just write the comparison expression in the @test attribute. Make sure the < (lower than sign) is escaped to <
e.g.

Code: Select all

<xsl:if test="WeightPounds < 50 or WeightPounds > 499">
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply