针对XSD的XML验证在Oracle中失败,但它在XMLSpy中得到验证

时间:2011-02-09 10:37:14

标签: xml oracle xsd

XSD在oracle中注册。使用XMLTYPE.schemavalidate根据已注册的XSD验证XML。 API给出错误,因为“LSX-00295:字段元素”项“不是简单类型”。但是,使用相同XSD的相同XML文件在Altova XMLSpy中得到了验证。 不知何故oracle正在给出复杂的类型错误。

匿名脚本如下:

declare
lxml  XMLTYPE;
l_err varchar2(4000);
l_transformxml CLOB:='<?xml version="1.0" encoding="UTF-8"?>
<tdvpf:products numproducts="2" xsi:schemaLocation="http://www.techdata.com/vpf VendorPriceFileTemplate_Volume.xsd" xmlns:tdvpf="http://www.techdata.com/vpf" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <product>
        <base>
            <distributorsku numitems="1">
                <item index="2">a</item>
            </distributorsku>
            <vendor numitems="1">
                <item index="2">a</item>
            </vendor>
            <vendorpartnumber numitems="1">
                <item index="2">a</item>
            </vendorpartnumber>
            <endusertype numitems="1">
                <item index="2">Government</item>
            </endusertype>
            <endusersubtype numitems="1">
                <item index="2">a</item>
            </endusersubtype>
            <vendorproductgroup numitems="1">
                <item index="2">a</item>
            </vendorproductgroup>
            <productname numitems="1">
                <item index="2">a</item>
            </productname>
            <productdescription numitems="1">
                <item index="2">a</item>
            </productdescription>
            <cost numitems="1">
                <item index="2">0.0</item>
            </cost>
            <msrp numitems="1">
                <item index="2">0.0</item>
            </msrp>
            <operatingsystem numitems="1">
                <item index="2">Linux</item>
            </operatingsystem>
            <operatingsystemversion numitems="1">
                <item index="2">a</item>
            </operatingsystemversion>
            <platform numitems="1">
                <item index="2">64 bit</item>
            </platform>
            <version numitems="1">
                <item index="2">a</item>
            </version>
            <edition numitems="1">
                <item index="2">a</item>
            </edition>
            <licensetype numitems="1">
                <item index="2">a</item>
            </licensetype>
            <licenseduration numitems="1">
                <item index="2">a</item>
            </licenseduration>
            <packagetype numitems="1">
                <item index="2">Full package product</item>
            </packagetype>
            <mediatype numitems="1">
                <item index="2">a</item>
            </mediatype>
            <maintenancesupporttype numitems="1">
                <item index="2">a</item>
            </maintenancesupporttype>
            <maintenancesupportduration numitems="1">
                <item index="2">a</item>
            </maintenancesupportduration>
            <licenseprogram numitems="1">
                <item index="2">a</item>
            </licenseprogram>
            <language numitems="1">
                <item index="2">a</item>
            </language>
            <productclass numitems="1">
                <item index="2">Applications</item>
            </productclass>
            <mediapartnumber numitems="1">
                <item index="2">a</item>
            </mediapartnumber>
            <requireditems numitems="1">
                <item index="2">a</item>
            </requireditems>
            <seats-qty numitems="1">
                <item index="2">a</item>
            </seats-qty>
            <users-qty numitems="1">
                <item index="2">a</item>
            </users-qty>
            <appliances-qty numitems="1">
                <item index="2">a</item>
            </appliances-qty>
            <devices-qty numitems="1">
                <item index="2">a</item>
            </devices-qty>
            <migrations-qty numitems="1">
                <item index="2">a</item>
            </migrations-qty>
            <mailboxes-qty numitems="1">
                <item index="2">a</item>
            </mailboxes-qty>
            <gigabytes-qty numitems="1">
                <item index="2">a</item>
            </gigabytes-qty>
            <servers-qty numitems="1">
                <item index="2">a</item>
            </servers-qty>
            <workstations-qty numitems="1">
                <item index="2">a</item>
            </workstations-qty>
            <licenses-qty numitems="1">
                <item index="2">a</item>
            </licenses-qty>
            <processors-qty numitems="1">
                <item index="2">a</item>
            </processors-qty>
            <domains-qty numitems="1">
                <item index="2">a</item>
            </domains-qty>
            <nodes-qty numitems="1">
                <item index="2">a</item>
            </nodes-qty>
        </base>
        <licenseprogram>
            <points numitems="1">
                <item index="2">0.0</item>
            </points>
            <minquantity numitems="1">
                <item index="2">0.0</item>
            </minquantity>
            <maxquantity numitems="1">
                <item index="2">0.0</item>
            </maxquantity>
            <volumelevel numitems="1">
                <item index="2">a</item>
            </volumelevel>
            <groupmethod numitems="1">
                <item index="2">ProgramPool</item>
            </groupmethod>
        </licenseprogram>
    </product>
</tdvpf:products>
';
begin
lxml := XMLTYPE (l_transformxml).createschemabasedxml ('VendorPriceFileTemplate_Volume.xsd');
   XMLTYPE.schemavalidate (lxml);

   IF lxml.isschemavalid () = 1
   THEN
      DBMS_OUTPUT.put_line ('XSD validation success');
   END IF;
EXCEPTION
   WHEN OTHERS
   THEN
      l_err := SUBSTR (SQLERRM, 1, 4000);
      DBMS_OUTPUT.put_line ('Error: ' || l_err);
END;

1 个答案:

答案 0 :(得分:0)

显然,架构将item定义为具有simpleType的元素,这意味着它不能包含属性。

<item index="2">a</item>