|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Complicated transformation step when using localizatio
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: <external-dictionary> <text key="translate me">Translate me, in other language</text> <text key="me too">Me too, in other idiom</text> </external-dictionary> 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()/@{.}]" /> </xsl:attribute> </xsl:for-each> Finally, we need to copy the rest of the child elements: <xsl:apply-templates /> </xsl:template> Does anybody know how can I make the middle part, the most difficult one? Any help will be appreciated! Regards, Andrew [ knocte ] --
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








