Template:Constraint: Difference between revisions

From railML 2 Wiki
Jump to navigation Jump to search
[checked revision][checked revision]
No edit summary
No edit summary
Line 1: Line 1:
<includeonly>{{attr|{{{1}}}}}: {{#switch:{{{2}}}
<includeonly><noinclude>
 
Collecting defaults:
</noinclude>{{#if:{{{default|}}}|{{defaults|Element=[[{{PAGENAME}}}}|Attribute={{{1}}}|Value={{{default}}}}}}}<noinclude>
 
Core:
</noinclude>{{attr|{{{1}}}}}: {{#switch:{{{2}}}
|xs
|xs
|xsd={{xsdType|{{{3}}}}}|rml={{{3}}} ({{railMLType|{{{3}}}}})|#default=FIXME}}{{#if:{{{default|}}}|<nowiki>; </nowiki>{{default|{{{default}}}}}}}; {{{4|optional}}}</includeonly><noinclude>
|xsd={{xsdType|{{{3}}}}}|rml={{{3}}} ({{railMLType|{{{3}}}}})|#default=FIXME}}{{#if:{{{default|}}}|<nowiki>; </nowiki>{{default|{{{default}}}}}}}; {{{4|optional}}}</includeonly><noinclude>

Revision as of 15:40, 27 June 2022

Usage

This template standardizes the declaration of constraints. It became necessary to process the default values.

Parameters

The template has 4 unnamed Parameters and a named one:

  1. The attribute name to which the constraint applies
  2. xsd for standard types like string and boolean resp. rml for generic railML® types like tGenericRef
  3. the type, e.g. string or tGenericRef
  4. is the attribute optional (default) or required?
  • default: the default vaue (optional), e.g. TRUE

Examples

*{{constraint|vehicleRef|rml|tGenericRef|mandatory}}

delivers

  • {{#if:|{{defaults|Element=[[Constraint}}|Attribute=vehicleRef|Value={{{default}}}}}}}vehicleRef: tGenericRef (xs:IDREF); mandatory
*{{constraint|vehicleCount|rml|tCounter|default=1}}

delivers

  • {{#if:1|{{defaults|Element=[[Constraint}}|Attribute=vehicleCount|Value=1}}}}vehicleCount: tCounter (xs:nonNegativeInteger); default: 1; optional
*{{constraint|frontGangway|xsd|boolean}}

delivers

  • {{#if:|{{defaults|Element=[[Constraint}}|Attribute=frontGangway|Value={{{default}}}}}}}frontGangway: xs:boolean; optional