Jump to content
jtorijano

Error when validate XML complextype imported

Recommended Posts

I have 2 schemas:

In a schema (schema_2) I define some types that I will use in the other schema (schema_1). The problem is that when I validate, when inserted into a table defined as the type of schema_1, it does not detect the nodes that are inside a complex type that I imported from schema_2.

 

Schema_2:

 

begin
   begin
    dbms_xmlschema.deleteschema(schemaURL => 'schema_2.xsd',
      delete_option => dbms_xmlschema.delete_cascade_force);
   exception
   when others then
    null;
   end;
    DBMS_XMLSCHEMA.REGISTERSCHEMA(SCHEMAURL=>'schema_2.xsd',
    SCHEMADOC=>'<xsd:schema xmlns:pty="schema_2.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="schema_2.xsd" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">
   <!--

   prueba de PresentationBody

    -->
   <xsd:complexType name="Complex_1">
   <xsd:sequence>
      <xsd:element name="ReportingFI">
      </xsd:element>
   </xsd:sequence>
   </xsd:complexType>


   <xsd:simpleType name="Simple_Type">
   <xsd:annotation>
   <xsd:documentation xml:lang="en">Receipt version</xsd:documentation>
   </xsd:annotation>
   <xsd:restriction base="xsd:string">
   <xsd:enumeration value="2.0"/>
   </xsd:restriction>
   </xsd:simpleType>

   <xsd:element name="Element_type">
   </xsd:element>

   </xsd:schema>', LOCAL=>true, GENTYPES=>false, GENBEAN=>false, GENTABLES=>false,
       FORCE=>false, OPTIONS=>DBMS_XMLSCHEMA.REGISTER_BINARYXML, OWNER=>USER);
    commit;
   end;

 

 

Schema_1 (imports from Schema 2):

 begin
   begin
    dbms_xmlschema.deleteschema(schemaURL => 'schema_1.xsd',
      delete_option => dbms_xmlschema.delete_cascade_force);
   exception
   when others then
    null;
   end;
    DBMS_XMLSCHEMA.REGISTERSCHEMA(SCHEMAURL=>'schema_1.xsd',
    SCHEMADOC=>'<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pty="schema_2.xsd" elementFormDefault="qualified" attributeFormDefault="unqualified" version="2.0">
       <xsd:import namespace="schema_2.xsd" schemaLocation="schema_2.xsd"/>

     <xsd:complexType name="NT_Test">
       <xsd:sequence>
         <xsd:element name="PresentationHeader">
           <xsd:complexType>
             <xsd:sequence>
               <xsd:element name="PresentationCode" type="xsd:string">
                 <xsd:annotation>
                   <xsd:documentation xml:lang="es">
                     Identificador único del mensaje generado por el declarante
                   </xsd:documentation>
                 </xsd:annotation>
               </xsd:element>
             </xsd:sequence>
           </xsd:complexType>
         </xsd:element>
         <xsd:element name="PresentationBody_2" type="pty:Simple_Type"/>
         <xsd:element name="PresentationBody_3" type="pty:Complex_1"/>
       </xsd:sequence>
     </xsd:complexType>

     <xsd:element name="Presentation" type="NT_Test"/>


   </xsd:schema>', LOCAL=>true, GENTYPES=>false, GENBEAN=>false, GENTABLES=>false,
       FORCE=>false, OPTIONS=>DBMS_XMLSCHEMA.REGISTER_BINARYXML, OWNER=>USER);
    commit;
   end;

 

I create a table:

 

 
   CREATE TABLE TEST_XML(id number,test_pres xmltype)
   XMLTYPE COLUMN test_pres
   STORE AS BINARY XML
   XMLSCHEMA "schema_1.xsd"
   ELEMENT "Presentation";

 

 

When I insert an XML register, I have an error:

 

declare
   test_clob clob;

   begin
   test_clob := '<?xml version="1.0" encoding="utf-8"?>
             <Presentation>
                 <PresentationHeader>
                   <PresentationCode>
                   29020160000000000001
                   </PresentationCode>
                </PresentationHeader>
                <PresentationBody_2>2.0</PresentationBody_2>
                <PresentationBody_3>
                    <ReportingFI>notnull
                   </ReportingFI>
                </PresentationBody_3>
             </Presentation>';

   insert into TEST_XML values(1,xmltype(test_clob));

   end;

 

 

Error:

 

 

  Error report -
   ORA-31061: XDB error: XML event error
   ORA-19202: Error occurred in XML processing
   LSX-00213: only 0 occurrences of particle "ReportingFI", minimum is 1
   ORA-06512: at line 19
   31061. 00000 -  "XDB error: %s"
   *Cause:    The specified error occurred in XDB.
   *Action:   Correct the error or contact Oracle Support Services.

 

Why dooesn't find ReportingFI particle if I insert it??

Share this post


Link to post
Share on other sites
Hi, and welcome to the forum!

 

Lsx-00213 is a common error!

 

I found this similar issue, hop this helps:

 

https://stackoverflow.com/questions/3610713...l-during-insert

 

Good luck!

 

I already checked it but isn't it the same problem. In that link you can see that the problem is that when make en insert, database didn't validate the XML. So the reply was that put the option--> dbms_xmlschema.REGISTER_BINARYXML, and if you check my code, I have that option.

 

My problem is that when I insert a complexType from another schema, it validates the parent node but the validation of de child node doesn't work fine, because the BBDD shows me the error that there is no child, but I am inserting it.

 

I hope you can check my code and shed some light on the problem, thanks in advance.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×