xsd:any ## other如何在扩展的一部分时表现

时间:2017-06-24 07:00:38

标签: xsd

当从另一个名称空间的另一个xsd扩展Oasis BaseFaultType时,xsd:any ## other会默认将所有扩展类成员放入其中吗? 这是Oasis BaseFaultType的相关部分

  <xsd:element name="BaseFault" type="wsrf-bf:BaseFaultType" />
  <xsd:complexType name="BaseFaultType">
    <xsd:sequence>
      <xsd:any minOccurs="0" maxOccurs="unbounded" namespace="##other" processContents="lax" />
      <xsd:element name="Timestamp" type="xsd:dateTime" />
      <xsd:element minOccurs="0" name="Originator" type="wsa:EndpointReferenceType" />
      <xsd:element minOccurs="0" name="ErrorCode">

以下是扩展名

的示例

<xsd:schema xmlns:ws-bf="http://docs.oasis-open.org/wsrf/bf-2" xmlns:cmn="http://customer.com/schema/common/v1" xmlns:tns="http://customer.com/contract/vfo/fault/v1" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://customer.com/contract/vfo/fault/v1" version="1.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:import schemaLocation="./bf-2.xsd" namespace="http://docs.oasis-open.org/wsrf/bf-2" />
  <xsd:import schemaLocation="./Meta.xsd" namespace="http://customer.com/schema/common/v1" />
  <xsd:import schemaLocation="./CodeLists.xsd" namespace="http://customer.com/schema/common/v1" />
  <xsd:element name="Fault" type="tns:FaultType">
  </xsd:element>
  <xsd:complexType name="FaultType">
    <xsd:complexContent mixed="false">
      <xsd:extension base="ws-bf:BaseFaultType">
        <xsd:sequence>
          <xsd:element minOccurs="0" name="Name" type="xsd:normalizedString">
          </xsd:element>
这是父XSD

的一部分

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:cmn="http://customer.com/schema/common/v1" xmlns:tns="http://customer.com/contract/vho/header/v1" xmlns:vfo="http://customer.com/contract/vfo/fault/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://customer.com/contract/vho/header/v1" version="1.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:import schemaLocation="./Fault.xsd" namespace="http://customer.com/contract/vfo/fault/v1" />
  <xsd:element name="Source" type="tns:SourceType" />
  <xsd:element name="Destination" type="tns:DestinationType" />
  <xsd:element name="Correlation" type="tns:CorrelationType" />
  <xsd:element name="Cache" type="tns:CacheType" />
  <xsd:element name="ServiceDocumentation" type="tns:ServiceDocumentationType" />
  <xsd:element name="ResultStatus" type="vfo:FaultType" />

我需要的是XSD专家告诉我,如果符合W3C标准,xml响应预期如下:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Header>
    <tns:ResultStatus xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:vfo="http://customer.com/contract/vfo/fault/v1" xmlns:cmn="http://customer.com/schema/common/v1" xmlns:ns3="http://www.w3.org/2005/08/addressing" xmlns:ns2="http://docs.oasis-open.org/wsrf/bf-2" xmlns:ns1="urn:un:unece:uncefact:documentation:standard:CoreComponentType:2" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://customer.com/contract/vho/header/v1">
      <vfo:Name>1006</vfo:Name>
      <vfo:Message>Invalid ChargeAccountNumber (not found).</vfo:Message>
      <ns2:Timestamp>2017-06-19T10:18:48.467+01:00</ns2:Timestamp>
   </tns:ResultStatus>
  </soapenv:Header>
  <soap-env:Body xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" />
</soapenv:Envelope>

在这个简洁示例中,Name值是属于BaseFaultType的Any结构还是父扩展FaultType?如果没有,为什么不呢? 是否有任何工具可以让我报告针对架构的响应的有效性?

1 个答案:

答案 0 :(得分:0)

BaseFault无法在其自己的命名空间之外进行扩展。在早期设计中,这个缺陷从未得到纠正: https://lists.oasis-open.org/archives/wsrf/200506/msg00060.html