p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > XML > XML
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XML General XML discussions.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 14th, 2003, 01:22 PM
lxu lxu is offline
Authorized User
Points: 122, Level: 2
Points: 122, Level: 2 Points: 122, Level: 2 Points: 122, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2003
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Merge XML files into a xml file using xslt

I have over 20 xml schema files and want to generate a xml file. I have to use xslt. Any suggestion?

Thanks in advance.

LX

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old October 17th, 2003, 09:56 AM
joefawcett's Avatar
Wrox Author
Points: 8,994, Level: 40
Points: 8,994, Level: 40 Points: 8,994, Level: 40 Points: 8,994, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 2,922
Thanks: 0
Thanked 13 Times in 12 Posts
Default

What do you mean?
You want to merger the 20 files to one large schema or create an xml that satisfies all the schemas?

Joe (MVP - xml)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old November 3rd, 2003, 10:53 AM
lxu lxu is offline
Authorized User
Points: 122, Level: 2
Points: 122, Level: 2 Points: 122, Level: 2 Points: 122, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2003
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the response. I have solved the problem.

I am looking for the solution or idea of coverting flat files into a xml file. Using Java programming would be easier for me. But my boss wants me to use xslt. I have converted each flat files into a .xml file. What is the better way for the next step?

Thanks again,

LX

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old November 3rd, 2003, 11:16 AM
joefawcett's Avatar
Wrox Author
Points: 8,994, Level: 40
Points: 8,994, Level: 40 Points: 8,994, Level: 40 Points: 8,994, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 2,922
Thanks: 0
Thanked 13 Times in 12 Posts
Default

If you want to convert a number of separate xml documents into one then you need to create a new master document and have each old document as a child. The easiest way I can think of is to create a config file such as this with a list of all the documents you need merging:
Code:
<mergeData newRoot="newRoot">
  <fileList>
    <fileItem>myFile1.xml</fileItem>
    <fileItem>myFile2.xml</fileItem>
    <fileItem>myFile3.xml</fileItem>
  </fileList>
</mergeData>
With msxml you can use a path relative to the stylesheet but with some processors you may need the full url, file:///c:/myFolder/myFile.xml for example.
Your stylesheet looks like:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <xsl:element name="{mergeData/@newRoot}">
      <xsl:apply-templates select="mergeData/fileList/fileItem"/>
    </xsl:element>
  </xsl:template>
  <xsl:template match="fileItem">    
    <xsl:copy-of select="document(.)"/>
  </xsl:template>
</xsl:stylesheet>
Replace the newRoot attribute value with your choice of new document element.

This simple merger won't work with source xml files that have embedded DTDs but given that you created these files from flat files this seems unlikely.

Joe (MVP - xml)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old November 6th, 2003, 06:01 PM
lxu lxu is offline
Authorized User
Points: 122, Level: 2
Points: 122, Level: 2 Points: 122, Level: 2 Points: 122, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2003
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT between two XML files NEO1976 XSLT 15 July 24th, 2006 09:52 AM
Problem to create an xml file from two xml files saurabh_inblore XSLT 1 April 12th, 2006 03:58 AM
merge two xml file and make new xml using xslt ketan XSLT 0 September 21st, 2004 09:48 AM
Merge two Similar XML files myunus XML 5 August 5th, 2004 12:12 AM
Merge xml schema files mayada XSLT 0 April 16th, 2004 11:37 AM



All times are GMT -4. The time now is 03:01 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc