[
Lists Home |
Date Index |
Thread Index
]
Hi All,
I have source xml like this:
<?xml version="1.0" encoding="UTF-8"?>
<sample>
<test trans_attr="trans">
<para>Sample para. This needs to be translated</para>
<comments>This is not translated</comments>
</test>
</sample>
Need output xml as:
<?xml version="1.0" encoding="UTF-8"?>
<sample xmlns:tm="urn:xmlintl-tm-tags">
<test trans_attr="trans">
<tm:ta id="a1" name="trans_attr">
<src>trans</src>
<tgt></tgt>
</tm:ta>
<para>Sample para. This needs to be translated</para>
<tm:nxlt><comments>This is not translated</comments></tm:nxlt>
</test>
</sample>
How will I do it with xslt, done some stupid showing no output on browser.
Xslt:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tm="urn:xmlintl-tm-tags">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
<xsl:template match="/">
<sample>
<xsl:attribute name="xmlns:tm" namespace="urn:xmlintl-tm-tags"/>
<xsl:apply-templates select="//test" mode="tm:ta"/>
<xsl:apply-templates select="//comments" mode="tm:nxlt"/>
</sample>
</xsl:template>
<xsl:template match="test">
<xsl:element name="tm:ta">
<xsl:attribute name="name">
<xsl:text>trans_attr</xsl:text>
</xsl:attribute>
</xsl:element>
<xsl:element name="src">
<xsl:value-of select="@trans_attr"/>
</xsl:element>
<xsl:element name="tgt"/>
</xsl:template>
<xsl:template match="comments">
<xsl:element name="tm:nxlt">
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Can anyone help me out?
Thanks,
Shailesh
|