XML Schema Definitions (XSDs) offer a variety of possibilities to define syntactic constraints, describing the syntax of an XML file, including the type and multiplicity of an element. For example in railML® 2, it is possible to describe and validate that a <train> must reference one or more <trainPart>s, that all <trackElements> must have a position on the <track>, that the length of a <tunnel> is a decimal number and that allowed positions of <couplers> are at the front, rear or both ends of a <wagon>. However, XML Schema Definitions are not able to express a constraint on one element or attribute that depends on the value or existence of another element or attribute. One example is that an XSD cannot express that a departure time must be greater than or equal to the arrival time, or that it does not make sense to specify a stopOnRequest and at the same time that the train is not allowed to stop. Such rules restricting the contents, or semantics, of one element or attribute depending on other content, are called semantic constraints.
Semantic constraints are as important as syntactic constraints. If they are ignored, other software may not be able to handle your railML® files, or may interpret the contents in different ways. Therefore, their implementation will be checked during certification.
Elements with approved semantic constraints are listed in Category:Semantic constraints. On the element documentation pages, the semantic constraints can be found in a dedicated chapter below the syntactic constraints. Proposed semantic constraints are listed in Category:Semantic constraints_proposed. A list of the semantic constraints by introduction date of a can be found below.
Every application of railML® has to be checked not only on XSD compliance but also on the obedience to the semantic constraints.
How to introduce Semantic Constraints
Constraints that can be described by XML Schema Definitions (XSDs) should be implemented syntactically in the schemas. Please, follow the guideline for participating in the development process. If a constraint cannot be described by XML Schema Definitions, you can propose a semantic constraints.
If there is consensus in a working group to add a new semantic constraint, a post will be made in the forum and the proposed constraint will be added to the element documentation using Template:Semcon, with
status=proposed and added to the list below. If there are no objections in the forum, it will be approved after six weeks and implemented in the wiki with
If you see the need for a semantic constraint beyond the schema, please discuss it in the forum (link to the railML® website) and then add a proposal in the element documentation using Template:Semcon, with
status=proposed. Please also add the proposal to the list below! If a consensus is reached in the forum, the proposal will be accepted, it will implemented in the wiki with
- Implement a seperate semantic constraint for every rule.
- Use the template with all mandatory arguments according to Template:SemanticConstraint.
- Record the semantic constraint on the respective list below (Dev:Semantic_Constraints/table2 for railML® 2 and Dev:Semantic_Constraints/table3 for railML® 3).
- assign a serial id to the semantic constraint according to the appropriate list below.
Current Constraints as of railML® 3.2
|Element||ID||Proposal date||Date of acception||Date of deprecation||Description|
|<TT:operationalTrainSectionPart>||TT:001||2022-09-15||2022-10-13||There is always only a single successor and predecessor for an <operationalTrainSectionPart> in the chain of <operationalTrainSectionPart>s that are linked via the attribute @next.|
|<TT:operationalTrainVariant>||TT:002||2023-01-12||2023-04-06||When calculating which <operationalTrainVariant> of an <operationalTrain> is valid on a particular day always a maximum of one active <operationalTrainVariant> shall be the result. If the result is more than one <operationalTrainVariant>, all except one shall be marked as <isCancelled> or <isOnRequest>.|
|<TT:commercialTrainVariant>||TT:003||2023-01-12||2023-04-06||When calculating which <commercialTrainVariant> of an <commercialTrain> is valid on a particular day always a maximum of one active <commercialTrainVariant> shall be the result. If the result is more than one <commercialTrainVariant>, all except one shall be marked as <isCancelled> or <isOnRequest>.|
|<TT:operationalTrainSection>||TT:004||2022-01-12||2023-03-09||The itinerary sections of an <operationalTrainVariant>, defined by the <operationalTrainSection>s and their respective <range>s, that are not <isCancelled> and not marked as <isOnRequest>, must be pairwise disjoint, except for their respective first and last <baseItineraryPoint>s.|
|<TT:operationalTrainSection>||TT:005||2022-01-12||2023-03-09||The first(last) <baseItineraryPoint> of each <operationalTrainSection> within an <operationalTrainVariant> must either be the referenced <itinerary>'s first(last) <baseItineraryPoint>, or coincide with another section's last(first) <baseItineraryPoint>.|
|<TT:commercialTrainSection>||TT:006||2022-01-12||2023-03-09||The itinerary sections of an <commercialTrainVariant>, defined by the <commercialTrainSection>s and their respective <range>s, that are not <isCancelled> and not marked as <isOnRequest>, must be pairwise disjoint, except for their respective first and last <baseItineraryPoint>s.|
|<TT:commercialTrainSection>||TT:007||2022-01-12||2023-03-09||The first(last) <baseItineraryPoint> of each <commercialTrainSection> within an <commercialTrainVariant> must either be the referenced <itinerary>'s first(last) <baseItineraryPoint>, or coincide with another section's last(first) <baseItineraryPoint>.|