Page 1 of 1

validating XML output using XML schema

Posted: Mon Jan 25, 2010 9:43 pm
by dsguyok
I am having trouble telling Datastage 8 to validate XML produced by the "XML Output" stage.

I have an XML schema that I want to be referenced in the validation. Currently I set this up by putting the following code in the Namespace Declaration text box in the XML Output stage properties:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="file://D:/DS_test/ proto_schema.xsd"

By doing this, the above code appears in the XML code's root element: "event". The official documentation says to do this (ie use schemaLocation as a root element attribute)


I get this warning in the logs and the validation seems to fail:

XML_Output_30,0: Warning: testEventGen.XML_Output_30: XML output document parsing failed. File Path: "D:/DS_test/XML_OUT.xml" Reason: "Xalan fatal error (publicId: , systemId: D:/DS_test/proto_schema.xsd, line: 2, column: 1): Invalid document structure
Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 6, column: 119): Unknown element 'event'
Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 6, column: 119): Attribute '{http://www.w3.org/2000/xmlns/}xsi' is not declared for element 'event'
Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 6, column: 119): Attribute '{http://www.w3.org/2001/XMLSchema-instan ... maLocation' is not declared for element 'event'
Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 8, column: 15): Unknown element 'event_type'
Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 11, column: 13): Unknown element 'event_dt'
Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 14, column: 21): Unknown element 'perm_req_clnt_id'


Would appreciate any thoughts on what to change.

Posted: Tue Jan 26, 2010 5:19 am
by eostic
I haven't tried schema validation on xmlOutput in a long time, but in reviewing tests that I use very often for xmlInput, my schemaLocation attributes for Windows systems are always absolute file identifiers.....meaning noNameSpaceSchemaLocation="C:\myfile\xyz\mySchema.xsd" ...you might want to try that instead of the syntax you are using above.

Ernie

Posted: Tue Jan 26, 2010 5:28 pm
by dsguyok
Thanks. I tried using

noNameSpaceSchemaLocation="D:\DS_test\proto_schema.xsd"

instead but got a similar error:

XML_Output_30,0: Warning: testEventGen.XML_Output_30: XML output document parsing failed. File Path: "D:/DS_test/XML_OUT.xml" Reason: "Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 6, column: 65): Unknown element 'event'
Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 6, column: 65): Attribute 'noNameSpaceSchemaLocation' is not declared for element 'event'
Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 8, column: 15): Unknown element 'event_type'
Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 11, column: 13): Unknown element 'event_dt'
Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 14, column: 21): Unknown element 'perm_req_clnt_id'


The error seems to be saying that noNameSpaceschemaLocation is undeclared for my root element "event". How would I fix that?

Posted: Wed Jan 27, 2010 7:15 am
by eostic
Hmm. Let's ask and try a few things.

a) what happens when you don't ask for validation (don't check the box)....do you get a document created?

b) if so....create it in DS and then find a validation tool on the web or in XMLSpy or other such product, and validate it.---- is it valid?

The error almost sounds like it is indeed doing validation correctly, and something is wrong with the document it is constructing, or wrong with your schema....

Ernie

Posted: Wed Jan 27, 2010 9:22 pm
by dsguyok
eostic wrote:a) what happens when you don't ask for validation (don't check the box)....do you get a document created?
in this case, the XML files are created without issue.

I've validated the XML output and the schema itself using web tools. Here they are, respectively:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<event xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:schemaLocation="D:\DS_test\ proto_schema.xsd">
  <event_type>1136</event_type>
  <event_dt>1960-01-01</event_dt>
  <perm_req_clnt_id>200</perm_req_clnt_id>
</event>

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" xml:lang="en">
  <xs:element name="event">
  	<xs:complexType>
	  	<xs:sequence>
  			<xs:element name="event_type" />
  			<xs:element name="event_dt" />
  			<xs:element name="perm_req_clnt_id" />
  		</xs:sequence>
  	</xs:complexType>
  </xs:element>
</xs:schema>
I get this error in Datastage with the validation switched back on:

XML_Output_30,0: Warning: testEventGen.XML_Output_30: XML output document parsing failed. File Path: "D:/DS_test/XML_OUT.xml" Reason: "Xalan fatal error (publicId: , systemId: D:/DS_test/proto_schema.xsd, line: 2, column: 1): Invalid document structure
Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 2, column: 113): Unknown element 'event'
Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 2, column: 113): Attribute '{http://www.w3.org/2000/xmlns/}xsi' is not declared for element 'event'
Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 2, column: 113): Attribute '{http://www.w3.org/2001/XMLSchema-instan ... maLocation' is not declared for element 'event'
Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 3, column: 15): Unknown element 'event_type'
Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 6, column: 13): Unknown element 'event_dt'
Xalan error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 9, column: 21): Unknown element 'perm_req_clnt_id'

Maybe it's having trouble reading the schema file ... "invalid document structure" ... ?

Using noNameSpaceSchemaLocation throws roughly the same error.

Posted: Thu Jan 28, 2010 5:55 am
by eostic
hmm. Not sure. Is that space in the xsd name just an issue here in the Forum? Assuming it is, I can't see anything obvious. Anyone else have an idea? I'll have to try it but probably won't have time until a day or so....

Ernie

Posted: Thu Jan 28, 2010 9:35 pm
by dsguyok
eostic wrote:Is that space in the xsd name just an issue here in the Forum?
No, that's intended. If I take the space out, I get this error message:

XML_Output_30,0: Warning: testEventGen.XML_Output_30: XML output document parsing failed. File Path: "D:/DS_test/XML_OUT.xml" Reason: "Xalan fatal error (publicId: , systemId: D:/DS_test/XML_OUT.xml, line: 2, column: 112): The schemaLocation attribute does not contain pairs of values.

So that's why I have a "pair" value: schemaLocation="D:\DS_test\ proto_schema.xsd"

Your help is much appreciated - keep it coming :)

Posted: Fri Jan 29, 2010 6:31 am
by eostic
Ok. Something's up. I'm looking forward to trying it. Probably won't have a thought for you until the end of the w/e....let me know if you resolve it sooner.

Posted: Mon Feb 08, 2010 2:25 am
by dsguyok
I've got it working on DS 7.5 running on UNIX.

The XML Output stage properties are the same as on DS 8 Windows (the installation with this issue).

So I guess it's a DS-8-Windows-specific problem.

Posted: Mon Feb 08, 2010 6:30 am
by eostic
Thanks. That's good news. At least we know that it is working as it "should" and that you did things correctly. Have you reported it for 8.x? I haven't been able to test as I've been "in between" systems while upgrading further to 8.1.2...., and there have been a lot of patches to various things that went into 8.1 and the FP1 to 8.1....

Ernie

Posted: Thu Nov 12, 2015 9:03 am
by apierro1
dsguyok wrote:I've got it working on DS 7.5 running on UNIX.
How were you able to get this working on 7.5?

Posted: Thu Nov 12, 2015 9:33 am
by chulett
Anthony, have you been through the documentation on that option? Have an issue or specific question?