Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Text file to XML file

From: ptjm@--------.--- (------- -- ------)
To: NULL
Date: 8/2/2004 4:42:00 AM
In article <rbuOc.8728$pc.461269@n...>,
Rizwan <hussains@p...> wrote:

% I have the following tasks :
% 1) receive a flat text file which contains data and
% 2) convert it into an XML

I don't think there's any point in using specialised tools to
create XML. Reading it is different. Use a parser to read it. Don't
write your own parser unless you're interested in understanding all
the ins and outs and getting them right, but creating XML is close
to trivial.

The things you need to be careful of:

 - character sets. You have to know what character set was used to
   encode your input data and either declare the XML file to use that
   data or convert it to UTF-8;
 - < and &. Replace them with &lt; and &amp;.

Before you start, you ought to design the output format and document it
either by writing a DTD, a w3c schema or a RELAX NG schema. This will be
more work than creating the conversion program, but it will be helpful
in ensuring the conversion is valid XML.

There are some philosophical issues in the design. Should each record be
represented by an empty element with a bunch of attributes, or by an
element with a bunch of other elements containing CDATA for the data?
Should each record be a `record' element, or should I go for
interoperability by describing the type of record? Should I give my data
a name space or is this too obvious a question and I just left it out of
my example for the sake of brevity?

Except for the last one, you seem to have resolved these issues in a
satisfactory manner, so damn the torpedos and have fun.
-- 

Patrick TJ McPhee
East York  Canada
ptjm@i...


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent