1 <?xml version="1.0"?>
   2 <!--
   3  Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   4  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5 
   6  This code is free software; you can redistribute it and/or modify it
   7  under the terms of the GNU General Public License version 2 only, as
   8  published by the Free Software Foundation.  Oracle designates this
   9  particular file as subject to the "Classpath" exception as provided
  10  by Oracle in the LICENSE file that accompanied this code.
  11 
  12  This code is distributed in the hope that it will be useful, but WITHOUT
  13  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  version 2 for more details (a copy is included in the LICENSE file that
  16  accompanied this code).
  17 
  18  You should have received a copy of the GNU General Public License version
  19  2 along with this work; if not, write to the Free Software Foundation,
  20  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21 
  22  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  23  or visit www.oracle.com if you need additional information or have any
  24  questions.
  25 -->
  26 
  27 <!--
  28 DTD binding information file which is supported by this version of XJC.
  29 
  30 - Changes from the EA1 is marked by "CHANGE:"
  31 - "ref:key" and "ref:keyref" are used to specify cross-reference
  32   information.
  33 - "a:defaultValue" is used to specify the default behavior.
  34   Note that default behaviors are hard-coded to the source code.
  35   Values specified in this schema is not used in the actual processing.
  36 -->
  37 <grammar
  38   xmlns="http://relaxng.org/ns/structure/1.0"
  39   xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
  40   xmlns:a="http://relaxng.org/ns/annotation/1.0"
  41   xmlns:ref="urn:crossreference"
  42   datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  43 
  44   <start>
  45     <element name="xml-java-binding-schema">
  46       <optional>
  47         <attribute name="version">
  48           <value>1.0ea2</value>
  49         </attribute>
  50       </optional>
  51 
  52       <interleave>
  53         <optional>
  54           <element name="options">
  55             <optional>
  56               <attribute name="package"/>
  57             </optional>
  58           </element>
  59         </optional>
  60         <optional>
  61           <element name="xjc:serializable">
  62             <optional>
  63               <attribute name="uid">
  64                 <data type="long"/>
  65               </attribute>
  66             </optional>
  67           </element>
  68         </optional>
  69         <optional>
  70           <element name="xjc:superClass">
  71             <attribute name="name"/>
  72           </element>
  73         </optional>
  74         <!-- light-weight runtime -->
  75         <optional>
  76           <element name="xjc:noMarshaller">
  77             <empty/>
  78           </element>
  79         </optional>
  80         <optional>
  81           <element name="xjc:noUnmarshaller">
  82             <empty/>
  83           </element>
  84         </optional>
  85         <optional>
  86           <element name="xjc:noValidator">
  87             <empty/>
  88           </element>
  89         </optional>
  90         <optional>
  91           <element name="xjc:noValidatingUnmarshaller">
  92             <empty/>
  93           </element>
  94         </optional>
  95         <zeroOrMore>
  96           <choice>
  97             <ref name="toplevel.declaration"/>
  98             <ref name="global.or.local.declaration"/>
  99           </choice>
 100         </zeroOrMore>
 101       </interleave>
 102     </element>
 103   </start>
 104  
 105  
 106  
 107  
 108   <!-- element-class declaration -->
 109   <define name="toplevel.declaration" combine="choice">
 110     <element name="element">
 111       <attribute name="name"/>
 112       <attribute name="type">
 113         <value>class</value>
 114       </attribute>
 115       <optional>
 116         <attribute name="class">
 117           <ref name="java.classname.datatype"/>
 118         </attribute>
 119       </optional>
 120       <optional>
 121         <attribute name="root" a:defaultValue="false">
 122           <choice>
 123             <value>true</value>
 124             <value>false</value>
 125           </choice>
 126         </attribute>
 127       </optional>
 128 
 129       <interleave>
 130         <!-- attribute-property declaration -->
 131         <zeroOrMore>
 132           <element name="attribute">
 133             <attribute name="name"/>
 134             <optional>
 135               <attribute name="property"/>
 136             </optional>
 137             <optional>
 138               <ref name="collection.att"/>
 139             </optional>
 140             <optional>
 141               <attribute name="convert">
 142                 <text ref:keyref="conversion"/>
 143               </attribute>
 144             </optional>
 145           </element>
 146         </zeroOrMore>
 147 
 148         <zeroOrMore>
 149           <ref name="global.or.local.declaration"/>
 150         </zeroOrMore>
 151 
 152         <!-- element-local declarations -->
 153         <zeroOrMore>
 154           <element name="constructor">
 155             <attribute name="properties">
 156               <list>
 157                 <oneOrMore>
 158                   <!-- point to a property defined in this element -->
 159                   <data type="token"/>
 160                 </oneOrMore>
 161               </list>
 162             </attribute>
 163           </element>
 164         </zeroOrMore>
 165 
 166         <optional>
 167           <element name="content">
 168             <interleave>
 169               <choice>
 170                 <!-- general content-property declaration -->
 171                 <ref name="collection.particle.decl"/>
 172 
 173                 <!-- model-based content property declaration -->
 174                 <group>
 175                   <zeroOrMore>
 176                     <choice>
 177                       <element name="element-ref">
 178                         <attribute name="name"/>
 179                         <optional>
 180                           <attribute name="property"/>
 181                         </optional>
 182                         <optional>
 183                           <ref name="collection.att"/>
 184                         </optional>
 185                       </element>
 186                       <element>
 187                         <choice>
 188                           <name>sequence</name>
 189                           <name>choice</name>
 190                         </choice>
 191                         <ref name="collection.particle.decl"/>
 192                       </element>
 193                     </choice>
 194                   </zeroOrMore>
 195                   <optional><!-- followed by an optional <rest> -->
 196                     <element name="rest">
 197                       <ref name="collection.particle.decl"/>
 198                     </element>
 199                   </optional>
 200                 </group>
 201               </choice>
 202             </interleave>
 203           </element>
 204         </optional>
 205       </interleave>
 206     </element>
 207   </define>
 208 
 209   <define name="collection.particle.decl">
 210     <attribute name="property"/>
 211     <optional>
 212       <ref name="collection.att"/>
 213     </optional>
 214     <optional>
 215       <attribute name="supertype"/>
 216     </optional>
 217   </define>
 218 
 219   <define name="collection.att">
 220     <attribute name="collection">
 221       <!-- CHANGE: array is removed and set,vector are added -->
 222       <choice>
 223         <value>list</value>
 224         <value>set</value>
 225         <value>vector</value>
 226       </choice>
 227     </attribute>
 228   </define>
 229 
 230  
 231  
 232   <!-- conversion declaration -->
 233   <define name="global.or.local.declaration" combine="choice">
 234     <element name="conversion">
 235       <attribute name="name" ref:key="conversion"/>
 236       <optional>
 237         <!-- defaults to @name -->
 238         <attribute name="type"/>
 239       </optional>
 240       <optional>
 241         <attribute name="parse" a:defaultValue="new"/>
 242       </optional>
 243       <optional>
 244         <attribute name="print" a:defaultValue="toString"/>
 245       </optional>
 246       <optional>
 247         <attribute name="whitespace" a:defaultValue="collapse">
 248           <choice>
 249             <value>preserve</value>
 250             <value>replace</value><!-- CHANGE: it was normalize -->
 251             <value>collapse</value>
 252           </choice>
 253         </attribute>
 254       </optional>
 255     </element>
 256   </define>
 257  
 258   <!-- element-value declaration -->
 259   <define name="toplevel.declaration" combine="choice">
 260     <element name="element">
 261       <attribute name="name"/>
 262       <attribute name="type">
 263         <value>value</value>
 264       </attribute>
 265       <optional>
 266         <attribute name="convert">
 267           <text ref:keyref="conversion"/>
 268         </attribute>
 269       </optional>
 270     </element>
 271   </define>
 272  
 273   <!-- interface declaration -->
 274   <define name="toplevel.declaration" combine="choice">
 275     <element name="interface">
 276       <attribute name="name">
 277         <ref name="java.classname.datatype"/>
 278       </attribute>
 279       <attribute name="members">
 280         <list>
 281           <oneOrMore>
 282             <ref name="java.classname.datatype"/>
 283           </oneOrMore>
 284         </list>
 285       </attribute>
 286       <!-- CHANGE: TODO: @properties is not supported yet -->
 287     </element>
 288   </define>
 289  
 290   <!-- enumeration declaration -->
 291   <define name="global.or.local.declaration" combine="choice">
 292     <element name="enumeration">
 293       <attribute name="name">
 294         <ref name="java.classname.datatype"/>
 295       </attribute>
 296       <attribute name="members">
 297         <list>
 298           <oneOrMore>
 299             <data type="token"/>
 300           </oneOrMore>
 301         </list>
 302       </attribute>
 303     </element>
 304   </define>
 305  
 306  
 307  
 308   <!-- valid Java name -->
 309   <define name="java.name.datatype">
 310     <!-- TODO: add pattern facet or implement a custom datatype -->
 311     <data type="token"/>
 312   </define>
 313 
 314   <define name="java.classname.datatype">
 315     <ref name="java.name.datatype"/>
 316   </define>
 317 </grammar>