<!--
     This dtd file was automatically generated from XOM model aggregates.
     Do not edit this file by hand.
  -->

<!--
     This is the XML model for defining default aggregate table recognition
     and level/measure mapping.
     Revision is $Id: //open/mondrian/src/main/mondrian/rolap/aggmatcher/DefaultRulesSchema.xml#9 $
  -->
<!--
     Base is the base class for all of the elements.
     All elements can be enabled or not, have a tag, and
     can be validated.
  -->
<!ENTITY % Base "FactCountMatch|ForeignKeyMatch|TableMatch|Regex|LevelMapRef|MeasureMapRef|IgnoreMapRef|FactCountMatchRef|ForeignKeyMatchRef|TableMatchRef|LevelMap|MeasureMap|IgnoreMap|AggRule">

<!--
     This is a base class for all elements that can match strings
     where the case of the string is important. In addition,
     it has an id which services as its tag.
  -->
<!ENTITY % CaseMatcher "FactCountMatch|ForeignKeyMatch|TableMatch|Regex">

<!--
     A NameMatcher is a CaseMatcher that prepends and appends
     regular expressions to a given string as part of creating
     the matching regular expression. Both the pre/post
     regular expression can be null in which case matches are
     applied simply against the name (modulo case considerations).
     The purpose of this class is to allow aggregate tables to
     be identified when their table names are formed by placing
     text before and/or after the base fact table name.
  -->
<!ENTITY % NameMatcher "FactCountMatch|ForeignKeyMatch|TableMatch">

<!--
     This allows one to create an element that matches against a
     single template, where the template is an attribute.
     While much loved, this is currently not used.
  -->
<!ENTITY % Mapper "">

<!--
  -->
<!ENTITY % RegexMapper "LevelMap|MeasureMap|IgnoreMap">

<!ENTITY % Ref "LevelMapRef|MeasureMapRef|IgnoreMapRef|FactCountMatchRef|ForeignKeyMatchRef|TableMatchRef">

<!--
     The set of "named" rules for matching aggregate tables.
     Only one rule can be applied to a given connection. In
     addition, one rule must be set as the default - this rule
     is always the choice when not selecting by name.
     It is very important that the AggRules validate method is called
     prior to using any of the object.
  -->
<!ELEMENT AggRules ((TableMatch)*,(FactCountMatch)*,(ForeignKeyMatch)*,(LevelMap)*,(MeasureMap)*,(IgnoreMap)*,(AggRule)+)>
<!ATTLIST AggRules
tag CDATA #REQUIRED
>

<!--
     This is used to identify the "fact_count" column in an aggregate
     table. It allows one to match using regular exprssions.
     The default is that the name of the fact count colum is simply
     the string "fact_count".
  -->
<!ELEMENT FactCountMatch EMPTY>
<!ATTLIST FactCountMatch
factCountName CDATA "fact_count"
pretemplate CDATA #IMPLIED
posttemplate CDATA #IMPLIED
basename CDATA #IMPLIED
id CDATA #REQUIRED
charcase (ignore|exact|upper|lower) "ignore"
enabled (true|false) "true"
>

<!--
     This is used to identify foreign key columns in a candidate
     aggregate table given the name of a foreign key column of the
     base fact table. This allows such foreign keys to be identified
     by using a regular exprsssion. The default is to simply
     match the base fact table's foreign key column name.
  -->
<!ELEMENT ForeignKeyMatch EMPTY>
<!ATTLIST ForeignKeyMatch
pretemplate CDATA #IMPLIED
posttemplate CDATA #IMPLIED
basename CDATA #IMPLIED
id CDATA #REQUIRED
charcase (ignore|exact|upper|lower) "ignore"
enabled (true|false) "true"
>

<!--
     This is used to identify which tables in the database might
     be aggregate table of a given fact table.
     It is expected that aggregate table names will include the
     base fact table name with additional text before and/or
     after.
     It is not allow for both the prepending and appending
     regular expression text to be null (if it were, then only
     aggregate tables who names were the same as (modulo case)
     would match - which is surely not allowed).
  -->
<!ELEMENT TableMatch EMPTY>
<!ATTLIST TableMatch
pretemplate CDATA #IMPLIED
posttemplate CDATA #IMPLIED
basename CDATA #IMPLIED
id CDATA #REQUIRED
charcase (ignore|exact|upper|lower) "ignore"
enabled (true|false) "true"
>

<!--
     This element is used in a vector of child elements when
     one wishes to have one or more regular expressions associated
     with matching a given string. The parent element must
     initialize Regex object by calling its validate method
     passing in an array of template names.
     The cdata content is a regular expression with embedded
     template names. Each name must be surrounded by "${" and "}".
     Each time this is used for a new set of names, the names
     replace the template names in the regular expression.
     For example, if the charcase="lower", the attribute
     dot="-" (the default dot value is "_"), the template names are:
     "city", "state", and "country"
     and the cdata is:
     .*_${country}_.*_${city}
     Then when the names:
     "San Francisco", "California", and "U.S.A"
     are passed in, the regular expression becomes:
     .*_u-s-a_.*_san_francisco
     Note that a given template name can only appear ONCE in the
     template content, the cdata content. As an example, the
     following cdata template is not supported:
     .*_${country}_.*_${city}_${country}
  -->
<!ELEMENT Regex (#PCDATA)>
<!ATTLIST Regex
space CDATA "_"
dot CDATA "_"
id CDATA #REQUIRED
charcase (ignore|exact|upper|lower) "ignore"
enabled (true|false) "true"
>

<!ELEMENT LevelMapRef EMPTY>
<!ATTLIST LevelMapRef
refId CDATA #REQUIRED
enabled (true|false) "true"
>

<!ELEMENT MeasureMapRef EMPTY>
<!ATTLIST MeasureMapRef
refId CDATA #REQUIRED
enabled (true|false) "true"
>

<!ELEMENT IgnoreMapRef EMPTY>
<!ATTLIST IgnoreMapRef
refId CDATA #REQUIRED
enabled (true|false) "true"
>

<!ELEMENT FactCountMatchRef EMPTY>
<!ATTLIST FactCountMatchRef
refId CDATA #REQUIRED
enabled (true|false) "true"
>

<!ELEMENT ForeignKeyMatchRef EMPTY>
<!ATTLIST ForeignKeyMatchRef
refId CDATA #REQUIRED
enabled (true|false) "true"
>

<!ELEMENT TableMatchRef EMPTY>
<!ATTLIST TableMatchRef
refId CDATA #REQUIRED
enabled (true|false) "true"
>

<!--
     This is the template that maps from a combination of level
     usage_prefix
     hierarchy_name
     level_name
     level_column_name
  -->
<!ELEMENT LevelMap ((Regex)*)>
<!ATTLIST LevelMap
id CDATA #REQUIRED
enabled (true|false) "true"
>

<!--
     This is the template that maps from a combination of measure
     measure_name,
     measure_column_name, and
     aggregate_name ("count", "sum", "avg", "min", "max",
     "distinct-count").
  -->
<!ELEMENT MeasureMap ((Regex)*)>
<!ATTLIST MeasureMap
id CDATA #REQUIRED
enabled (true|false) "true"
>

<!--
     This is the template used to specify columns to be ignored.
     There are NO template names. One simply uses a regular
     expression.
  -->
<!ELEMENT IgnoreMap ((Regex)*)>
<!ATTLIST IgnoreMap
id CDATA #REQUIRED
enabled (true|false) "true"
>

<!--
     A RolapConnection uses one AggRule. If no name is specified, then
     the AggRule which is marked as default==true is used (validation
     fails if one and only one AggRule is not marked as the default).
     An AggRule has manditory child elements for matching the
     aggregate table names, aggregate table fact count column,
     foreign key columns, the measure columns, and the hierarchy level
     columns. These child elements can be specified as direct children
     of an AggRule element or by reference to elements defined as a
     pier to the AggRule (using references allows reuse of the child
     elements and with one quick edit the reference to use can be
     changed by changing the refid attribute value).
  -->
<!ELEMENT AggRule (IgnoreMap?,IgnoreMapRef?,FactCountMatch?,FactCountMatchRef?,ForeignKeyMatch?,ForeignKeyMatchRef?,TableMatch?,TableMatchRef?,LevelMap?,LevelMapRef?,MeasureMap?,MeasureMapRef?)>
<!ATTLIST AggRule
tag CDATA #REQUIRED
countColumn CDATA "fact_count"
enabled (true|false) "true"
>