I searched for a solution on the internet but didn´t find one. I´m not even sure if this is possible or what causes this behaviour. I´m trying to copy a node content to a nother node. It works without a problem, but then in the first node is a tag (xliff:g), only the tag text element is copied.
What i´m missing, or why at all this tag is not copied ?
Here is my input xml:
<?xml version="1.0"?>
<texts xmlns:android="http://schemas.android.com/apk/res/android" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<?xml-stylesheet href="hello.xsl" type="text/xsl"?>
<strings>
<string name="cpu">
<en>example1</en>
<de name="cpu">"something <xliff:g id="WIDGET_HOST_NAME">%1$s</xliff:g> something1</de>
<es>""</es>
</string>
<string name="gpu">
<en>example2</en>
<de name="gpu">something2<xliff:g id="WIDGET_HOST_NAME">%1$s</xliff:g></de>
<es>""</es>
</string>
<string name="mainboard">
<en>example3</en>
<de><xliff:g id="WIDGET_HOST_NAME">%1$s</xliff:g></de>
<es>""</es>
</string>
</strings>
</texts>
My xsl to transform the xml:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="strings/string/es/text()">
<xsl:value-of select="../../de"/>
</xsl:template>
</xsl:stylesheet>
And the output where only the text value of the xliff:g tag is copied:
<texts xmlns:android="http://schemas.android.com/apk/res/android" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"><?xml-stylesheet href="hello.xsl" type="text/xsl"?>
<strings>
<string name="cpu">
<en>example1</en>
<de name="cpu">"something <xliff:g id="WIDGET_HOST_NAME">%1$s</xliff:g> something1</de>
<es>"something %1$s something1</es>
</string>
<string name="gpu">
<en>example2</en>
<de name="gpu">something2<xliff:g id="WIDGET_HOST_NAME">%1$s</xliff:g>
</de>
<es>something2%1$s</es>
</string>
<string name="mainboard">
<en>example3</en>
<de>
<xliff:g id="WIDGET_HOST_NAME">%1$s</xliff:g>
</de>
<es>%1$s</es>
</string>
</strings>
</texts>
The desired output would look like this:
<texts xmlns:android="http://schemas.android.com/apk/res/android" xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"><?xml-stylesheet href="hello.xsl" type="text/xsl"?>
<strings>
<string name="cpu">
<en>example1</en>
<de name="cpu">"something <xliff:g id="WIDGET_HOST_NAME">%1$s</xliff:g> something1</de>
<es>"something <xliff:g id="WIDGET_HOST_NAME">%1$s</xliff:g> something1</es>
</string>
<string name="gpu">
<en>example2</en>
<de name="gpu">something2<xliff:g id="WIDGET_HOST_NAME">%1$s</xliff:g>
</de>
<es>something2<xliff:g id="WIDGET_HOST_NAME">%1$s</xliff:g></es>
</string>
<string name="mainboard">
<en>example3</en>
<de>
<xliff:g id="WIDGET_HOST_NAME">%1$s</xliff:g>
</de>
<es><xliff:g id="WIDGET_HOST_NAME">%1$s</xliff:g></es>
</string>
</strings>
</texts>
Maybe someone could help me figuring out what i´am doing wrong, or why the transformation behave like this.
Many thanks in advance Cali