unable to validate Input XML

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

unable to validate Input XML

Post by cosec »

Hi All,

I am unable to validate the input XML in a job which extracts data from a XML source file and subsequently converts the information to a text file (with Header repeated for Details).

Job Design:
XML Source File -> XML Input Stage -> Transformer -> Text File

In the XML Input Stage the option 'Validate Input XML' is checked and the schema validation level is indicated as 'strict'. The job converts the source XML file to a text file as expected. However, there is no validation performed. There is no warning or job failure for contents not satisfying the XML criteria (e.g. length is not as specified, character content for numeric field).

I would greatly appreciate your advise on what may be the cause and how i could enable the validation of XML source files. Thanks !
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

Make sure that the xsd is properly identified in the header of the xml document, and that it is fully qualified as to its location......meaning, check the exact value of the schemaLocation or NoNamespaceSchemaLocation attributes.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post by cosec »

Thanks for your response. Is it sufficient to define the location of the XSD schema in the XML Input Stage and not in the XML document or is it a must that it has to be specified in the XML document ?

XSD is defined as follows:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="ROOT">
<xs:complexType>
<xs:sequence>
<xs:element name="HDR">
...
...
<xs:element name="DTL" minOccurs="0" maxOccurs="unbounded">
...
...
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

The only way I know of to tell it which xsd is to do it inside the instance document itself.

At time's, I have "zapped" the value into the doc in an upstream transformer

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post by cosec »

Thanks. I'll try that out.
cosec
Premium Member
Premium Member
Posts: 230
Joined: Tue May 08, 2007 8:10 pm

Post by cosec »

Hi,

I imported the XSD to the schema library. Then in the XML document I made reference to it as follows:

<ROOT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="TEST.xsd">
<HDR><FIELD1>ABC</FIELD1></HDR>
<DTL><FIELD2>123</FIELD2></DTL>
</ROOT>

I encountered the following error:
Xalan warning (publicId: , systemId: , line: 0, column: 0): An exception occurred! Type:RuntimeException, Message:Warning: The primary document entity could not be opened. Id=TEST.xsd

Any suggestion to fix this ?
eostic
Premium Member
Premium Member
Posts: 3838
Joined: Mon Oct 17, 2005 9:34 am

Post by eostic »

....ok. Now I am confused. In the first post you noted that you are using the xml Input Stage......

Now above the Library Schema Manager is mentioned.

Two different technologies and two different methods of doing xml validation. Which Stage are you using (xml or xmlInput) ?

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

From what I recall, it's looking for it on disk. And a relative path like that would mean 'in the current project'.
-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 »

As Craig said. But the two aren't going to mix.

Using the xmlInput Stage, validation will occur if the xsd is noted inside the document and it can be properly found. As Craig notes, it might need to be in the project directory --- I haven't done one in awhile and can't recall if it enforces that or not. Validation with the xmlInput Stage has nothing to do with the Library Manager.

The xml Stage uses the xsd that is imported at design time into the Library Manager and specifically noted in the assembly. Validation options are selected within the xmlParser Step.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The one time I did XML validation, the xsd had to be in the Project directory otherwise no workie. But that was a long time ago so I wasn't sure if that had changed.
-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 »

I recall that also...I also recall a time when it simply had to be fully qualified....it may depend on the release --- but either way, that discussion is exclusively for the xmlInput Stage.

Ernie
Ernie Ostic

blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

True. My 'one time' was back when that was the only option. Ah, those were that days. :wink:
-craig

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