<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="../../../../misc/Meta.xsl" ?>
<!--
// $Id: //open/util/resgen/src/org/eigenbase/xom/Meta.xml#4 $
// package org.eigenbase.xom is an XML Object Mapper
// Copyright (C) 2005-2005 The Eigenbase Project
// Copyright (C) 2005-2005 Disruptive Tech
// Copyright (C) 2005-2005 Red Square, Inc.
// Portions Copyright (C) 2000-2005 Kana Software, Inc. and others.
// All Rights Reserved.
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
// License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
//
// This file is the XOM Meta Model description of itself, in XML.
  -->

<Model
  name="meta"
  dtdName="meta.dtd"
  className="MetaDef"
  packageName="org.eigenbase.xom"
  root="Model"
  version="1.0"
  defaultKeepDef="true"
>

<Doc>
  This model is the XOM Meta Model.  It is the specification of the model used
  to define new XML-based models.  It is also an instance of itself.

</Doc>

<Element type="Model">
    <Doc>
       Model is the top-level element for a model description.  The model element
       contains all other elements in the model and also defines the model's
       basic attributes, such as its name and version number.
    </Doc>

    <Attribute name="name" required="true"/>
    <Attribute name="dtdName"/>
    <Attribute name="className"/>
    <Attribute name="packageName"/>
    <Attribute name="importName">
        <Doc>
            Colon-separated list of packages to import.
            For example, importName="java.lang.*:java.util.List"
        </Doc>
    </Attribute>
    <Attribute name="root" required="true"/>
    <Attribute name="prefix"/>
    <Attribute name="version" type="Double" required="true"/>
    <Attribute name="defaultKeepDef" type="Boolean" default="false">
        <Doc>
            Default value for <code>keepDef</code> attribute.
        </Doc>
    </Attribute>

    <Object name="doc" type="Doc"/>
    <Array name="elements" type="Definition" min="1">
        <Doc>
       The elements array contains a definition for each element within the
       model.  Elements include Class, Element, and String definitions.
    </Doc>
    </Array>
</Element>

<Class class="Definition">
    <Doc>
       The Definition class represents a generic type of element definition.
       The actual definition may be of a Class, Element, or String.
       Definitions are the basic building blocks of a model.
    </Doc>

    <Object name="doc" type="Doc">
        <Doc>
      Doc tags allow documentation to be added to any definition.  The
      documentation will automatically appear in all physical forms
      of this model, including dtds, java classes, and the xsl
      transformation.
    </Doc>
    </Object>
</Class>

<Class class="FullDefinition" superclass="Definition">
    <Doc>
       The FullDefinition class represents a fully-specified definition
       that may include content.
    </Doc>

    <Attribute name="contentModel" default="sequential">
        <Doc>
      Specifies the content model of this definition.  Content model
      determines how the contained objects and arrays will be parsed
      and intepreted:<ul>

      <li><dfn>Sequential</dfn> content is the default model.
      Under a sequential model, content is intepreted by its position,
      and the order of content in a .xml file must match the order
      defined in the model.</li>

      <li>Under <dfn>random</dfn> content, order is less important;
      different types are parsed as needed.  Order is still used to resolve
      multiple instances of the same type.</li>

      <li><dfn>Mixed</dfn> content allows text
      to appear intermixed with elements, which are interpreted in random
      order.  It is currently unsupported.</li>

      <li><dfn>Any</dfn> content removes all
      restrictions, allowing any content to appear (but at the price of
      a lack of type-safety in the java representation of the element).</li>

      <li><dfn>CData</dfn> content specifies text-only content.  No objects or arrays
      may be defined.</li>

      </ul>
    </Doc>
    <Value>sequential</Value>
    <Value>random</Value>
    <Value>mixed</Value>
    <Value>any</Value>
    <Value>cdata</Value>
    </Attribute>

    <Attribute name="keepDef" type="Boolean">
        <Doc>
            Whether to keep the underlying wrapper around (in a field
            called <code>_def</code>) after the object has been
            constructed.

            <p>If not specified, defaults to the value of the
                Model.defaultKeepDef attribute, or false if that is not
                specified.</p>
        </Doc>
    </Attribute>

    <Array name="attributes" type="Attribute">
        <Doc>
            This array defines all attributes to appear within this class or
            element.
        </Doc>
    </Array>

    <Array name="content" type="Content">
        <Doc>
      This array defines all content (objects and arrays) to appear within
      this class or element.  The interpretation of this array depends
      on the element's defined content model.
    </Doc>
    </Array>

    <Object name="any" type="Any"/>
    <Object name="cdata" type="CData"/>

    <Object name="code" type="Code">
        <Doc>
      This element allows arbitrary Java Code to be attached to any
      class or element.  Code sections are not verified until the final
      .java class is compiled and should be used sparingly.
    </Doc>
    </Object>
</Class>

<Element type="Element" class="FullDefinition">
    <Doc>
       An Element Definition defines a basic entity of the meta model.  Elements
       are containers for two types of data: attributes and content.  Attributes
       are simple name/value pairs which may take on the full range of Java
       types.  Content consists of other Elements and Strings, either
       appearing alone or as arrays.
    </Doc>

    <Attribute name="type" required="true"/>
    <Attribute name="class"/>
    <Attribute name="dtdName" required="false">
        <Doc>
        The dtdName attribute sets the name by which this Element will be
        known in the dtd.  If not specified, it will default to the model's
        prefix (in any) plus the type of this element.</Doc>
    </Attribute>
</Element>

<Element type="Class" class="FullDefinition">
    <Doc>
       A Class Definition defines a class of entities.  A class specifies a group
       of entities with similar properties.  Full inheritence is supported,
       although there are limits on what can be overridden.
    </Doc>

    <Attribute name="class" required="true"/>
    <Attribute name="superclass"/>
</Element>

<Element type="StringElement" class="Definition">
    <Doc>
       A StringElement is a simple type of element which has no attributes and
       whose content is a single String (usually represented as a CDATA section).
       StringElements are used when raw text must be included in a model, such
       as raw Java code, or SQL statements, or HTML documentation.
    </Doc>

    <Attribute name="type" required="true"/>
</Element>

<Element type="Plugin" class="Definition">
    <Doc>
       A Plugin in a special type of element whose content may be derived from
       a different model.  The exact model to use is specified by the
       individual XML file, allowing a Plugin element to link to another
       model dynamically.  The Plugin element automatically defines the
       defPackage and defClass attributes.  Other attributes may be added
       as needed.  Code and documentation sections are supported as well.
    </Doc>

    <Attribute name="type" required="true"/>
    <Attribute name="class"/>

    <Array name="attributes" type="Attribute"/>
    <Object name="code" type="Code"/>
</Element>

<Element type="Import" class="Definition">
    <Doc>
       An Import as a special type of element that represents another element
       stored in an external model.  The model to use is specified by the
       defPackage and defClass attributes of the import.
       An Import may not be derived from any class.
    </Doc>

    <Attribute name="type" required="true"/>
    <Attribute name="defPackage" required="true"/>
    <Attribute name="defClass" required="true"/>
    <Attribute name="dtdName"/>
</Element>

<StringElement type="Doc">
    <Doc>
       The Doc entity specifies a documentation section.  The text contained
       in this element should be raw text or HTML used to document the object
       in which the Doc section appears.
    </Doc>
</StringElement>

<StringElement type="Code">
    <Doc>
       The Code entity specifies a raw block of Java code.  Each Class/Element
       becomes represented by a Java Class.  Including a Code block inside
       a Class or Element will insert the code directly into the corresponding
       class.  No checking is done on the code until it is complied later.
    </Doc>
</StringElement>

<Element type="Attribute">
    <Doc>
       The Attribute entity appears within any Element definition.  It defines
       an Attribute, which is a name/value pair used to hold data inside of an
       Element.  The Attribute's definition includes its name, type, and
       usage information (default value and whether or not it is required).
       An Attribute definition may limit its values by specifying Value
       objects.
    </Doc>

    <Attribute name="name" required="true"/>
    <Attribute name="type" default="String"/>
    <Attribute name="required" type="Boolean" default="false"/>
    <Attribute name="default"/>

    <Object name="doc" type="Doc"/>
    <Array name="values" type="Value"/>
</Element>

<StringElement type="Value">
    <Doc>
       The Value entity specifies a single value in the set of allowed values
       for an Attribute.  The value is specifies as text so that any special
       characters may appear.
    </Doc>
</StringElement>

<Class class="Content">
    <Doc>
       The Content class contains all entities which represent types of
       content which may appear within an Element.  Content includes
       Objects, Arrays, Strings, and special markers such as Any.
    </Doc>
</Class>

<Element type="Object" class="Content">
    <Doc>
       An Object is a single instance of an Element type.  Objects have an
       identifying name and a type.  The name identifies the object within
       its Element and must be unique within the Element.  The object is itself
       an instance of an Element, and this Element is identified by the type.
       The type may be the type name of an Element or the class name of a Class.
    </Doc>

    <Attribute name="name" required="true"/>
    <Attribute name="type" required="true"/>
    <Attribute name="required" type="Boolean" default="false"/>

    <Object name="doc" type="Doc"/>
</Element>

<Element type="Array" class="Content">
    <Doc>
       An Array is a set of multiple instances of Elements.  The Array
       has an identifying name and a base type.  The name identifies the array
       within its Element and must be unique within the Element.  Each object
       in the array is an instance of the Element identified by the type.
       The type may be the type name of an Element or the class name of a Class.
    </Doc>

    <Attribute name="name" required="true"/>
    <Attribute name="type" required="true"/>
    <Attribute name="min" type="Integer" default="0"/>
    <Attribute name="max" type="Integer" default="0"/>

    <Object name="doc" type="Doc"/>
</Element>

<Element type="Any" class="Content">
    <Doc>
       The Any content is a special marker which allows an Element to
       contain any type of data.  The data will appear in a single
       array called "children".  The data will contain all kinds of
       node (elements, comments, text) if the content model is
       "mixed", otherwise just elements. If an Any marker appears, no other
       content may appear in the element.
    </Doc>
</Element>

<Element type="CData" class="Content">
    <Doc>
       The CData content is a special marker which allows an Element to
       contain a single CDATA section as its only content, yet still
       have attributes.  The data will appear in a single String
       called "cdata".  If a CData marker appears, no other
       content may appear in the element.
    </Doc>
</Element>

</Model>
