how to convert XML document to several XML documents in a new format

E

enyetor

I'm migrating data into a content management system and in order to use
the import tool provided I need to change the format of a large xml
file and convert each entry to a seperate xml file.

This is what I have now:


<?xml version="1.0" encoding="UTF-8" ?>

<dataroot xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata"
generated="2005-04-18T12:05:51">
<Checklist>
<ID>1</ID>
<Category>stuff</Category>
<Type>stuff</Type>
<Item>stuff</Item>
<Steps>stuff</Steps>
</Checklist>
<Checklist>
<ID>2</ID>
<Category>stuff</Category>
<Type>stuff</Type>
<Item>stuff</Item>
<Steps>stuff</Steps>
</Checklist>
<Checklist>
<ID>3</ID>
<Category>stuff</Category>
<Type>stuff</Type>
<Item>stuff</Item>
<Steps>stuff</Steps>
</Checklist>
<Checklist>
<ID>4</ID>
<Category>stuff</Category>
<Type>stuff</Type>
<Item>stuff</Item>
<Steps>stuff</Steps>
</Checklist>
</dataroot>



This is what I need each entry to be as a single file:

<?xml version="1.0" ?>
<file DocType="TypeName" DocTitle="TITLE:testing 123"
DocDesc="TITLE:testing 123">
<section name="Category">
<![CDATA[
stuff
]]>
</section>
<section name="Type">
<![CDATA[
stuff
]]>
</section>
<section name="Item">
<![CDATA[
stuff
]]>
</section>
<section name="SLA">
<![CDATA[
stuff
]]>
</section>
<section name="Troubleshooting Steps">
<![CDATA[
stuff
]]>
</section>
</file>

I need some direction on how to accomplish this task...
 
M

Martin Honnen

I'm migrating data into a content management system and in order to use
the import tool provided I need to change the format of a large xml
file and convert each entry to a seperate xml file.

XSLT 1.1 respectively 2.0 can produce multiple output documents so you
could look at an XSLT processor which implements 1.1 or 2.0 or its own
extension function to produce multiple output documents.

Saxon 6.5 implements XSLT 1.1, Saxon 8 implements 2.0, info is here
<http://saxon.sourceforge.net/>
 
T

TextDoctor

If you actually need to perform formatting of the text, try TEXTools.
It's an inexpensive shareware product designed for heavy-duty text
processing that might do the trick for you. Instead of declaring
variables, creating loops, etc., you simply combine filters into a
"pipe" that, when executed, does all the text processing work for
you... You can find TEXTools at www.fireflysoftware.com. Best of
luck!

Barry Block
Firefly Software
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,128
Latest member
ElwoodPhil
Top