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: 53

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

Wed Aug 20, 2014 5:25 pm

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: 53

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

Wed Aug 20, 2014 5:29 pm

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: 2337

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

Thu Aug 21, 2014 11:11 am

Hi,

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

Code: Select all

<xsl:if test="WeightPounds &lt; 50 or WeightPounds > 499">

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 1 guest