XSD-Schema

Das folgende XSD-Schema wird verwendet, um die XML-Struktur einer Webservice-Definitionsdatei auf Gültigkeit zu prüfen:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="https://www.business-app.com/WebServices" targetNamespace="https://www.business-app.com/WebServices" elementFormDefault="qualified">
  <!-- Root node -->
  <xs:element name="BAWebServiceDefinitions">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="Include" type="includeType"/>
        <xs:element name="WebService" type="WebServiceType"/>
        <xs:element name="WebServiceModification" type="WebServiceModificationType"/>
        <xs:element name="MappingTemplate" type="MappingTemplateType"/>
        <xs:element name="MappingTemplateModification" type="MappingTemplateModificationType"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>

  <!-- Own types -->
  <xs:complexType name="WebServiceModificationType">
    <xs:all>
      <xs:element name="Method" type="mandatoryMethodType" minOccurs="0" maxOccurs="1"/>
      <xs:element name="Url" type="mandatoryStringType" minOccurs="0" maxOccurs="1"/>
      <xs:element name="Authentication" type="AuthenticationType" minOccurs="0" maxOccurs="1"/>
      <xs:element name="UrlMappings" type="GeneralMappingCollectionType" minOccurs="0" maxOccurs="1"/>
      <xs:element name="OutboundMappings" type="GeneralMappingCollectionType" minOccurs="0" maxOccurs="1"/>
      <xs:element name="InboundMappings" type="GeneralMappingCollectionType" minOccurs="0" maxOccurs="1"/>
      <xs:element name="FollowUpWebService" type="FollowUpWSType" minOccurs="0" maxOccurs="1"/>
      <xs:element name="ErrorMapping" type="ErrorMappingType" minOccurs="0" maxOccurs="1"/>
    </xs:all>
    <xs:attribute name="id" type="xs:string" use="required"/>
    <xs:attribute name="displayName" type="mandatoryStringType"/>
    <xs:attribute name="outboundModelType" type="mandatoryStringType"/>
    <xs:attribute name="inboundModelType" type="mandatoryStringType"/>
    <xs:attribute name="lifeCycleEventHandler" type="mandatoryStringType"/>
    <xs:attribute name="selectable" type="xs:boolean"/>
    <xs:attribute name="callLog" type="WebServiceCallLogType" default="None"/>
  </xs:complexType>

  <xs:complexType name="WebServiceType">
    <xs:all>
      <xs:element name="Method" type="MethodType" minOccurs="1" maxOccurs="1"/>
      <xs:element name="Url" type="xs:string" minOccurs="1" maxOccurs="1"/>
      <xs:element name="Authentication" type="AuthenticationType" minOccurs="0" maxOccurs="1"/>
      <xs:element name="UrlMappings" type="GeneralMappingCollectionType" minOccurs="0" maxOccurs="1"/>
      <xs:element name="OutboundMappings" type="GeneralMappingCollectionType" minOccurs="0" maxOccurs="1"/>
      <xs:element name="InboundMappings" type="GeneralMappingCollectionType" minOccurs="0" maxOccurs="1"/>
      <xs:element name="FollowUpWebService" type="FollowUpWSType" minOccurs="0" maxOccurs="1"/>
      <xs:element name="ErrorMapping" type="ErrorMappingType" minOccurs="0" maxOccurs="1"/>
    </xs:all>
    <xs:attribute name="id" type="xs:string" use="required"/>
    <xs:attribute name="displayName" type="mandatoryStringType"/>
    <xs:attribute name="outboundModelType" type="mandatoryStringType"/>
    <xs:attribute name="inboundModelType" type="mandatoryStringType"/>
    <xs:attribute name="lifeCycleEventHandler" type="mandatoryStringType"/>
    <xs:attribute name="selectable" type="xs:boolean" default="true"/>
    <xs:attribute name="callLog" type="WebServiceCallLogType" default="None"/>
  </xs:complexType>

  <xs:complexType name="AuthenticationType">
    <xs:choice minOccurs="0">
      <xs:element name="JWT">
        <xs:complexType>
          <xs:attribute name="serviceRef" type="xs:string" use="required"/>
        </xs:complexType>
      </xs:element>

      <xs:element name="Basic">
        <xs:complexType>
          <xs:all>
            <xs:element name="Username" type="AuthenticationSubInformationType" minOccurs="1" maxOccurs="1"/>
            <xs:element name="Password" type="AuthenticationSubInformationType" minOccurs="1" maxOccurs="1"/>
          </xs:all>
        </xs:complexType>
      </xs:element>

      <xs:element name="Header">
        <xs:complexType>
          <xs:all>
            <xs:element name="Name" type="AuthenticationSubInformationType" minOccurs="1" maxOccurs="1"/>
            <xs:element name="Value" type="AuthenticationSubInformationType" minOccurs="1" maxOccurs="1"/>
          </xs:all>
        </xs:complexType>
      </xs:element>
    </xs:choice>
  </xs:complexType>

  <xs:complexType name="AuthenticationSubInformationType">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="type" type="SelectorType"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <xs:complexType name="FollowUpWSType">
    <xs:all>
      <xs:element name="SourceProperty" type="mandatoryStringType" minOccurs="0"/>
      <xs:element name="FilterCollection" type="mandatoryStringType" minOccurs="0"/>
    </xs:all>
    <xs:attribute name="serviceRef" type="mandatoryStringType" use="required"/>
  </xs:complexType>

  <xs:complexType name="ErrorMappingType">
    <xs:all>
      <xs:element name="Message" type="xs:string" minOccurs="1" maxOccurs="1" nillable="true"/>
      <xs:element name="DetailsArray" type="mandatoryStringType" minOccurs="0" maxOccurs="1"/>
      <xs:element name="TransformOutput" type="mandatoryStringType" minOccurs="0" maxOccurs="1"/>
      <xs:element name="CacheStorage" type="EMCacheStorageType" minOccurs="0"/>
    </xs:all>
  </xs:complexType>

  <xs:complexType name="EMCacheStorageType">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element name="Entry" type="EMCacheStorageEntryType" minOccurs="0"/>
    </xs:choice>
  </xs:complexType>

  <xs:complexType name="EMCacheStorageEntryType">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="index" type="xs:integer" use="required"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <xs:complexType name="FromType">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="type" type="SelectorType"/>
        <!-- Default selector types:
          InboundMapping: jsonpath
          OutboundMapping: formula
          MappingTemplate: formula -->
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <xs:complexType name="MappingType">
    <xs:all>
      <xs:element name="From" type="FromType" nillable="true"/>
      <xs:element name="To" type="mandatoryStringType" nillable="true"/>
      <xs:element name="Transform" type="mandatoryStringType" minOccurs="0"/>
    </xs:all>
  </xs:complexType>

  <xs:complexType name="RowMappingsType">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:group ref="AnyMapping"/>
    </xs:choice>
    <xs:attribute name="targetRowType" type="mandatoryStringType" use="required"/>
  </xs:complexType>

  <xs:complexType name="MultiValueMappingType">
    <xs:all>
      <xs:element name="From" type="FromType"/>
      <xs:element name="To" type="mandatoryStringType" nillable="true"/>
      <xs:element name="Transform" type="mandatoryStringType" minOccurs="0"/>
      <xs:element name="RowMappings" type="RowMappingsType"/>
    </xs:all>
  </xs:complexType>

  <xs:group name="AnyMapping">
    <xs:choice>
      <xs:element name="Mapping" type="MappingType"/>
      <xs:element name="MultiValueMapping" type="MultiValueMappingType"/>
      <xs:element name="TemplateMapping" type="TemplateMappingType"/>
    </xs:choice>
  </xs:group>

  <xs:complexType name="TemplateMappingType">
    <xs:attribute name="ref" type="mandatoryStringType" use="required"/>
  </xs:complexType>

  <xs:complexType name="MappingTemplateType">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:group ref="AnyMapping"/>
    </xs:choice>
    <xs:attribute name="id" type="mandatoryStringType" use="required"/>
    <xs:attribute name="sourceType" type="mandatoryStringType" use="required"/>
    <xs:attribute name="targetType" type="mandatoryStringType" use="required"/>
  </xs:complexType>

  <xs:complexType name="MappingTemplateModificationType">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:group ref="AnyMapping"/>
    </xs:choice>
    <xs:attribute name="id" type="mandatoryStringType" use="required"/>
  </xs:complexType>


  <xs:complexType name="GeneralMappingCollectionType">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:group ref="AnyMapping"/>
    </xs:choice>
  </xs:complexType>

  <xs:simpleType name="SelectorType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="text"/>
      <xs:enumeration value="formula"/>
      <xs:enumeration value="jsonpath"/>
      <xs:enumeration value="enum"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="MethodType">
    <xs:restriction base="xs:string">
      <xs:enumeration value=""/>
      <xs:enumeration value="GET"/>
      <xs:enumeration value="POST"/>
      <xs:enumeration value="PUT"/>
      <xs:enumeration value="PATCH"/>
      <xs:enumeration value="DELETE"/>
      <xs:enumeration value="OPTION"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="WebServiceCallLogType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="None"/>
      <xs:enumeration value="Medium"/>
      <xs:enumeration value="Full"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="mandatoryMethodType">
    <xs:restriction base="xs:string">
      <xs:minLength value="1"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="includeTypeType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="file"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="includeType">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="type" type="includeTypeType" fixed="file"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <!-- Global types for extension -->
  <xs:simpleType name="mandatoryStringType">
    <xs:restriction base="xs:string">
      <xs:minLength value="1"/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>