Opened 10 years ago

Last modified 5 years ago

#2687 new enhancement

Simulation templates: Allow XPath to reference another XML node's value.

Reported by: Radagast Owned by:
Priority: If Time Permits Milestone: Backlog
Component: Simulation Keywords:
Cc: Patch:

Description

It would be nice to allow XPath references in simulation templates to avoid redundancy and to lessen the manually edited information that is hard to maintain.

e.g. consider the following:

 <?xml version="1.0" encoding="utf-8"?>
 <Entity parent="template_unit_cavalry_ranged_archer">
   <Identity>
     <Civ>chin</Civ>
     <Classes datatype="tokens">Ranged Cavalry Horse Archer Crossbow</Classes>
     <SelectionGroupName>units/chin_cavalry_crossbowman_b</SelectionGroupName>
     <GenericName>Chinese Mounted Crossbowman</GenericName>
     <SpecificName>?</SpecificName>
     <Icon>units/chin_cavalry_crossbowman.png</Icon>
     <Tooltip>Classes: {/Entity/Identity/Classes}.
         First occurrence: {first_occurrence}.
         Zenith: {zenith} 
         Last occurrence: {last_occurrence}.</Tooltip>
   </Identity>
   <Promotion>
     <Entity>units/chin_cavalry_crossbowman_a</Entity>
   </Promotion>
   <VisualActor>
     <Actor>units/china/cavalry_crossbowman_b.xml</Actor>
   </VisualActor>
 </Entity>

It would require us to parse for that pattern {}, then check if it's an XPath {/*}. If it's an XPath then we resolve the value if possible and replace the placeholder with this value.

Alternatively we can use {Classes} or {VisibleClasses} and replace those as we do for {Civ}.

We needed an easy way to add such replacements dynamically in the templates then and the only solution without extra tagging I figured is to use the XPath which is already there anyway.

Change History (1)

comment:1 by Imarok, 5 years ago

Component: UI & SimulationSimulation

Move tickets to Simulation as UI & Simulation got some sub components.

Note: See TracTickets for help on using tickets.