I'm going to validate and process XML provided by a third party. The XML conforms a standardized XML schema also provided by a third party.
For validation I use DBMS_XMLSCHEMA essentially this way:
-- pseudocode follows
declare
xmldoc xmltype;
begin
dbms_xmlschema.registerschema(schemaurl => name,
schemadoc => xmltype(schema),
local => true,
gentypes => false,
gentables => false
);
xmldoc := xmltype(xml).createSchemaBasedXML(schema_name);
xmldoc.schemavalidate;
end;
Validation seems to work except that I've run an issue with XML schema type xs:dateTime
that is demonstrated below.
With XML schema:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="datetime-issue">
<xs:complexType>
<xs:sequence>
<xs:element name="time" type="xs:dateTime" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The validation of following XML:
<?xml version="1.0" encoding="UTF-8"?>
<datetime-issue>
<time>2011-06-15T16:58:23</time>
<!-- Oracle doesn't like timezone ? -->
<time>2011-06-15T16:58:23+02:00</time>
<time>2011-06-16T09:55:01</time>
</datetime-issue>
Fails unexpectedly on the second time-element:
ORA-30992: error occurred at Xpath /datetime-issue/time[2]
ORA-01830: date format picture ends before converting entire input string
ORA-06512: at "SYS.XMLTYPE", line 354
AFAICS 2011-06-15T16:58:23+02:00
should be a valid XML schema xs:dateTime value and DBMS_XMLSCHEMA should not complain about that at all. Validation should also be independent on any database date format settings, right ?
So is this an Oracle quirk and if yes what are the workarounds ? Or should I configure Oracle and/or DBMS_XMLSCHEMA differently ? Or have I misinterpreted something or ...
I'm running Oracle Database 11g Release 11.2.0.1.0.
If it's worth of anything the example XML schema and data above validates correctly with exchangerxml that uses Xerces.