### How to create the Mondrian Schema Plugin

The Eclipse plugin was generated from mondrian.dtd using the amazing Eclipse EMF framework.

1. In mondrian.dtd, in `aggregator (sum|count|min|max|avg|distinct count) #REQUIRED`, replace the string "distinct count" with "distinct_count" because trang does not like the blank in the attribute value
2. Transform the mondrian.dtd into a XML Schema using trang from www.thaiopensource.com. You will have to use the `-o disable-abstract-elements` commandline option
3. In the generated mondrian.xsd replace "distinct_count" back to "distinct count"
4. Also replace

         <xs:element name="SQL">
           <xs:complexType mixed="true">
             <xs:attribute name="dialect" default="generic">
               <xs:simpleType>
                 <xs:restriction base="xs:token">
                   <xs:enumeration value="generic"/>
                   <xs:enumeration value="oracle"/>
                   <xs:enumeration value="mysql"/>
                   <xs:enumeration value="access"/>
                   <xs:enumeration value="postgres"/>
                   <xs:enumeration value="hsqldb"/>
                   <xs:enumeration value="mssql"/>
                 </xs:restriction>
               </xs:simpleType>
             </xs:attribute>
           </xs:complexType>
         </xs:element>

   with

         <xs:element name="SQL">
           <xs:complexType>
             <xs:simpleContent>
               <xs:extension base="xs:string">
                 <xs:attribute name="dialect" default="generic">
                   <xs:simpleType>
                     <xs:restriction base="xs:token">
                       <xs:enumeration value="generic"/>
                       <xs:enumeration value="oracle"/>
                       <xs:enumeration value="mysql"/>
                       <xs:enumeration value="access"/>
                       <xs:enumeration value="postgres"/>
                       <xs:enumeration value="hsqldb"/>
                       <xs:enumeration value="mssql"/>
                     </xs:restriction>
                   </xs:simpleType>
                 </xs:attribute>
               </xs:extension>
             </xs:simpleContent>
           </xs:complexType>
         </xs:element>

5. In Eclipse use the "New ..." Wizard to create a new EMF Project and choose mondrian.xsd as the source for the EMF Model
6. Open the mondrian.genmodel, adjust some properties like package names and projects, then right click "generate all".

There seem to be a problem with EMF 2.0. The Editor only accepts one child for the Join element. To fix this replace

      <xs:element name="Join" substitutionGroup="Relation">
        <xs:complexType>
          <xs:sequence>
            <xs:element ref="Relation"/>
            <xs:element ref="Relation"/>
          </xs:sequence>
          <xs:attribute name="leftAlias"/>
          <xs:attribute name="leftKey" use="required"/>
          <xs:attribute name="rightAlias"/>
          <xs:attribute name="rightKey" use="required"/>
        </xs:complexType>
      </xs:element>

with

      <xs:element name="Join">
        <xs:complexType>
          <xs:group ref="Relation" minOccurs="2" maxOccurs="2"/>
          <xs:attribute name="leftAlias"/>
          <xs:attribute name="leftKey" use="required"/>
          <xs:attribute name="rightAlias"/>
          <xs:attribute name="rightKey" use="required"/>
        </xs:complexType>
      </xs:element>

Also in the genmodel, the `JoinType` has a `relation : EFeatureMapEntry`. In the properties view, set the Edit Children property to false (otherwise you get duplicate entries in the tree view).