Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > conversion from one *format in a text file* -> to xml

Reply
Thread Tools

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

 
 
Raghavendra Mahuli
Guest
Posts: n/a
 
      11-03-2005
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


 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?J=FCrgen_Kahrs?=
Guest
Posts: n/a
 
      11-03-2005
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.
 
Reply With Quote
 
 
 
 
shaun
Guest
Posts: n/a
 
      11-03-2005
In article <dkcirv$8l5$(E-Mail Removed)>,
"Raghavendra Mahuli" <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Announce] Stylus Studio 2007 XML Enterprise Suite Released: XML Pipeline, XML Publishing and Data Conversion API's stylusstudio@gmail.com Java 0 09-26-2006 05:04 PM
[ANN] Stylus Studio 2007 XML Enterprise Suite Released: XML Pipeline, XML Publishing and Data Conversion API's Stylus Studio XML 0 09-26-2006 04:49 PM
XML schema validation of one xml block based on values from another xml block Andy XML 0 11-18-2004 11:04 PM
Help on including one XML document within another XML document using XML Schemas Tony Prichard XML 0 12-12-2003 03:18 PM
Using One XSLT and multiple XML Problem (One is XML and another one is XBRL) loveNUNO XML 2 11-20-2003 06:47 AM



Advertisments