日期:2014-05-16  浏览次数:21123 次

Oracle xmldb xmlSchema与xml
其中xml schema的定义如下
<schema
  targetNamespace = "http://xmlns.xzr.com/research2.xsd"
  xmlns:cis = "http://xmlns.xzr.com/research2.xsd"
  xmlns:xdb = "http://xmlns.oracle.com/xdb"
  xmlns="http://www.w3.org/2001/XMLSchema">
  <element name="Research" xdb:defaultTable="STU_Research2">
  <complexType>
  <sequence>
  <element name="PatientID" type = "string" xdb:SQLName="PatientID" xdb:SQLType="VARCHAR2"/>
  <element name="name" type = "string" xdb:SQLName="name" xdb:SQLType="VARCHAR2"/>
  <element name="age" type = "int" xdb:SQLName="age" xdb:SQLType="NUMBER"/>
  </sequence>
  </complexType>
  </element>
</schema>
xml内容如下,格式总是不对应,找不出问题所在求解
<Research 
xmlns = "http://xmlns.xzr.com/research2.xsd"
xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://xmlns.xzr.com/research2.xsd
http://xmlns.xzr.com/research2.xsd">
  <PatientID>1231</PatientID>
  <name>adf</name>
  <age>12</age>
</Research>

错误报告:
SQL 错误: ORA-30937: 没有 'PatientID' (名称空间 'http://xmlns.xzr.com/research2.xsd', 在父 '/Research' 中) 的方案定义
30937. 00000 - "No schema definition for '%s' (namespace '%s') in parent '%s'"
*Cause: The schema definition for the parent node being processed does
  not allow for the specified child node in its content model.
  Note that any typecasting via xsi:type must occur before the
  schema definitions for the new type can be used.
*Action: Only insert elements and attributes declared in the schema.
  Check to make sure that xsi:type (if used) is specified first.

请大家帮忙看一下是schema定义错了还是xml写错了,初学xmldb 求帮忙

------解决方案--------------------
还没用过,都是直接用xmltype。 ——