Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 18th, 2014, 11:39 AM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default How do I display HeightFeet element?

Based on my xml code, I want to convert the HeightFeet number into inches.
I also want to check that the HeightFeet is not less than 48 inches and not greater than 95 inches.
How do I do this?

My xml code
Code:
<Party ID="1116666" InternalPartyID="1610656384">
    <Gender Word="F">Female</Gender>
    <HeightFeet>5</HeightFeet>
    <HeightInches>5</HeightInches>
    <WeightPounds>130</WeightPounds>
    <EyeColor Word="BLU">Blue</EyeColor>
</Party>
Desired output
Code:
<nc:PersonHeightMeasure>
    <nc:MeasureText>60</nc:MeasureText>
    <nc:MeasureUnitText>inches</nc:MeasureUnitText>
    <nc:LengthUnitCode>INH</nc:LengthUnitCode>
</nc:PersonHeightMeasure>
Output I am getting
Code:
<nc:PersonHeightMeasure>
    <nc:MeasureText>NaN</nc:MeasureText>
    <nc:MeasureUnitText>inches</nc:MeasureUnitText>
    <nc:LengthUnitCode>INH</nc:LengthUnitCode>
</nc:PersonHeightMeasure>
xslt code
Code:
<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>

Last edited by winkimjr2; December 19th, 2014 at 10:19 AM..
 
Old December 19th, 2014, 07:55 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I don't see HeightInches? If you include things in a calculation that don't exist then it will always come out of NaN (Not A Number).

Sam
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
winkimjr2 (December 19th, 2014)
 
Old December 19th, 2014, 10:16 AM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default

I added HeightInches in the xml and now it is working. However how do I check to make sure the HeightInches is not less than 45 inches and not greater than 95 inches?

Last edited by winkimjr2; December 19th, 2014 at 10:19 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to display more than element in the xslt output winkimjr2 XSLT 1 September 19th, 2014 12:28 PM
How can I display xml element tags as it is in HTML gkrishna.tibco XSLT 2 November 22nd, 2010 07:42 AM
div element in array won't display onload linus9 BOOK: Beginning JavaScript 3rd Ed. ISBN: 978-0-470-05151-1 5 November 6th, 2008 02:08 AM
Can display output as Element name HareshVani XSLT 2 March 22nd, 2006 03:19 AM
display element (layer) over java applet mateenmohd Java GUI 0 January 6th, 2004 12:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.