Note that there are some explanatory texts on larger screens.

plurals
  1. POdbms_xmlschema fail to validate with complexType
    text
    copied!<p>Preface: <strong>This works on one Oracle 11gR1 (Solaris 64) database and not on a second</strong> and we can't figure out the difference between the two databases. Somehow the complexType causes the validation to fail with this error:</p> <pre><code>ORA-31154: invalid XML document ORA-19202: Error occurred in XML processing LSX-00200: element "shiporder" not empty ORA-06512: at "SYS.XMLTYPE", line 354 ORA-06512: at line 13 </code></pre> <p>But the schema is valid (passes this online test: <a href="http://www.xmlme.com/Validator.aspx" rel="nofollow noreferrer">http://www.xmlme.com/Validator.aspx</a>)</p> <pre><code>-- Cleanup any existing schema begin dbms_xmlschema.deleteschema('shiporder.xsd',dbms_xmlschema.DELETE_CASCADE); end; -- Define the problem schema (adapted from http://www.w3schools.com/schema/schema_example.asp) begin dbms_xmlschema.registerSchema('shiporder.xsd','&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xs:element name="shiporder"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="orderperson" type="xs:string"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:schema&gt;',owner=&gt;'SCOTT'); end; -- Attempt to validate declare bbb xmltype; begin bbb := XMLType('&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt; &lt;shiporder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="shiporder.xsd"&gt; &lt;orderperson&gt;John Smith&lt;/orderperson&gt; &lt;/shiporder&gt;'); XMLType.schemaValidate(bbb); end; </code></pre> <p>Now if I gut the schema definition and leave only a string in the XML then the validation passes:</p> <pre><code>begin dbms_xmlschema.deleteschema('shiporder.xsd',dbms_xmlschema.DELETE_CASCADE); end; begin dbms_xmlschema.registerSchema('shiporder.xsd','&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xs:element name="shiporder" type="xs:string"/&gt; &lt;/xs:schema&gt;',owner=&gt;'SCOTT'); end; DECLARE xml XMLTYPE; BEGIN xml := XMLTYPE('&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt; &lt;shiporder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="shiporder.xsd"&gt; John Smith &lt;/shiporder&gt;'); XMLTYPE.schemaValidate(xml); END; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload