Repository navigation
Description
Background
Phase 2 of the MDL full compatibility work introduced three new datamodel constructs:
-
Equation::Arrayedwithdefault_equation-- Represents Vensim's:EXCEPT:syntax, where a default equation applies to all dimension elements not explicitly overridden. -
DimensionMappingwithelement_map-- Element-level correspondence between subscript families, supporting mappings like "element A in dimension X corresponds to element B in dimension Y." -
DataSourcemetadata -- Stores parsed arguments from Vensim'sGET DIRECT DATA/CONSTANTS/LOOKUPS/SUBSCRIPTfunctions for roundtrip fidelity.
Current behavior
XMILE serialization (xmile/variables.rs, xmile/dimensions.rs) returns an explicit error when encountering any of these constructs, preventing silent data loss.
XMILE schema limitations and potential extension points
The XMILE specification (v1.0) has limited native support for these constructs:
EXCEPT equations
XMILE's <eqn> element within <element> tags under an arrayed variable can represent per-element equations, but there is no standard mechanism for a "default equation with exceptions" pattern. Potential approaches:
- Use a non-subscripted
<eqn>as the default and<element>entries as overrides (closest to XMILE semantics, but may conflict with existing implementations) - Use a vendor-specific extension attribute (e.g.,
isee:default_eqn) on the variable element
Element-level dimension mappings
XMILE's <dimensions> section supports <dim> elements with <elem> children, but dimension mappings between families are not part of the core spec. Potential approaches:
- Extend
<dim>with a mapping child element (vendor extension) - Use Simlin-specific metadata within the model's
<options>or a custom namespace
DataSource metadata
XMILE has no concept equivalent to Vensim's GET DIRECT functions, since it uses inline data. Potential approaches:
- Store as vendor-specific metadata on the variable (e.g.,
simlin:data_source) - Inline the resolved data and store the original source reference as metadata for roundtrip purposes
Acceptance criteria
- XMILE serialization roundtrips all three constructs without error (likely via vendor extensions)
- Existing XMILE files without these constructs continue to parse correctly
- The explicit error paths in
xmile/variables.rsandxmile/dimensions.rsare replaced with proper serialization logic - Extension approach is documented so other tools can interoperate
Activity