[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Complicated transformation step when using localizatio

Subject: Complicated transformation step when using localization
From: knocte <knocte@xxxxxxxxx>
Date: Thu, 13 Oct 2005 05:22:26 +0200
transformation step
Hello list!
I am trying to make a transformation step but I can't get it to work!

I will receive an XML document with many nodes. Some of them may contain the attribute "translate-attrs":

<img src="myURI" alt="translate me" title="me too" translate-attrs="alt title" />

I want to select all the nodes that have this attribute and replace the content of the attributes with the content of an external file, like this:

 <text key="translate me">Translate me, in other language</text>
 <text key="me too">Me too, in other idiom</text>

Expected final XML result would be:

<img src="myURI" alt="Translate me, in other language" title="Me too, in other idiom" />

So first we want to match all the nodes that have this attribute:

<xsl:template match="*[@translate-attrs]">

Then we want to copy all attributes except the one mentioned:

<xsl:copy-of select="@*[not (local-name()='translate-attrs')]" />

Now I want to do a for-each part which captures all of the terms separated by spaces that are contained in the translate-attrs attribute, and make an attribute by each, with the content of the external XML file, but I can't achieve it! It would be something like:

<xsl:for-each select"@translate-attrs">
<xsl:attribute name=".">
<xsl:value-of select="document($myxml)//external-dictionary/text[@key = current()/@{.}]" />

Finally, we need to copy the rest of the child elements:

 <xsl:apply-templates />

Does anybody know how can I make the middle part, the most difficult one? Any help will be appreciated!


Andrew [ knocte ]


Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.