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 May 9th, 2006, 02:13 PM
Registered User
 
Join Date: May 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default One XML to Multiple XML file

I have below XML file which is generated from Mainframe. I want below multiple xmls and xsd file to use in my .net program. As I am new to XSLT, please help me in this regards.

[u]INPUT XML</u>
<?xml version="1.0" encoding="utf-8"?>
<records>
  <fields>
    <field name="doccreated" type="DateTime" />
    <field name="docmodified" type="DateTime" />
    <field name="ModifiedBy" type="String" />

  </fields>
  <record>
    <field name="doccreated" type="DateTime">2006-05-03</field>
    <field name="docmodified" type="DateTime">2006-05-03</field>
    <field name="ModifiedBy" type="String">ABC</field>

  </record>
  <record>
    <field name="doccreated" type="DateTime">2006-05-05</field>
    <field name="docmodified" type="DateTime">2006-05-05</field>
    <field name="ModifiedBy" type="String">DEF</field>

  </record>
......
............
.............


</records>

[u]OUTPUT XMLS I NEED</u>

[u]a.xsd</u>
<fields>
    <doccreated/>
    <docmodified/>
    <ModifiedBy/>

  </fields>



[u]b.xml</u>
<?xml version="1.0" encoding="utf-8"?>
<abc:record>
    <doccreated>2006-05-03</doccreated/>
    <docmodified>2006-05-03</docmodified/>
    <ModifiedBy>ABC</ModifiedBy>

</abc:record>


[u]c.xml</u>
<?xml version="1.0" encoding="utf-8"?>
<abc:record>
    <doccreated>2006-05-05</doccreated/>
    <docmodified>2006-05-05</docmodified/>
    <ModifiedBy>DEF</ModifiedBy>

</abc:record>


...
...
...

d.xml
...



 
Old May 9th, 2006, 02:26 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Generating multiple output files is a standard feature in XSLT 2.0 (the xsl:result-document instruction) but not in XSLT 1.0. Some XSLT 1.0 processor offer an extension to do this.

Given your environment, I would suggest downloading Saxon for .NET (which is an XSLT 2.0 processor) and using xsl:result-document.

The code is then something like:

<xsl:template match="fields">
  <xsl:result-document href="{position()}.xml">
    <record>
      <doccreated>
         <xsl:value-of select="field[@name='doccreated']"/>
      </
      <docmodified>
         <xsl:value-of select="field[@name='docmodified']"/>
      </
    </
  </
</

etc.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 9th, 2006, 03:55 PM
Registered User
 
Join Date: May 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you for your quick reply.
but my file attribute are not fixed. It is variable like
<doccreated/> --- <doc>
    <docmodified/>---<abc>
    <ModifiedBy/>---<def>

so i cannot hardcode this
<doccreated>
         <xsl:value-of select="field[@name='doccreated']"/>
      </
.


I ll look Saxon for .Net but I need immediate solution for the above.


Please help me



 
Old May 11th, 2006, 12:24 PM
Registered User
 
Join Date: May 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

mhkay I am waiting response from you. Please help me







Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple input xml / get data from other xml file elayaraja.s XSLT 3 July 25th, 2008 06:59 AM
Convert 1 big XML to multiple smaller XML victorcorey XSLT 1 March 20th, 2008 05:59 AM
DTS Package, XML task. Read XML file and store it Victoria SQL Server DTS 0 July 24th, 2006 02:43 PM
grouping multiple xml files in one file bcogney XSLT 3 April 21st, 2006 03:58 AM
Multiple XML File Problem jhunsake XSLT 1 July 7th, 2004 05:01 AM





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