Page 1 of 1

Read xml file with xsd

Posted: Mon Apr 20, 2015 7:42 am
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.

Posted: Mon Apr 20, 2015 8:39 am
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.

Posted: Mon Apr 20, 2015 10:04 am
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.

Posted: Mon Apr 20, 2015 10:08 am
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.

Posted: Mon Apr 20, 2015 10:11 am
by spuli
Hi Chulett,

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

Please let me know your suggestions.

Posted: Mon Apr 20, 2015 10:12 am
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.

Posted: Mon Apr 20, 2015 10:38 am
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

Posted: Mon Apr 20, 2015 11:48 am
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.