schemavalidate and pattern matching
370091May 10 2006 — edited May 10 2006I am unable to get Oracle 9.2.0.6 to validate my schema when one of the elements in a choice has a pattern restriction.
full example is below.
does anybody have any thoughts or work around for this.
the first error i get is LSX-00213: only 0 occurrences of particle ">choice element<", minimum is 1 , when I alter the schema to give my elements a minOccurs = "0" I get the error LSX-00204: extra data at end of complex element .
many thanks in advance for help and advice
phil
begin
dbms_xmlschema.deleteschema('dateTimeTest.xsd',dbms_xmlschema.DELETE_CASCADE);
end;
/
PL/SQL procedure successfully completed.
begin
dbms_xmlschema.registerSchema('dateTimeTest.xsd','<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root" type="DateElement" />
<xs:complexType name="DateElement">
<xs:sequence>
<xs:choice>
<xs:element name="dateString" type="dts"/>
<xs:element name="datePattern" type="dtsp"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="dts">
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:simpleType name="dtsp">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(Z|((\+|-)[0-9]{2}:[0-9]{2}))" />
</xs:restriction>
</xs:simpleType>
</xs:schema>',owner=>'N_SYS');
end;
/
PL/SQL procedure successfully completed.
declare
xmldoc xmltype :=xmltype('<root><datePattern>2006-13-18T13:45:45.0Z</datePattern></root>','dateTimeTest.xsd');
begin
xmldoc.schemavalidate();
if xmldoc.isschemavalidated() = 1 then
dbms_output.put_line('Data is valid');
else
dbms_output.put_line('Data is invalid');
end if;
exception when others then
raise;
end;
/
declare
*
ERROR at line 1:
ORA-31154: invalid XML document
ORA-19202: Error occurred in XML processing
LSX-00213: only 0 occurrences of particle "dateString", minimum is 1
ORA-06512: at line 11
begin
dbms_xmlschema.deleteschema('dateTimeTest.xsd',dbms_xmlschema.DELETE_CASCADE);
end;
/
PL/SQL procedure successfully completed.
begin
dbms_xmlschema.registerSchema('dateTimeTest.xsd','<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root" type="DateElement" />
<xs:complexType name="DateElement">
<xs:sequence>
<xs:choice>
<xs:element name="dateString" minOccurs="0" type="dts"/>
<xs:element name="datePattern" minOccurs="0" type="dtsp"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="dts">
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:simpleType name="dtsp">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(Z|((\+|-)[0-9]{2}:[0-9]{2}))" />
</xs:restriction>
</xs:simpleType>
</xs:schema>',owner=>'N_SYS');
end;
/
PL/SQL procedure successfully completed.
declare
xmldoc xmltype :=xmltype('<root><datePattern>2006-13-18T13:45:45.0Z</datePattern></root>','dateTimeTest.xsd');
begin
xmldoc.schemavalidate();
if xmldoc.isschemavalidated() = 1 then
dbms_output.put_line('Data is valid');
else
dbms_output.put_line('Data is invalid');
end if;
exception when others then
raise;
end;
/
declare
*
ERROR at line 1:
ORA-31154: invalid XML document
ORA-19202: Error occurred in XML processing
LSX-00204: extra data at end of complex element
ORA-06512: at line 11