Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 9th, 2006, 02:13 PM
Registered User
 
Join Date: May 2006
Location: , , .
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
...



Reply With Quote
  #2 (permalink)  
Old May 9th, 2006, 02:26 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
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
Reply With Quote
  #3 (permalink)  
Old May 9th, 2006, 03:55 PM
Registered User
 
Join Date: May 2006
Location: , , .
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



Reply With Quote
  #4 (permalink)  
Old May 11th, 2006, 12:24 PM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

mhkay I am waiting response from you. Please help me


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:38 AM.


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