File: Data.xml
<?xml version="1.0" encoding="UTF-8"?>
<greeting>
<welcome xml:lang="en" id="001">Welcome</welcome>
<welcome xml:lang="fr" id="002">Bienvenue</welcome>
<welcome xml:lang="es" id="003">Bienvenido</welcome>
<welcome xml:lang="de" id="004">Willkommen</welcome>
</greeting>
File: Transform.xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="greeting">
<xsl:apply-templates select="welcome[lang('de')]" />
</xsl:template>
<xsl:template match="welcome[lang('de')]">
<xsl:text>German: </xsl:text>
<xsl:value-of select="." />
<xsl:text> (ID: </xsl:text>
<xsl:value-of select="@id" />
<xsl:text>)</xsl:text>
</xsl:template>
</xsl:stylesheet>
Output:
German: Willkommen (ID: 004)
|