XML Parsing

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
prasanna2100
Participant
Posts: 36
Joined: Mon Mar 27, 2006 12:23 am
Location: Chennai

XML Parsing

Post by prasanna2100 »

HI All,
I have a DB2 table ,where one of the column is a XML file .
I have to read the column and parse it to get the value.

suggestions please


Thanks in advance
PrasannaKumar
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Read the column from the table and pass it to an XML Input stage for parsing. Mark the source column as an XML Document and supply the correct XPath expressions.
-craig

"You can never have too many knives" -- Logan Nine Fingers
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

...it's also worth noting that the XML stages support the concept of "pass thru"... meaning that any other "non-xml" column whose name exists on the input link and also the output link (but with no xpath syntax in the Description property) will be "passed - thru" the Stage without incident. So you can parse the one column and the others just come along for the ride....

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

...it's also worth noting that the XML stages support the concept of "pass thru"... meaning that any other "non-xml" column whose name exists on the input link and also the output link (but with no xpath syntax in the Description property) will be "passed - thru" the Stage without incident. So you can parse the one column and the others just come along for the ride....

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
prasanna2100
Participant
Posts: 36
Joined: Mon Mar 27, 2006 12:23 am
Location: Chennai

Post by prasanna2100 »

Hi,
When i try to parse a XML file ,Which is a Column in my DB2 Table
by providing the XPath in the XML InputStage , iam getting an error


'XML_Input_10,0: Warning: xmltest1.XML_Input_10: Xalan warning (publicId: , systemId: , line: 0, column: 0): An exception occurred! Type:RuntimeException, Message:Warning: The primary document entity could not be opened. Id=TransactionDetails.xsd'

Please advice.

Thanks in advance
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Take a look at the document closely...it probably has a SchemaLocation or xsi:noNameSpaceSchemaLocation= attribute inside the header. This is the xml schema for the document....the stage is looking for it. Is the document in the database table already validated? If so, just pass the column string into a Transformer before the XMLStage and use some string functions to remove the attribute entirely.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
dsdoubt
Participant
Posts: 106
Joined: Sat Jul 15, 2006 12:17 am

Post by dsdoubt »

How can we parse the data based on Schema?
If we have a XML schema and is there a way to reject the records which doest fall under given schema
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

A good discussion...probably should be a new thread....but the XML Schema can be used to bring in meta data for a given document (you can import a schema or an xml instance document itself to garner column names).... and then afterwards, you have an option to use the XML Schema to perform in-line validation.....

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
Post Reply