Page 1 of 1

How to use Stage XML

Posted: Thu Dec 14, 2006 3:51 am
by RAI ROUSES
Hi
there is any doc where teache how to use the XML stage to read and write XML files ?

Posted: Thu Dec 14, 2006 4:32 am
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.

Posted: Thu Dec 14, 2006 7:05 am
by wnogalski
If You don't have the docs installed search the instalation CDs.

Posted: Thu Dec 14, 2006 8:04 am
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.

Posted: Fri Dec 15, 2006 6:59 am
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

Posted: Fri Dec 15, 2006 7:20 am
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.

Posted: Fri Dec 15, 2006 8:06 am
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.

Posted: Fri Dec 15, 2006 8:52 am
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

Posted: Fri Dec 15, 2006 9:01 am
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.

Posted: Fri Dec 15, 2006 9:19 am
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 ?

Posted: Fri Dec 15, 2006 11:05 am
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

Posted: Fri Dec 15, 2006 12:36 pm
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!