|
Subject: RE: [xsl] replacing values in file1 from file2 From: <Jarno.Elovirta@xxxxxxxxx> Date: Thu, 25 Mar 2004 14:24:39 +0200 |
Hi,
> <file1>
> <terms>
> <source lang="english">
> <term>dog</term>
> </source>
> <source lang="danish">
> <term>dog</term>
> </source>
> </terms>
> <terms>
> <source lang="english">
> <term>dog</term>
> </source>
> <source lang="danish">
> <term>dog</term>
> </source>
> </terms>
> </file1>
>
> <file2>
> <tranlated>
> <term lang="danish">hund</term>
> <term lang="danish">bord</term>
> </translated>
> </file2>
>
> I've tried matching a nodeset in file1 using <..
> match="//source[@lang='danish']/term"> seems fine. Then I've tried to
With match patterns the leading // is not needed, just use
<xsl:template match="source[@lang='danish']/term">
> copy-of the value from select="document('file2.xml')//term/text()" in
> various ways. I get the first value only from the list
> copied, but in all
> the locations I wanted. How do I pass on the number of the
> node in the first
> nodeset to the nodeset selected from the second file. I tried
> setting up a
> variable using position() but couldn't get it to work.
If you've simplified your source, then I suppose you can't change the source to use proper keys, instead of relying on the position for a match. First you want to know your position in file1
<xsl:variable name="position" select="count(../../preceding-sibling::terms)"/>
Then get the translated term
<xsl:value-of select="document('file2.xml')//term[count(preceding-sibling::term) = $position]"/>
For performance you want to replace the // walking with file2/translated, and also you might want to consider using keys: just use the preceding term sibling count as the key.
Cheers,
Jarno - Melotron: Manchmal
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] replacing values in file1, M. David Peterson | Thread | RE: [xsl] replacing values in file1, ronan martin |
| Re: [xsl] Symbol handling in XSLT, Alex | Date | RE: [xsl] Symbol handling in XSLT, Jarno.Elovirta |
| Month |