xsl-list
[Top] [All Lists]

Re: [xsl] PARAMS and VARIABLES in XSL

2007-01-30 14:20:57
  Hi

  Obviously, Michael meant (note the '{' and '}'):

    <word soundtime="{ preceding-sibling::sound[1]/@time }"/>
      <xsl:value-of select="."/>
    </word>

  Regards,

--drkm


--- mark bordelon wrote:

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(_at_)saxonica(_dot_)com> 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(_at_)yahoo(_dot_)com] 
Sent: 30 January 2007 19:42
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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



--~------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





 

____________________________________________________________________________________
Sucker-punch spam with award-winning protection. 
Try the free Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/features_spam.html

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





        

        
                
___________________________________________________________________________ 
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 
Profitez des connaissances, des opinions et des expériences des internautes sur 
Yahoo! Questions/Réponses 
http://fr.answers.yahoo.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--