Subject: RE: [xsl] PARAMS and VARIABLES in XSL From: mark bordelon <markcbordelon@xxxxxxxxx> Date: Tue, 30 Jan 2007 13:14:51 -0800 (PST) |
Dave, thanks for the quick reply. This did not work. It transformed to the following using Altova version 2007: <?xml version="1.0" encoding="UTF-8"?><word soundtime="preceding-sibling::sound[1]/@time"/>ja<word soundtime="preceding-sibling::sound[1]/@time"/>ty<word soundtime="preceding-sibling::sound[1]/@time"/>on<word soundtime="preceding-sibling::sound[1]/@time"/>my<word soundtime="preceding-sibling::sound[1]/@time"/>vy<word soundtime="preceding-sibling::sound[1]/@time"/>oni<word soundtime="preceding-sibling::sound[1]/@time"/>eto<word soundtime="preceding-sibling::sound[1]/@time"/>to<word soundtime="preceding-sibling::sound[1]/@time"/>zdjes`<word soundtime="preceding-sibling::sound[1]/@time"/>tut<word soundtime="preceding-sibling::sound[1]/@time"/>tam<word soundtime="preceding-sibling::sound[1]/@time"/>kto<word soundtime="preceding-sibling::sound[1]/@time"/>chto<word soundtime="preceding-sibling::sound[1]/@time"/>gdje<word soundtime="preceding-sibling::sound[1]/@time"/>kogda<word soundtime="preceding-sibling::sound[1]/@time"/>kak<word soundtime="preceding-sibling::sound[1]/@time"/>nje<word soundtime="preceding-sibling::sound[1]/@time"/>vsje --- Michael Kay <mike@xxxxxxxxxxxx> wrote: > Looks like > > <xsl:template match="clause"> > <xsl:apply-templates select="word"/> > </xsl:template> > > <xsl:template match="word"> > <word > soundtime="preceding-sibling::sound[1]/@time"/> > <xsl:value-of select="."/> > </ > </ > > Michael Kay > http://www.saxonica.com/ > > > -----Original Message----- > > From: mark bordelon > [mailto:markcbordelon@xxxxxxxxx] > > Sent: 30 January 2007 19:42 > > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > > Subject: [xsl] 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 > > ____________________________________________________________________________________ Sucker-punch spam with award-winning protection. Try the free Yahoo! Mail Beta. http://advision.webevents.yahoo.com/mailbeta/features_spam.html
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] PARAMS and VARIABLES in X, Michael Kay | Thread | Re: [xsl] PARAMS and VARIABLES in X, Florent Georges |
[xsl] Simple Question, Punnoose, Roshan | Date | Re: [xsl] PARAMS and VARIABLES in X, mark bordelon |
Month |