Stefan: "copy-of" kombiniert mit "translate" - wie geht's?

Beitrag lesen

Hallo Thomas,

vielen Dank für Deine Mühen. Leider klappt es alles nicht, daher mal etwas ausführlicher ...

Ich habe z.B. folgende XML-Datei (sample.xml):

  
<?xml version="1.0" encoding="UTF-8"?>  
    <heading xml:lang="EN-US">abc</heading>  
    <para xml:lang="EN-US">abc</para>  

Das dazugehörige xsl (sample.xsl) sieht so aus:

  
<?xml version="1.0" encoding="utf-8"?>  
    <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>  
    <xsl:output encoding="UTF-8" indent="yes"/>  
  
    <xsl:variable name="source" select="abc" />  
    <xsl:variable name="target" select="ABC" />  
  
    <xsl:template match="*">  
        <xsl:copy>  
            <!-- <xsl:copy-of select="translate(@*, $source, $target)" /> -->  
            <xsl:copy-of select="@*" />  
            <xsl:apply-templates />  
        </xsl:copy>  
    </xsl:template>  
  
</xsl:stylesheet>  

Das XSL dupliziert den kompletten Baum in eine neue Datei so wie er eben auch in der sample.xml ist, i.e. sie sieht nach der Transformation noch genauso aus wie vorher.
Nun will ich aber zusätzlich die translation machen. Wenn ich aber
<xsl:copy-of select="@*" />
in
<xsl:copy-of select="translate(@*, $source, $target)" />
oder
<xsl:copy-of select="translate(@*|*, $source, $target)" />
oder
<xsl:copy-of select="translate(@*|node(), $source, $target)" />
ändere, führt das nicht zum Erfolg.
Das Ergebnis ist dann

  
<?xml version="1.0" encoding="UTF-8"?>  
    <heading>EN-USabc</heading>  
    <para>EN-USabc</para>  

statt

  
<?xml version="1.0" encoding="UTF-8"?>  
    <heading xml:lang="EN-US">ABC</heading>  
    <para xml:lang="EN-US">ABC</para>  

Das Ganze ist also noch falsch, nur wie geht es richtig?

Ratlos: Stefan.