xsl-list
[Top] [All Lists]

determining node position by the content of a text node

2005-09-12 04:33:34
I want to translate (German <-->English) some XML
documents. Therefore I have created a dictionary
dict.xml).

My stylesheet should work like this :

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.

See the dict.xml :


...
<tu>
  <wort xml:lang="en"><seg>login</seg></wort>
  <wort xml:lang="de"><seg>Anmeldung</seg></wort>
</tu>

<tu>
  <wort xml:lang="en"><seg>customer</seg></wort>
  <wort xml:lang="de"><seg>Kunde</seg></wort>
</tu>

<tu>
  <wort xml:lang="en"><seg>order</seg></wort>
  <wort xml:lang="de"><seg>Bestellung</seg></wort>
</tu>

<tu>
  <wort xml:lang="en"><seg>browse</seg></wort>
  <wort xml:lang="de"><seg>suchen</seg></wort>
</tu>
...

My first thought was to create a stylesheet like this
but obviously the Xpath expression position() cannot
be used like that.

...
<xsl:template match="*[text()='Kunde']">
 <xsl:variable name="trans" select="text()"/>
  <xsl:variable name="pos"
select="number(document('dict.xml')//seg[text()=$trans]/position())"/>

<xsl:variable name="replace"
select="string(document('dict.xml')//wort[$pos][1])"/>
...



Can anyone help me ? Thanks in advance !



        

        
                
___________________________________________________________ 
Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: 
http://mail.yahoo.de

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