XSD重用complexType元素

Moh*_*idi 2 xml xsd jdeveloper

我正在使用Jdeveloper 12c.我正在尝试使用a complexType作为引用在另一个元素中键入另一个元素complexType.Jdev告诉我它无法找到AddressInfo参考.以下是相关代码的片段,请帮忙:

<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://xmlns.oracle.com/SquareEdge/SEPPO/ProcessPO"
xmlns="http://www.w3.org/2001/XMLSchema">
<complexType name="AddressInfo">
   <sequence>
       <element type="string" name="FirstName"/>
       <element type="string" name="LastName"/>
       <element type="string" name="Street"/>
       <element type="string" name="City"/>
       <element type="string" name="State"/>
       <element type="short" name="ZipCode"/>
       <element type="unsignedLong" name="PhoneNumber"/>
   </sequence>
</complexType>
<complexType name="Billing">
   <sequence>
     <element name="PaymentCardName" type="string" maxOccurs="1"/>
     <element name="PaymentCardNumber" type="unsignedLong"maxOccurs="1"/>
     <element name="ExpirationDate" type="unsignedShort" maxOccurs="1"/>
     <element name="BillingAddress" maxOccurs="1" type="AddressInfo"/> 
   </sequence>
</complexType>
Run Code Online (Sandbox Code Playgroud)

kjh*_*hes 5

为以下内容定义名称空间前缀targetNamespace:

  xmlns:po="http://xmlns.oracle.com/SquareEdge/SEPPO/ProcessPO"
Run Code Online (Sandbox Code Playgroud)

然后用它来参考AddressInfo:

  <element name="BillingAddress" maxOccurs="1" type="po:AddressInfo"/> 
Run Code Online (Sandbox Code Playgroud)

而你的错误将消失.

总共(加上一些其他小修正):

<?xml version="1.0" encoding="UTF-8"?>
<schema attributeFormDefault="unqualified"
        elementFormDefault="qualified"
        xmlns:po="http://xmlns.oracle.com/SquareEdge/SEPPO/ProcessPO"
        targetNamespace="http://xmlns.oracle.com/SquareEdge/SEPPO/ProcessPO"
        xmlns="http://www.w3.org/2001/XMLSchema">
  <complexType name="AddressInfo">
    <sequence>
      <element type="string" name="FirstName"/>
      <element type="string" name="LastName"/>
      <element type="string" name="Street"/>
      <element type="string" name="City"/>
      <element type="string" name="State"/>
      <element type="short" name="ZipCode"/>
      <element type="unsignedLong" name="PhoneNumber"/>
    </sequence>
  </complexType>
  <complexType name="Billing">
    <sequence>
      <element name="PaymentCardName" type="string" maxOccurs="1"/>
      <element name="PaymentCardNumber" type="unsignedLong" maxOccurs="1"/>
      <element name="ExpirationDate" type="unsignedShort" maxOccurs="1"/>
      <element name="BillingAddress" maxOccurs="1" type="po:AddressInfo"/> 
    </sequence>
  </complexType>
</schema>
Run Code Online (Sandbox Code Playgroud)