Java configuration with XML Schema

A sample XML Schema and Java class show you how

返回原文..

Appendix A: XML Schema
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v4.0 U (http://www.xmlspy.com) by Marcello Vitaletti (IBM/Tivoli) -->
<!--W3C Schema generated by XML Spy v4.0 U (http://www.xmlspy.com)-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
   <xs:element name="Application">
      <xs:complexType>
         <xs:sequence minOccurs="0" maxOccurs="unbounded">
            <xs:choice>
               <xs:element name="Parameter" type="ParameterType"/>
               <xs:element name="Object" type="ObjectType"/>
               <xs:element name="Property" type="PropertyType"/>
               <xs:element name="ClassMethod" type="ClassMethodType"/>
               <xs:element name="InstanceMethod" type="InstanceMethodType"/>
               <xs:element name="Topic" type="TopicType"/>
               <xs:element name="Package" type="PackageType"/>
            </xs:choice>
         </xs:sequence>
         <xs:attribute name="name" type="xs:string" use="required"/>
      </xs:complexType>
   </xs:element>
   <xs:complexType name="ClassType">
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
         <xs:choice>
            <xs:element name="Parameter" type="ParameterType"/>
            <xs:element name="Object" type="ObjectType"/>
            <xs:element name="Property" type="PropertyType"/>
            <xs:element name="ClassMethod" type="ClassMethodType"/>
            <xs:element name="InstanceMethod" type="InstanceMethodType"/>
         </xs:choice>
      </xs:sequence>
      <xs:attribute name="name" type="xs:string" use="required"/>
   </xs:complexType>
   <xs:complexType name="ClassMethodType">
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
         <xs:choice>
            <xs:element ref="Reference"/>
            <xs:element ref="Boolean"/>
            <xs:element ref="Byte"/>
            <xs:element ref="Short"/>
            <xs:element ref="Integer"/>
            <xs:element ref="Long"/>
            <xs:element ref="Float"/>
            <xs:element ref="Double"/>
            <xs:element ref="String"/>
         </xs:choice>
      </xs:sequence>
      <xs:attribute name="name" type="xs:string" use="required"/>
      <xs:attribute name="class" type="xs:string" use="required"/>
      <xs:attribute name="method" type="xs:string" use="required"/>
   </xs:complexType>
   <xs:complexType name="InstanceMethodType">
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
         <xs:choice>
            <xs:element ref="Reference"/>
            <xs:element ref="Boolean"/>
            <xs:element ref="Byte"/>
            <xs:element ref="Short"/>
            <xs:element ref="Integer"/>
            <xs:element ref="Long"/>
            <xs:element ref="Float"/>
            <xs:element ref="Double"/>
            <xs:element ref="String"/>
         </xs:choice>
      </xs:sequence>
      <xs:attribute name="name" type="xs:string" use="required"/>
      <xs:attribute name="reference" type="xs:string" use="required"/>
      <xs:attribute name="method" type="xs:string" use="required"/>
   </xs:complexType>
   <xs:complexType name="ObjectType">
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
         <xs:choice>
            <xs:element ref="Reference"/>
            <xs:element ref="Boolean"/>
            <xs:element ref="Byte"/>
            <xs:element ref="Short"/>
            <xs:element ref="Integer"/>
            <xs:element ref="Long"/>
            <xs:element ref="Float"/>
            <xs:element ref="Double"/>
            <xs:element ref="String"/>
         </xs:choice>
      </xs:sequence>
      <xs:attribute name="name" type="xs:string" use="required"/>
      <xs:attribute name="class" type="xs:string" use="required"/>
   </xs:complexType>
   <xs:complexType name="PackageType">
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
         <xs:choice>
            <xs:element name="Parameter" type="ParameterType"/>
            <xs:element name="Object" type="ObjectType"/>
            <xs:element name="Property" type="PropertyType"/>
            <xs:element name="ClassMethod" type="ClassMethodType"/>
            <xs:element name="InstanceMethod" type="InstanceMethodType"/>
            <xs:element name="Class" type="ClassType"/>
            <xs:element name="Package" type="PackageType"/>
         </xs:choice>
      </xs:sequence>
      <xs:attribute name="name" type="xs:string" use="required"/>
   </xs:complexType>
   <xs:complexType name="ParameterType">
      <xs:choice>
         <xs:element ref="Reference"/>
         <xs:element ref="Boolean"/>
         <xs:element ref="Byte"/>
         <xs:element ref="Short"/>
         <xs:element ref="Integer"/>
         <xs:element ref="Long"/>
         <xs:element ref="Float"/>
         <xs:element ref="Double"/>
         <xs:element ref="String"/>
      </xs:choice>
      <xs:attribute name="name" type="xs:string" use="required"/>
   </xs:complexType>
   <xs:complexType name="PropertyType">
      <xs:attribute name="name" type="xs:string" use="required"/>
      <xs:attribute name="value" type="xs:string" use="required"/>
   </xs:complexType>
   <xs:complexType name="TopicType">
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
         <xs:choice>
            <xs:element name="Parameter" type="ParameterType"/>
            <xs:element name="Object" type="ObjectType"/>
            <xs:element name="Property" type="PropertyType"/>
            <xs:element name="ClassMethod" type="ClassMethodType"/>
            <xs:element name="InstanceMethod" type="InstanceMethodType"/>
            <xs:element name="Topic" type="TopicType"/>
         </xs:choice>
      </xs:sequence>
      <xs:attribute name="name" type="xs:string" use="required"/>
   </xs:complexType>
   <xs:element name="Boolean" type="xs:boolean"/>
   <xs:element name="Byte" type="xs:byte"/>
   <xs:element name="Short" type="xs:short"/>
   <xs:element name="Integer" type="xs:int"/>
   <xs:element name="Long" type="xs:long"/>
   <xs:element name="Float" type="xs:float"/>
   <xs:element name="Double" type="xs:double"/>
   <xs:element name="String" type="xs:string"/>
   <xs:element name="Reference" type="xs:string"/>
</xs:schema>

返回原文.