Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 20th, 2005, 01:08 AM
Authorized User
 
Join Date: Apr 2005
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default Xml to Xml Transformation using xslt

Hi Friends,

I have to transform source xml file to another xml file using xslt. I am Confused!

For Example:
My source xml contains:
<?xml version="1.0" encoding="UTF-8" ?>
<office-document xmlns:text="http://openoffice.org/2000/text">
  <text:p text:style-name="Text body" text:index-qualifier="xml:tm description">
        xml:tm is a radical new approach
        <text:index name="radical new approach"/>
        to dealing with the problems of translation
        memory for XML documents by using XML syntax to embed memory
        directly into the XML documents themselves.
        It makes extensive use of XML namespace.
   </text:p>
</office-document>

Using xsl how will I transfrom it to :
Output xml:
<?xml version="1.0" encoding="UTF-8" ?>
 <office-document xmlns:text="http://openoffice.org/2000/text"
     xmlns:text="http://openoffice.org/2000/text"
     xmlns:tm="urn:xmlintl-tm-tags">
  <tm:tm te="543" ta="41" version="2.0" uid="8fba2f33" source-language="en-US" date="2003-12-18T13:06:52Z"
      xmltm-version="1.0" tool-name="XYZ Tool" tool-version="1.23">
    <tm:vh version="1.0" date="2003-05-02T14:15:03Z"/>
  <text:p text:style-name="Text body">
    <tm:ta id="a1" name="text:index-qualifier" version="1.0">
       xml:tm description
    </tm:ta>
    <tm:te id="e1" tu="2" version="1.0">
      <tm:tu id="u1.1" ti="1" crc="3275b242" version="1.0">
        xml:tm is a radical new approach
        <text:index>
           <tm:ti id="i1.1.1" name="text:name" crc="9114ce48" version="2.0">
            radical new approach
           </tm:ti>
        </text:index>
        to dealing with the problems of translation
        memory for XML documents by using XML syntax to embed memory
        directly into the XML documents themselves.
      </tm:tu>
      <tm:tu id="u1.2" crc="306bf701" version="1.0">
        It makes extensive use of XML namespace.
      </tm:tu>
    </tm:te>
  </text:p>
</tm:tm>
 </office-document>

Can you please help me this.

Thanks,
Shailesh

 
Old July 20th, 2005, 01:20 AM
Authorized User
 
Join Date: Apr 2005
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

HI Friends,

I have posted xml and the required xml file, sorry for not posting xslt on which i am working, xslt is new fro me but still tried to do some stupid things.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes" xmlns:tm="urn:xmlintl-tm-tags" xmlns:text="http://openoffice.org/2000/text">
<xsl:output method="xml"/>
<xsl:template match="office-document">
<xsl:attribute name="xmlns:tm" namespace="urn:xmlintl-tm-tags">urn:xmlintl-tm-tags</xsl:attribute>
<xsl:element name="tm:tm">
<xsl:attribute name="te"></xsl:attribute><xsl:attribute name="ta"></xsl:attribute><xsl:attribute name="version"></xsl:attribute>
<xsl:attribute name="uid"></xsl:attribute><xsl:attribute name="source-language"></xsl:attribute><xsl:attribute name="date"></xsl:attribute>
<xsl:attribute name="xmltm-version"></xsl:attribute><xsl:attribute name="tool-name"></xsl:attribute><xsl:attribute name="tool-version"></xsl:attribute>
</xsl:element>
<xsl:element name="tm:vh">
<xsl:attribute name="version">1.0</xsl:attribute><xsl:attribute name="date">2003-05-02T14:15:03Z</xsl:attribute>
</xsl:element>
</xsl:template>
<xsl:template match="text:p">
<xsl:element name="tm:ta">
<xsl:attribute name="id"></xsl:attribute><xsl:attribute name="name"><xsl:text>name=</xsl:text><xsl:value-of select="@text:index-qualifier"/><xsl:text></xsl:text></xsl:attribute>
<xsl:attribute name="version">1.0</xsl:attribute>
</xsl:element>
<xsl:element name="tm:te">
<xsl:attribute name="id"></xsl:attribute><xsl:attribute name="ti"></xsl:attribute><xsl:attribute name="crc"></xsl:attribute>
<xsl:attribute name="version"></xsl:attribute><xsl:value-of select="."/>
<xsl:template match="text:index">
<xsl:element name="tm:ti"><xsl:attribute name="id"></xsl:attribute><xsl:attribute name="name"><xsl:text>text:name</xsl:text></xsl:attribute>
<xsl:attribute name="crc"></xsl:attribute><xsl:attribute name="version"></xsl:attribute>
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
</xsl:element>
</xsl:template>
</xsl:stylesheet>







Similar Threads
Thread Thread Starter Forum Replies Last Post
Is XML supports transformation of HTML to XML? zeeonline XSLT 1 July 28th, 2006 05:13 PM
Problem in XML to XML transformation jkuravatti XSLT 2 May 5th, 2006 11:21 AM
XSLT transformation from XML buffer and XSL file sundaramkumar Javascript 1 September 5th, 2005 02:11 AM
XSLT for complicated xml to xml transf. required doug@sirvisetti XSLT 3 June 17th, 2005 04:26 PM
XML to XML transformation using XSLT karjagis XSLT 3 July 30th, 2004 06:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.