|
|
 |
| 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.
|
 |

October 14th, 2003, 01:22 PM
|
|
Authorized User
|
|
Join Date: Oct 2003
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

October 17th, 2003, 09:56 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 2,922
Thanks: 0
Thanked 13 Times in 12 Posts
|
|
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)
|

November 3rd, 2003, 10:53 AM
|
|
Authorized User
|
|
Join Date: Oct 2003
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

November 3rd, 2003, 11:16 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 2,922
Thanks: 0
Thanked 13 Times in 12 Posts
|
|
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)
|

November 6th, 2003, 06:01 PM
|
|
Authorized User
|
|
Join Date: Oct 2003
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |