Expression Pattern Language (eXPL)

Query Names

Scope Transitions

In the case of a query, a name can have an active role in the execution of the query. A scope part, when specified in a query or calculator name, will cause execution to switch to the indicated scope. A simple demonstration is given in tutorial18 CalculateSquareMiles3, which has two queries:

  query surface_area_query(surface_area : country_area);
  query au_surface_area_query(surface_area : 
    australia.country_area);
                  

In the first query, the calculator executes in the global scope while in the second query, the same calculator executes in the Australia scope. The results of the first query are given in imperial units, and in metric units for the second. Note that the calculator must be in the global scope for this to work.

The CalculateSquareMiles3 example shows use of a custom scope property with key of "location". Note the global scope is declared with name "global" in order to define the custom property in this scope.

A different scope transition demonstration is given in tutorial18 ForeignColors Here a global scope choice calculator is referenced from two different scope queries. A scope transition occurs when the calculator executes. The FOREIGN_COLORS script has the following queries:

scope french (language="fr", region="FR")
{
  query color_query (shade : swatch);
}
scope german (language="de", region="DE")
{
  query color_query (shade : swatch);
}
               

A query with French aqua "bleu vert" returns result colors(aqua = bleu vert, black = noir, blue = bleu, white = blanc)

The Foreign Colors example shows scope-specific resources in use for both input and output. The resource names are made the same as the axiom names so the "resource" reserved word can be used.