validating XML output using XML schema
Moderators: chulett, rschirm, roy
validating XML output using XML schema
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.
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.
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
Ernie
Ernie Ostic
blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
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?
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?
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
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
Ernie Ostic
blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
in this case, the XML files are created without issue.eostic wrote:a) what happens when you don't ask for validation (don't check the box)....do you get a document created?
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>
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.
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
Ernie
Ernie Ostic
blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
No, that's intended. If I take the space out, I get this error message:eostic wrote:Is that space in the xsd name just an issue here in the Forum?
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
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.
Ernie Ostic
blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
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
Ernie
Ernie Ostic
blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>
blogit!
<a href="https://dsrealtime.wordpress.com/2015/0 ... ere/">Open IGC is Here!</a>