You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Sangita Gupta <sa...@xpedior.com> on 2000/03/22 19:12:18 UTC

Re: Generate XML from DTD

Thanks Tom. This gives me something to chew on. I will research it further and
keep you posted with the latest.
Sangita

"Watson, Tom" wrote:

> I have been researching this also and there would seem to be a lot of demand
> since lots of corporate data is in flat files.  I have basically seen three
> approaches:
>
> 1. Create a java application that reads in your DTD, reads in your data (a
> line at a time)  and then creates the internal DOM structure using those two
> sources.  Once you have the internal DOM built, you can serialize the XML as
> an output stream.
>
> Advantages - everything is done in one program
> Disadvantages - fairly complex and dependent upon a specific implementation
> of parser (IBM xml4j version 2 API)
>
> Take a look at "XML and Java Building Web Applications" by Maruyama, Tamura
> and Uramoto...chapter 3.
>
> 2. (courtesy of Doug Tidwell)
> a simpler approach would be a Java application that reads in your data and
> simply creates XML tags associated with each column.  Somthing like this,
>
> <?xml version="1.0"?>
> <document>
>   <row>
>     <column 1>xxxxx</column1>
>     <column 2>xxxxx</column2>
>     .....
>   </row>
>   ....more rows....
> </document>
>
> then, you use xalan and stylesheets to "render" this XML format into a
> format suitable for your particular application, where you do conversion of
> columns to actual meaningful tags:
>
> ...
> <employees>
>   <employee sex="F">
>     <serial number>000000</serial number>
>     <name>
>         <first_name>john</first_name>
>         <last_name>doe</last_name>
>     </name>
>     .....
>
> the last step is to run it against the parser to validate against your DTD
>
> Advantage - much simpler and parser independence
> Disadvantage - more programs/steps/coordination required
>
> 3. buy from a vendor (I am researching this but have not found much).
>
> Tom Watson