xsl-list
[Top] [All Lists]

Re: determining node position by the content of a text node

2005-09-12 04:54:31
Hi,

Tempore 13:33:34, die 09/12/2005 AD, hinc in 
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Thomas Winkler 
<thomasm003(_at_)yahoo(_dot_)de>:

Find a text-node named "Kunde". Then call the
dictionary and search for that word.After finding it,
remember the position of that word, because the
english text node for that German word is one
element-node before.

That's a very fragile algorithm. What garanty is there that the English 
translation is exactly before the German version?

If you'd like to persist with this technique, then at least store the node 
itself, instead of its position (it's not easy to calculate the position within 
xpath).

<xsl:variable name="Germanword" 
select="document('dict.xml')//seg[text()=$trans]"/>
<xsl:variable name="Englishword" select="$Germanword/preceding::seg[1]"/>


In my opinion, it's far better to use keys instead.

e.g. <xsl:key name="term" match="wort" use="concat(@xml:lang,'-',seg)"/>

<xsl:variable name="Englishword">
        <xsl:for-each select="document('dict.xml')">
                <xsl:value-of 
select="key('term',concat('de-',$trans))/../wort[(_at_)xml:lang='en']"/>
        </xsl:for-each>
</xsl:variable>

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Laudeo W3C et dona ferens

--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>