rewriteSets.xml ================= The ``rewriteSets.xml`` file defines named sets of rewrite statements that can be added to queries defined in a separate :doc:`query-xml` file, or in a ```` element within a :doc:`project-xml` file. XML elements ------------ The elements that comprise the ``rewriteSets.xml`` file are described below. .. seealso:: Some elements of the ``rewriteSets.xml`` file can contain ```` elements, as described below. See :doc:`conditional-xml` for further details. ^^^^^^^^^^^^^ This is the outermost element, which takes no attributes and contains one or more ```` elements. It may also contain ```` elements. ^^^^^^^^^^^^^ This element defines a set of rewrites, assigns the set a unique name, and specifies the default 'level' to use if not overridden in the ``queries.xml`` file when the rewrite set is referenced. If the ``append-values`` flag is "true", rows are written out for all elements including those with zero results. When the rewrite sets are inserted into a query file, ``level`` is set to "true" if any of the rewrite sets specified ``append-values="true"``, otherwise the value is set to "false". If ``byAEZ="true"``, each rewrite is expanded to 18 elements with the same 'to' attribute, but with the 'from' attributes formed by appending 'AEZ' and zero-padded, 2-digit integers from 1 to 18. In the example below, the element .. code-block:: xml ... is expanded in the generated query file to: .. code-block:: xml The ```` element may contain ```` elements. ^^^^^^^^^^^^^ The ```` element defines a label rewrite. If the element specifies ``byAEZ="true"``, the element is expanded as described above. If all elements in a rewriteSet are to be expanded by AEZ, it is more convenient to specify this once in the ```` element. The resulting ```` statements are inserted into the query file and processed as usual by the GCAM batch query processor: * If the "to" value is empty, any row with a matching value is dropped from the result set. * If the "to" value specified a new name, the label is rewritten using the new name and grouped with other values having that name. This is used to aggregate values, e.g., from 32 regions to a smaller number. In the example below, the ``resultSet`` named ``eightRegions`` maps the 32 standard GCAM regions into 8 regions. * If a value is not specified, or if the "from" and "to" values are the same, the row is processed normally. +-------------+------------+-----------+----------+ | Attribute | Required | Default | Values | +=============+============+===========+==========+ | from | yes | (none) | text | +-------------+------------+-----------+----------+ | to | yes | (none) | text | +-------------+------------+-----------+----------+ | byAEZ | no | (none) | text | +-------------+------------+-----------+----------+ Example ^^^^^^^^ This is an example of a file defining rewrite sets. .. code-block:: xml