Skip to content

Instantly share code, notes, and snippets.

@thevery
Created January 2, 2011 16:38
Show Gist options
  • Save thevery/762634 to your computer and use it in GitHub Desktop.
Save thevery/762634 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:variable name="with" select="'translation.xml'"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/resources/string">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:variable name="info"
select="document($with)/resources/string[src/node()=current()/node()]/."/>
<xsl:choose>
<xsl:when test="$info">
<xsl:copy-of select="$info/dst/node()"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="current()/node()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
</xsl:transform>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment