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 August 13th, 2014, 11:25 AM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default In xslt how do I calculate the xml's person height to show in inches?

I have the following xml element. I want to calculate this height in xslt so it displays as 65 inches. I know I have to multiply 5 feet by 12 and then add 5 inches. But I am not sure how to do it.
Code:
<HeightFeet>5</HeightFeet>
<HeightInches>5</HeightInches>
Here is my xslt code
Code:
<nc:PersonHeightMeasure>
		<nc:MeasureText>
		    <xsl:value-of select="HeightFeet"/>
		    <xsl:value-of select="HeightInches"/>
		</nc:MeasureText>
		<nc:MeasureUnitText>
		    <xsl:text>inches</xsl:text>
		</nc:MeasureUnitText>
			<nc:LengthUnitCode>
				<xsl:text>INH</xsl:text>
			</nc:LengthUnitCode>
	</nc:PersonHeightMeasure>
This xslt displays the following which is not what I want.
Code:
<nc:PersonHeightMeasure>
		<nc:MeasureText>55</nc:MeasureText>
		<nc:MeasureUnitText>inches</nc:MeasureUnitText>
		<nc:LengthUnitCode>INH</nc:LengthUnitCode>
	</nc:PersonHeightMeasure>
 
Old August 13th, 2014, 11:46 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Ah yes, feet and inches - I remember learning about them in history lessons...

In XPath it's

Code:
<xsl:value-of select="HeightFeet * 12 + HeightInches"/>
(Did you know that these forums are provided for readers of Wrox books to ask any questions that they can't find answered in the books? I find it a little difficult to believe that you have read very far to be asking a question like this.)
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
winkimjr2 (August 13th, 2014)
 
Old August 13th, 2014, 04:45 PM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default

I did solve this on my own but thank you for the response.
 
Old August 13th, 2014, 04:48 PM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default

I know that and I do have Professional Visual Basic 2010 and .NET 4.0 paper book that I bought.





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to extract appended xml's into single xml's using XSL veeka01 XSLT 1 July 30th, 2011 08:22 PM
xslt slide show kawlaelo XSLT 6 February 13th, 2007 10:41 AM
Fixed table height and row height rajanikrishna HTML Code Clinic 3 January 18th, 2007 12:42 AM
Inches 2 Pixels Conversion ejan Pro VB 6 3 October 20th, 2004 04:02 PM
Change height of div element if < window height JoelJunstrom Javascript How-To 1 October 10th, 2003 09:14 AM





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