<?xml version="1.0" encoding="UTF-8"?>
<!-- 
   Legal Disclaimer
	
   Copyright Notice
	
   (c) Copyright Akamai Technologies, 
       Computer Associates International, Inc., Fujitsu Limited, 
       Hewlett-Packard Development Company, 
       International Business Machines Corporation, SAP AG, 
       Sonic Software Corporation, Tibco Software Inc. and 
       The University of Chicago  2003, 2004  All rights reserved. 
              
-->

<xsd:schema 
  xmlns="http://www.w3.org/2001/XMLSchema" 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing"
  xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy" 
  xmlns:wsrp=
    "http://www.ibm.com/xmlns/stdwip/web-services/WS-ResourceProperties"
  xmlns:wsnt=
    "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification" 
  xmlns:wstop=
    "http://www.ibm.com/xmlns/stdwip/web-services/WS-Topics"
  targetNamespace=
    "http://www.ibm.com/xmlns/stdwip/web-services/WS-Topics"   
  elementFormDefault="qualified"  attributeFormDefault="unqualified">

<!-- ======================== Imports  ============================ -->
  
  <xsd:import namespace=
    "http://www.ibm.com/xmlns/stdwip/web-services/WS-ResourceProperties" 
              schemaLocation= 
  "http://www-106.ibm.com/developerworks/webservices/library/ws-resource/WS-ResourceProperties.xsd" 
  /> 
  <xsd:import namespace=
    "http://www.ibm.com/xmlns/stdwip/web-services/WS-BaseNotification" 
              schemaLocation= 
  "../WS-BaseNotification/WS-BaseNotification.1.xsd" 
  /> 

<!-- =============== utility type definitions  ==================== -->
  <xsd:complexType name="Documentation" mixed="true">
    <xsd:sequence>
      <xsd:any processContents="lax" minOccurs="0" 
               maxOccurs="unbounded" namespace="##any"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="ExtensibleDocumented" abstract="true" 
                   mixed="false">
    <xsd:sequence>
      <xsd:element name="documentation" type="wstop:Documentation" 
                   minOccurs="0" />
    </xsd:sequence>
    <xsd:anyAttribute namespace="##other" processContents="lax" />
  </xsd:complexType>

<!-- ================== Topic-Space Related  ====================== -->   
  <xsd:complexType name="TopicSpaceType">
    <xsd:complexContent>
       <xsd:extension base="wstop:ExtensibleDocumented">
         <xsd:sequence>
           <xsd:element name="Topic" type="wstop:TopicType" 
                        minOccurs="0" maxOccurs="unbounded"/>
           <xsd:any namespace="##other" 
                    minOccurs="0" maxOccurs="unbounded" 
                    processContents="lax"/>
         </xsd:sequence>
         <xsd:attribute name="name" type="xsd:NCName"/>
         <xsd:attribute name="targetNamespace" type="xsd:anyURI" 
                        use="required"/>
       </xsd:extension>
     </xsd:complexContent> 
   </xsd:complexType>

  <xsd:element name="TopicSpace" type="wstop:TopicSpaceType">
    <xsd:unique name="rootTopicUniqueness">
      <xsd:selector xpath="wstop:Topic"/>
        <xsd:field xpath="@name"/>
    </xsd:unique>
  </xsd:element>
  
<!-- ===================== Topic Related  ========================= -->   

  <xsd:group name="NonAliasTopicDefinition">
    <xsd:sequence>
      <xsd:element name="MessagePattern" 
                   type="wsrp:QueryExpressionType" 
                   minOccurs="0" maxOccurs="1" />
      <xsd:element name="Topic" type="wstop:TopicType" 
                   minOccurs="0" maxOccurs="unbounded">
         <xsd:unique name="childTopicUniqueness">
           <xsd:selector xpath="wstop:topic"/>
           <xsd:field xpath="@name"/>
         </xsd:unique>
      </xsd:element>
    </xsd:sequence>
  </xsd:group>

  <xsd:complexType name="TopicType">
    <xsd:complexContent>
      <xsd:extension base="wstop:ExtensibleDocumented">
        <xsd:sequence>
          <xsd:choice>
            <xsd:element name="AliasRef" 
                         type="wsnt:TopicExpressionType"
                         minOccurs="1" maxOccurs="1" />
            <xsd:group ref="wstop:NonAliasTopicDefinition" />
          </xsd:choice>
          <xsd:any namespace="##other" minOccurs="0" 
                                       maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:attribute name="name" use="required" type="xsd:NCName"/>
        <xsd:attribute name="messageTypes" default="xsd:any">
          <xsd:simpleType>
            <xsd:list itemType="xsd:QName"/>
          </xsd:simpleType>
        </xsd:attribute>
        <xsd:attribute name="final" type="xsd:boolean" 
                                     default="false"/>
      </xsd:extension>
    </xsd:complexContent>  
  </xsd:complexType>

<!-- ================ Topic Expression Related  =================== -->   
  
  <xsd:simpleType name="FullTopicPathExpression">
    <xsd:restriction base="xsd:token">
      <xsd:annotation>
        <xsd:documentation>
        TopicPathExpression  ::=   TopicPath ( '|' TopicPath )*  
        TopicPath       ::=   RootTopic ChildTopicExpression* 
        RootTopic       ::=   NamespacePrefix? ('//')? (NCName | '*')  
        NamespacePrefix ::=   NCName ':'      
        ChildTopicExpression ::=   '/' '/'? (NCName | '*'| '.')
                        
        </xsd:documentation>
      </xsd:annotation>
      <xsd:pattern value= 
         "([\i-[:]][\c-[:]]*:)?(//)?([\i-[:]][\c-[:]]*|\*)((/|//)([\i-[:]][\c-[:]]*|\*|[.]))*(\|([\i-[:]][\c-[:]]*:)?(//)?([\i-[:]][\c-[:]]*|\*)((/|//)([\i-[:]][\c-[:]]*|\*|[.]))*)*">
      </xsd:pattern>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="ConcreteTopicPathExpression">
    <xsd:restriction base="xsd:token">
      <xsd:annotation>
        <xsd:documentation>
  The pattern allows strings matching the following EBNF:
    ConcreteTopicPath    ::=   RootTopic ChildTopic*    
    RootTopic            ::=   QName  
    ChildTopic           ::=   '/' NCName 
                        
        </xsd:documentation>
      </xsd:annotation>
      <xsd:pattern value=
"(( [\i-[:]][\c-[:]]*:)? [\i-[:]][\c-[:]]*)(/ [\i-[:]][\c-[:]]*)*" >
      </xsd:pattern>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="SimpleTopicExpression">
    <xsd:restriction base="xsd:token">
      <xsd:annotation>
        <xsd:documentation>
  The pattern allows strings matching the following EBNF:
    RootTopic            ::=   QName  
                        
        </xsd:documentation>
      </xsd:annotation>
      <xsd:pattern value="([\i-[:]][\c-[:]]*:)?( [\i-[:]][\c-[:]]*)" >
      </xsd:pattern>
    </xsd:restriction>
  </xsd:simpleType>

</xsd:schema>