Read xml file with xsd

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
spuli
Participant
Posts: 40
Joined: Thu Apr 09, 2015 12:13 pm

Read xml file with xsd

Post by spuli »

Hi All,

Good morning.

I have a xsd schema file and xml data file. I have to read the xml file data and validation should happen against the xsd file. I have 8.5 version installed on my machine.

I do not find any option in XML input stage to include the xsd file.

In XML stage, there is a change to validate the xml file with xsd.

I need your suggestion (steps) to use xml stage in reading the xml file.

Thanks in advance.
Thanks,
Sai
sarathchandrakt
Participant
Posts: 50
Joined: Fri Aug 29, 2014 1:32 pm
Location: Mumbai

Post by sarathchandrakt »

Hi Spuli,

First you need to include the xsd as a library and then use it in XML stage in XML Parser step>Document root.

Here is the step to step explanation of same,

https://www.ibm.com/developerworks/data ... atastages/

I had a tough time getting help on XML too. I hope you will find all answers in the link.
spuli
Participant
Posts: 40
Joined: Thu Apr 09, 2015 12:13 pm

Post by spuli »

Thanks Sarath for your inputs.

I created a text file and wrote the xml file name (with complete path) in it.

This is the source stage to XML stage.
I am trying to write some nodes data into a sequential file.

Getting the below error.
XML_0,0: 2015-04-20 12:00:59,457 Warn [XML_Parser] []
Start XML Validation Errors (Only first error reported for any path in the schema):
Path: [Schema_Node]
CDIER0007E: An error occurred while reading the XML: cause=javax.xml.stream.XMLStreamException: An invalid XML character (Unicode: 0x5c) was found in the prolog of the document., systemId=null, line number=1, column number=1, step=XML_Parser, source=\\server\XML\test.xml.
End XML Validation Errors

Am I doing anything wrong. Please suggest.
Thanks,
Sai
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Which XML stage are you using? The advice posted was for the 'new' stage while you mentioned the XML Input stage in your first post.
-craig

"You can never have too many knives" -- Logan Nine Fingers
spuli
Participant
Posts: 40
Joined: Thu Apr 09, 2015 12:13 pm

Post by spuli »

Hi Chulett,

I am using the XML stage only not XML input stage.

Please let me know your suggestions.
Thanks,
Sai
spuli
Participant
Posts: 40
Joined: Thu Apr 09, 2015 12:13 pm

Post by spuli »

I have imported the xsd in schema manager.

In edit assembly of XML stage, i did used input stage, xml parser step and output.
Thanks,
Sai
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

You are probably on the right track, but be aware of the following when working with the xml (now called Hierarchical) Stage...

a) how is your xml? It is very important that you have a good understanding of xml and especially xsd's before starting with the xml stage.

b) review the dev works article above. Also be sure to look at the very good redbook for xml.

http://www.redbooks.ibm.com/redbooks/pdfs/sg247987.pdf

c) learn to "parse" and "read" xml before you try to write it. That will teach you basic concepts about working with lists and see how an xsd is represented in the Stage, before you do the more difficult "writing" of xml.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
sarathchandrakt
Participant
Posts: 50
Joined: Fri Aug 29, 2014 1:32 pm
Location: Mumbai

Post by sarathchandrakt »

0x5c is a hex char which your default NLS is unable to read. Check your XML source file data once. To make sure your Job is fine, you can download an example XML and XSD and try running the job with that.
Post Reply