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

manipulating a property value

Subject: manipulating a property value
From: David Buddrige <dbuddrige@xxxxxxxxx>
Date: Wed, 14 Apr 2004 19:48:06 -0700 (PDT)
yahoo property value
Hi all,

I have the following input document:

<?xml version="1.0" encoding="iso-8859-1"?>
<info>
	<mytag duration="3 days" />
	<mytag duration="4 days" />
	<mytag duration="6 hours" />
	<mytag duration="33 hours" />
	<mytag duration="13 hours" />
	<mytag duration="5 days" />
	<mytag duration="3 hours" />
	<mytag duration="23 hours" />
</info>

What I want to do, is to convert the output document
so that all duration values are in hours, and without
specifying the units.  So where a duration = "3 days",
I want to convert it to hours by multiplying it by 8,
and dropping the units identifier.

Thus

	<mytag duration="5 days" />

becomes

	<mytag duration="40"/>


And also

	<mytag duration="6 hours"/>

becomes

	<mytag duration="6"/>


The xslt template I have written to [attempt] to do
this is as follows:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="/">
		<myoutput>
			<xsl:apply-templates/>
		</myoutput>
	</xsl:template>
	<xsl:template match="mytag">
		<xsl:choose>
			<xsl:when test="@duration='*days'"><!-- need to
somehow strip off the 'days' and multiply remaining
value by 8 --></xsl:when>
			<xsl:otherwise><!-- need to somehow strip off the
'hours' and return the remaining substring
--></xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>

I note that XSLT 2.0 has regular expressions available
that would make this alot easier - is there any way to
do this with XSLT 1.x?

thanks heaps

David Buddrige


	
		
__________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html

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.