469,347 Members | 1,999 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,347 developers. It's quick & easy.

conversion from one *format in a text file* -> to xml

Hello,

I have a text file in which records are stored in a particular format. For
ex:

Node1( att1, att2, node2(attx))

I need to convert it to xml. I know xsl can be used to convert *xml to* some
other format. But i need the reverse operation.
Same thing in xml has to be transformed to something like(need not be
exactly):

<n name="Node1">
<a> att1</a>
<a> att2</a>
<n name="node2">
<a>attx</a>
</n>
</n>

Can u pls give me some pointers to convert a predefined format to xml.
thanks in advance.
warm regards
Nov 3 '05 #1
2 1208
Raghavendra Mahuli wrote:
I have a text file in which records are stored in a particular format. For
ex:

Node1( att1, att2, node2(attx))


This looks like the parameters like node2 may be
deeply nested. In this case, you really need a
parser for your own data format. This is not as
trivial as converting simple tables to XML.

You probably need something like lex and yacc in
this case. As an alternative, I have used awk for
implementing such a parser.
Nov 3 '05 #2
In article <dk**********@ns2.fe.internet.bosch.com>,
"Raghavendra Mahuli" <ra************@in.bosch.com> wrote:
Hello,

I have a text file in which records are stored in a particular format. For
ex:

Node1( att1, att2, node2(attx))

I need to convert it to xml. I know xsl can be used to convert *xml to* some
other format. But i need the reverse operation.
Same thing in xml has to be transformed to something like(need not be
exactly):

<n name="Node1">
<a> att1</a>
<a> att2</a>
<n name="node2">
<a>attx</a>
</n>
</n>


Take a look at :
http://www.idealliance.org/proceedin...-paper.html#S2
..
if you have access to XSLT 2.0 (e.g. via Michael Kays saxon 8.x.x) then
you can 'upconvert' plaintext to xml using an xslt. I had a similar
task, but i have to admit I ended up using a lot of "tokenize" followed
by "for-each" structures rather than the "analyze-string" as advocated
in the article. My regex wasn't up to scratch, probably.
cheers
shaun
Nov 3 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Dillon Mantle | last post: by
22 posts views Thread by kalio80 | last post: by
4 posts views Thread by kalio80 | last post: by
8 posts views Thread by Bill Nguyen | last post: by
10 posts views Thread by el__marcin | last post: by
6 posts views Thread by Oleg | last post: by
1 post views Thread by Vic | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.