p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   merge two xml file and make new xml using xslt (http://p2p.wrox.com/showthread.php?t=18710)

ketan September 21st, 2004 08:48 AM

merge two xml file and make new xml using xslt
 
hi,
 i have to use xslt for merge two xml file and make a new one.
here my two files...
*******m1.xml*******
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="merge.xsl"?>
<row-data1>
<rec>
      <date1>080104</date1>
      <description>CT-</description>
      <minutes>10</minutes>
</rec>
<rec>
      <date1>080304</date1>
      <description>Telephone</description>
      <minutes>30</minutes>
</rec>
<rec>
      <date1>080504</date1>
      <description>CT-</description>
      <minutes>50</minutes>
</rec>
<rec>
      <date1>080704</date1>
      <description>Telephone</description>
      <minutes>70</minutes>
</rec>
</row-data1>
*****************m2.xml*********
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="merge.xsl"?>
<row-data2>
<rec>
      <date1>080204</date1>
      <description>DDDDD</description>
      <minutes>20</minutes>
</rec>
<rec>
      <date1>080404</date1>
      <description>EEEEE</description>
      <minutes>40</minutes>
</rec>
<rec>
      <date1>080604</date1>
      <description>FFFFF</description>
      <minutes>60</minutes>
</rec>
</row-data2>
************merge.xsl*********
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"><xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<root>
<xsl:for-each select="document('m1.xml')/rec-data1/rec|
document('m2.xml')/rec-data2/rec[not(@date1=document('m1.xml')/rec-data1/rec/@date1)]">
<xsl:sort select="@date1"/><rec date1="{@date1}">
</rec>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>
***************************
you give me the full updated sourcecode ...
I am newbie in xml/xsl....pl. give me the full sourcecode/change in all three files....and also let me know how i can make a new merge xml document.....

thanks

ketan


All times are GMT -4. The time now is 05:41 AM.

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