## build_structure_map_from_template_wb()


Build a complete StructureMap object by parsing a WB-format Excel template.


Usage

``` python
build_structure_map_from_template_wb(
    mappings,
    agency="SDMX",
    structure_map_id="WB_STRUCTURE_MAP",
    structure_type="datastructure",
    version="1.0",
    required_keys=("INFO", "COMP_MAPPING", "REP_MAPPING"),
    valid_rules=("representation", "multi_representation", "implicit"),
    valid_prefixes=("fixed:",),
    generate_urns=True,
    source_structure_id=None,
    target_structure_id=None
)
```


## Parameters


`mappings: dict[str, pd.DataFrame]`  
Dictionary of DataFrames containing all sheets.

`agency: str = ``"SDMX"`  
Fallback agency ID if not found in INFO.

`structure_map_id: str = ``"WB_STRUCTURE_MAP"`  
ID for the resulting StructureMap.

`structure_type: Literal[``"datastructure", `<span class="st">`"dataflow"``, ``"provisionagreement"``]`</span>` = ``"datastructure"`  
The type of artefact to extract from INFO.

`version: str = ``"1.0"`  
Fallback version if not found in INFO.

`required_keys: Iterable[str] = (``"INFO", `<span class="st">`"COMP_MAPPING"``, ``"REP_MAPPING"``)`</span>  
Required sheet names to validate.

`valid_rules: Iterable[str] = (``"representation", `<span class="st">`"multi_representation"``, ``"implicit"``)`</span>  
Valid literal mapping rules.

`valid_prefixes: Iterable[str] = (``"fixed:",)`  
Valid prefixes for parameterized mapping rules.

`generate_urns: bool = ``True`  
If True, automatically generate URNs for StructureMap and nested RepresentationMaps. Defaults to True.

`source_structure_id: str | None = None`  
Optional source structure reference in `"AGENCY:ID(VERSION)"` format (e.g. `"WB:DSD_ASPIRE(1.0)"`). When provided and `generate_urns` is True, a full SDMX URN is built and set as the StructureMap's `source`.

`target_structure_id: str | None = None`  
Optional target structure reference in `"AGENCY:ID(VERSION)"` format (e.g. `"WB:DSD_WDI(1.0)"`). When provided and `generate_urns` is True, a full SDMX URN is built and set as the StructureMap's `target`.


## Returns


`StructureMap`  
A valid pysdmx StructureMap object.


## Raises


`ValueError`  
If mandatory sheets/columns are missing or mapping rules are invalid.


## Examples


``` python
    >>> mappings = {
    ...     "INFO": pd.DataFrame({"Key": ["FMR_AGENCY"], "Value": ["TEST_AGENCY"]}),
    ...     "COMP_MAPPING": pd.DataFrame(
    ...         {
    ...             "SOURCE": ["src"],
    ...             "TARGET": ["tgt"],
    ...             "MAPPING_RULES": ["fixed:VAL"],
    ...         }
    ...     ),
    ...     "REP_MAPPING": pd.DataFrame({"source": ["a"], "target": ["b"]})
    ... }
    >>> smap = build_structure_map_from_template_wb(mappings)
    >>> isinstance(smap, StructureMap)
```

    True
