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

PARAMS and VARIABLES in XSL

Subject: PARAMS and VARIABLES in XSL
From: mark bordelon <markcbordelon@xxxxxxxxx>
Date: Tue, 30 Jan 2007 11:41:51 -0800 (PST)
 PARAMS and VARIABLES in XSL
I need help with the following problem.

This is the XML is wish to transform:
 
<clause>
 <sound time="1.2">
 <word>the</word>
 <word>quick</word>
 <sound time="2.2">
 <word>fox</word>
 <sound time="2.8">
 <word>jumped</word>
</clause>
<clause>
</clause>
 
I need to transform it into the following xml, where
the sound tags time attritubes are soundtime
attributes of the following word tags:
 
<clause>
 <word soundtime="1.2">the</word>
 <word soundtime="1.2">quick</word>
 <word soundtime="2.2">fox</word>
 <word soundtime="2.8">jumped</word>
</clause>
<clause>
</clause>
 
Note that the soundtime attribute should not change if
there was no intervening new sound tag. 
 
I have tried all sorts of solutions using axes,
preceding-sibling, but these did not work, since the
<word> and <sound> are not true siblings to the
processor, even though they are on the same level of
the hierarchy.
 
The solution I would like to work with is the
following, using params to accumulate the soundtime
variable. However, even with all the research I have
done, I cannot find a solution that the processor does
not error on. Can anyone help?
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="//clause/*">
<xsl:param name="soundtime" />
<xsl:if test="local-name() = 'sound'">
<xsl:param name="soundtime" select="@time" />
</xsl:if>
<xsl:if test="local-name() = 'word'">
<word sound = "{$soundtime}" >
<xsl:value-of select="." /> 
</word>
</xsl:if>
</xsl:template>
</xsl:stylesheet>



 
____________________________________________________________________________________
Cheap talk?
Check out Yahoo! Messenger's low PC-to-Phone call rates.
http://voice.yahoo.com

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.