Subject: [xsl] Re: Complicated transformation step when using localization From: knocte <knocte@xxxxxxxxx> Date: Thu, 13 Oct 2005 10:11:32 +0200 |
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 ]
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Complicated transformation st, knocte | Thread | [xsl] best validation was Re: [xsl], bryan rasmussen |
Re: [xsl] Opinions, please. Keep en, James Fuller | Date | RE: [xsl] Merging 2 XML's in to 1 o, Michael Kay |
Month |