我有2个模式:
在模式(schema_2)中,我定义了一些我将在另一个模式(schema_1)中使用的类型。问题是,当我验证时,当插入到定义为schema_1类型的表中时,它不会检测我从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(从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;
我创建了一个表:
CREATE TABLE TEST_XML(id number,test_pres xmltype)
XMLTYPE COLUMN test_pres
STORE AS BINARY XML
XMLSCHEMA "schema_1.xsd"
ELEMENT "Presentation";
当我插入XML寄存器时,出现错误:
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>
</ReportingFI>
</PresentationBody_3>
</Presentation>';
insert into TEST_XML values(1,xmltype(test_clob));
end;
错误:
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.
如果插入它,为什么我们找不到ReportingFI粒子?