首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >XSD重用complexType元素

XSD重用complexType元素
EN

Stack Overflow用户
提问于 2015-11-02 09:41:41
回答 1查看 982关注 0票数 2

我使用的是Jdeveloper 12c。我正在尝试使用complexType作为在另一个complexType中输入另一个元素的引用。Jdev告诉我它找不到AddressInfo引用。以下是相关的代码片段,请帮助:

代码语言:javascript
复制
<?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>
EN

回答 1

Stack Overflow用户

发布于 2015-11-02 10:04:18

targetNamespace定义命名空间前缀

代码语言:javascript
复制
  xmlns:po="http://xmlns.oracle.com/SquareEdge/SEPPO/ProcessPO"

然后使用它来引用AddressInfo

代码语言:javascript
复制
  <element name="BillingAddress" maxOccurs="1" type="po:AddressInfo"/> 

你的错误就会消失。

全部(加上其他一些次要的修复):

代码语言:javascript
复制
<?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>
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33469455

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档