How to use Stage XML

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
RAI ROUSES
Participant
Posts: 176
Joined: Wed Nov 15, 2006 5:48 am

How to use Stage XML

Post by RAI ROUSES »

Hi
there is any doc where teache how to use the XML stage to read and write XML files ?
jhmckeever
Premium Member
Premium Member
Posts: 301
Joined: Thu Jul 14, 2005 10:27 am
Location: Melbourne, Australia
Contact:

Post by jhmckeever »

RAI,

Check your client installation directory.
E.g. C:\Program Files\Ascential\DataStage\Docs\XMLPACK_20_Designer.pdf

Note that you don't read/write XML file specifically, you just read/write sequential files, which may or may not contain XML data. The XML stages operate on input and output streams and (generally) provide abilities to convert from/to XML, or between different XML schemas.

HTH,
J.
<b>John McKeever</b>
Data Migrators
<b><a href="https://www.mettleci.com">MettleCI</a> - DevOps for DataStage</b>
<a href="http://www.datamigrators.com/"><img src="https://www.datamigrators.com/assets/im ... l.png"></a>
wnogalski
Charter Member
Charter Member
Posts: 54
Joined: Thu Jan 06, 2005 10:49 am
Location: Warsaw

Post by wnogalski »

If You don't have the docs installed search the instalation CDs.
Regards,
Wojciech Nogalski
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You can also go to Kim Duke's (kduke here) website and download the Ascential 'XML PACK Best Practices' document we uploaded there. His URL is in his sig in any post here.
-craig

"You can never have too many knives" -- Logan Nine Fingers
RAI ROUSES
Participant
Posts: 176
Joined: Wed Nov 15, 2006 5:48 am

Post by RAI ROUSES »

Hi,
i'm try to read data from xml file, ds job can open the xml file, but didn't read any data, it pass 0 records from the stage input xml.
The process finished with sucess, but didnt do anything.

Any idea ?

Rai
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

This file has been in my downloads directory for a while now but there was no link on my tips page until yesterday. Sorry Craig. Craig, let me know if there are other links needed.
Mamu Kim
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

RAI ROUSES wrote:ds job can open the xml file, but didn't read any data, it pass 0 records from the stage input xml. The process finished with sucess, but didnt do anything.
Your XPath expressions don't match up to what it found in the file, so nothing made it through. More specific than that, I cannot be.
-craig

"You can never have too many knives" -- Logan Nine Fingers
RAI ROUSES
Participant
Posts: 176
Joined: Wed Nov 15, 2006 5:48 am

Post by RAI ROUSES »

tks for your anwser

when i imported the metadata from my xml file i get the xpath for each column.
In the XMLInput stage i defined in each derivation the corresponding xpath.
The job run with sucess, with no warning but didn't read any record from xml file.

Any idea ?

RAI
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:idea: Your XPath expressions don't match up to what it found in the file. Not sure how much plainer to say it. Don't forget that namespace plays a role here as well, but problems there would typically (but not always) generate errors during the run.

You haven't given us any information that we can use to help you solve this problem. Perhaps if you post the xsd, an xml snippet and some example XPath expressions? That would be a start.
-craig

"You can never have too many knives" -- Logan Nine Fingers
RAI ROUSES
Participant
Posts: 176
Joined: Wed Nov 15, 2006 5:48 am

Post by RAI ROUSES »

I used a folder stage to get the name of xml file, then pass 2 records (FileName and Record) to the XMLInput stage.

In the XMLInput Stage, in the Input tab, i defined the FileName as a XML source column, in the column tabs i have the 2 columns that i take from folder stage.

in the XMLInput Stage, Output tab, i definned the columns of my xml file and the derivation for each column.

Column -> derivation
id -> /Compagnie/Client/@id
Nomme -> /Compagnie/Client/Nomme/text()
Ville -> /Compagnie/Client/adresse/Ville/text()
Anne -> /Compagnie/Client/adresse/Anee/text()

An example of my xml file is

<?xml version="1.0"?>
<Compagnie>
<Client id="1001">
<Nomme>Charter Group</Nomme>
<adresse>
<Ville>VfT Paris</Ville>
<Anee>1998</Anee>
</adresse>
</Client>
</Compagnie>

What is wrong ?
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Column -> Derivation ? ?

...are you sure that's not in the "Description" of each column? It must be in the Description...

also...you'll get an error, but who knows, if you don't have one of your columns (Ville would be a good candidate) marked as "key"

Ernie
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Nice catch, Ernie. Odd as it looks, the XPath expressions go in the 'Description' field. Hopefully that simple change will solve all your problems!
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply