Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   text to xml conversion (http://www.velocityreviews.com/forums/t516457-text-to-xml-conversion.html)

sethridge1991@yahoo.ca 06-21-2007 09:25 PM

text to xml conversion
 
Hi Everyone,

I am trying to send a XML file via SFTP staying completely in UNIX.

The data in the file will vary everytime I create and send it. This is
not a simple address book dump.

This is what I am trying to do:

1. Access my Unix DataBase
2. Depending on the situation, different data, some of it repeating,
gets dumped into a UNIX text file. Because of the potential
combinations of required data, I am embedding the corresponding data
tags around the individual data items when I am deciding which data
should be sent. The data comes from several related DB Files.
My first line in my text file is -<header>.
3. I want to execute a UNIX script that will convert the text file,
login to a SFTP server in batch mode and send the converted file to
the SFTP server.

The SFTP part is ok. It is the conversion to XML that is the problem.
All the examples I see on the Net, involve typical data.

Here is a simple stripped down example of what my text file would look
like (bare in mind, this does not reflect the complexity of the
decision making or data):

-<header>
-<personal_info>
-<name>John Smith</name>
-<address1>123 Main Street</address1>
-<address2>Any City, XX 9999999</address2>
-<status>employed</status>
-<occupation>plumber</occupation>
-<salary>60000</salary>
</personal_info>
-<personal_info>
-<name>Jane Doe</name>
-<address1>100 Maple Street</address1>
-<address2>First City, YY 8888888</address2>
-<status>housewife</status>
</personal_info>
</header>

In this example, people who are employed also require occupation and
salary. The data is not typical. Trying to dump the data comma
separated, in this example, may look easy, but my actual situation
does not lend itself to null fields.

Is there a point where I can start in the conversion and take
advantage of the fact the embedded data tags already exist?

The <?xml> line will be version 1.0, encoding UTF-8, standalone Yes.

I have the full XML Library in my UNIX version (SCO Openserver 5.7).

Any ideas or suggestions would be greatly appreciated.

Regards,
Steve


Joe Kesselman 06-22-2007 12:07 AM

Re: text to xml conversion
 
Decide how you want the XML structured to represent your data.

Gather the data from your database.

Wrap the XML structure around it -- either via text manipulation
(sloppy, has hazards, not recommended) or via the DOM or SAX APIs
feeding into an XML serializer to create the XML file.

Transmit as appropriate.

> The data is not typical.


I have no idea what you mean by "not typical" in this context. That
looks like a typical-to-the-point-of-being-pedestrian application...


--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry

Peter Flynn 06-22-2007 10:54 PM

Re: text to xml conversion
 
sethridge1991@yahoo.ca wrote:
> Hi Everyone,
>
> I am trying to send a XML file via SFTP staying completely in UNIX.
>
> The data in the file will vary everytime I create and send it. This is
> not a simple address book dump.
>
> This is what I am trying to do:


This is extremely confusing.

Sending a file by sftp is trivial. Using scp is even easier.

> 1. Access my Unix DataBase




> 2. Depending on the situation, different data, some of it repeating,
> gets dumped into a UNIX text file. Because of the potential
> combinations of required data, I am embedding the corresponding data
> tags around the individual data items


How? Manually in an editor? Using a programming language? XSLT?

> when I am deciding which data
> should be sent. The data comes from several related DB Files.
> My first line in my text file is -<header>.


I hope not. That hyphen is an artifact of viewing the XML document in a
browser.

> 3. I want to execute a UNIX script that will convert the text file,


You want to convert some kind of unmarked plaintext file to XML, right?

> login to a SFTP server in batch mode and send the converted file to
> the SFTP server.
>
> The SFTP part is ok.


So skip this.

> It is the conversion to XML that is the problem.
> All the examples I see on the Net, involve typical data.


I don't know what "typical" data is.

> Here is a simple stripped down example of what my text file would look
> like (bare in mind, this does not reflect the complexity of the
> decision making or data):
>
> -<header>
> -<personal_info>
> -<name>John Smith</name>
> -<address1>123 Main Street</address1>
> -<address2>Any City, XX 9999999</address2>
> -<status>employed</status>
> -<occupation>plumber</occupation>
> -<salary>60000</salary>
> </personal_info>
> -<personal_info>
> -<name>Jane Doe</name>
> -<address1>100 Maple Street</address1>
> -<address2>First City, YY 8888888</address2>
> -<status>housewife</status>
> </personal_info>
> </header>


OK. That looks straightforward.

> In this example, people who are employed also require occupation and
> salary. The data is not typical. Trying to dump the data comma
> separated, in this example, may look easy, but my actual situation
> does not lend itself to null fields.


This data is not comma-separated, it's XML. Are you trying to convert
comma-separated data to XML, or XML data to comma-separated?

> Is there a point where I can start in the conversion and take
> advantage of the fact the embedded data tags already exist?


Show us an example of your raw data, as dumped out of the database.

> Any ideas or suggestions would be greatly appreciated.


Can you explain what it is you are trying to do, with an example of the
input and an example of how the output ought to look? Then we might be
able to help.

///Peter


All times are GMT. The time now is 03:13 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.