Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Xml to xml transformation

From: "Shailesh" <shailesh@--------.--->
To: <xml-dev@-----.---.--->
Date: 8/3/2005 7:09:00 AM
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent