[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

XSD alternatives




Hi All,


XML Schema is a very flexible language and there are often
a variety of ways to define schemas that will accept the same
input documents.

Consider the following two alternatives ("SubstitutionGroup" and
"Choice") for defining a portion of the NETCONF rpc operations:

"SubstitutionGroup":

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
    targetNamespace="http://ietf.org/netconf/1.0/base";
    xmlns:xc="http://ietf.org/netconf/1.0/base";
    xmlns:xsd="http://www.w3.org/2001/XMLSchema";
    elementFormDefault="unqualified">

  <xsd:complexType name="rpcType">
    <xsd:sequence>
      <xsd:element ref="xc:rpcOperation"/>
    </xsd:sequence>
    <xsd:attribute name="message-id" type="xsd:string"/>
  </xsd:complexType>

<xsd:element name="rpc" type="xc:rpcType"/>

<xsd:complexType name="rpcOperationType"/>

  <xsd:element name="rpcOperation"
       type="xc:rpcOperationType" abstract="true"/>

  <xsd:complexType name="get-configType">
    <xsd:complexContent>
      <xsd:extension base="xc:rpcOperationType">
        <xsd:sequence>
          <xsd:element name="source"/>
        </xsd:sequence>
      </xsd:extension>
    </xsd:complexContent>
  </xsd:complexType>

  <xsd:element name="get-config" type="xc:get-configType"
       substitutionGroup="xc:rpcOperation"/>

  <xsd:complexType name="edit-configType">
    <xsd:complexContent>
      <xsd:extension base="xc:rpcOperationType">
        <xsd:sequence>
          <xsd:element name="source"/>
        </xsd:sequence>
      </xsd:extension>
    </xsd:complexContent>
  </xsd:complexType>

  <xsd:element name="edit-config" type="xc:edit-configType"
       substitutionGroup="xc:rpcOperation"/>

</xsd:schema>


"Choice":


<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
    targetNamespace="http://ietf.org/netconf/1.0/base";
    xmlns:xc="http://ietf.org/netconf/1.0/base";
    xmlns:xsd="http://www.w3.org/2001/XMLSchema";
    elementFormDefault="unqualified">

  <xsd:element name="rpc" block="#all">
    <xsd:complexType>
      <xsd:choice>
        <xsd:element name="get-config" type="xc:get-configType"/>
        <xsd:element name="edit-config" type="xc:edit-configType"/>
        <xsd:any processContents="strict"/>
      </xsd:choice>
      <xsd:attribute name="message-id" type="xsd:string" />
    </xsd:complexType>
  </xsd:element>

  <xsd:complexType name="edit-configType" block="#all">
   <xsd:sequence>
     <xsd:element name="source" />
   </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="get-configType" block="#all">
   <xsd:sequence>
     <xsd:element name="source"/>
   </xsd:sequence>
  </xsd:complexType>

</xsd:schema>



The "SubstitutionGroup" approach models the abstract relationships
between the operations (such as the fact that both edit-config and
get-config are rpcOperations) and this is reflected in generated
source code (such as that obtained from Apache Axis WSDL2Java).

The "Choice" approach is more compact and allows extension of the
operations to be forbidden (via block="#all"), but does not provide
as many hints to code-generation tools.

What advantages and disadvantages do people see in the different
approaches?  Which is to be preferred?  Is it desirable to restrict
modification of the base operations?

Thanks,
Ted.


-- to unsubscribe send a message to netconf-request@ops.ietf.org with the word 'unsubscribe' in a single line as the message text body. archive: <http://ops.ietf.org/lists/netconf/>