Dev:identities: Difference between revisions
[checked revision] | [checked revision] |
(→Recommendation: Usage of _ after intense discussion added) |
m (→Recommendation: Added _ to the example) |
||
Line 36: | Line 36: | ||
or [https://en.wikipedia.org/wiki/Universally_unique_identifier UUID]'s, e.g. | or [https://en.wikipedia.org/wiki/Universally_unique_identifier UUID]'s, e.g. | ||
<pre><formation id=" | <pre><formation id="_f36014b1-055d-4171-91a4-2a32a3210f28" name="TGV-ICE3">...</pre>''Please note: a [https://en.wikipedia.org/wiki/Universally_unique_identifier#Nil_UUID Nil UUID] shall not be used; [https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random) UUID's Version 4] is commonly used. Due to the limitations of the ID type by www.w3.org in {{rml}} 2 the ID shall begin with a letter. Since this is not the case for all UUIDs, some tools are adding the prefix "_" before the UUID to fufil the constraints.'' | ||
=== Bad style === | === Bad style === |
Revision as of 14:31, 13 December 2019
railML® Identities
Very many railML® elements require an id attribute of the W3C-Type xs:ID.
This has to be provided in order to enable references, that are very much used within the railML® schemas.
On the other hand, software tools may refer to certain railML® elements, that are not referred to within the railML® file.
Semantics
The general railML® description states the following semantics for this attribute.
- id: XML-file-wide unique, machine-interpretable identity, required for later referencing that element internally. For a detailed explanation see Dev:identities.
XML-Datei-weit eindeutige, maschineninterpretierbare Identität, die für die spätere interne Referenzierung dieses Elements erforderlich ist. Für eine detaillierte Erklärung siehe Dev:identities.
Constraints
The general railML® description states the following contraints.
- id: xs:ID, required
a string, starting with a letter (a..zA..Z) or an underscore (_),
followed by a non-colonized and non-spaced string consisting of letters, digits, points (.), dashes (-) or underscores (_)
Export of railML® files
Software tools, which create railML® files, are free to define id values according to the above mentioned constraints.
Recommendation
railML® recommends using generic values, e.g.
<formation id="d2e717" name="TGV-ICE3">...
or serial numbers with letter prefixes, e.g.
<formation id="rsf0002" name="TGV-ICE3">...
or UUID's, e.g.
<formation id="_f36014b1-055d-4171-91a4-2a32a3210f28" name="TGV-ICE3">...
Please note: a Nil UUID shall not be used; UUID's Version 4 is commonly used. Due to the limitations of the ID type by www.w3.org in railML® 2 the ID shall begin with a letter. Since this is not the case for all UUIDs, some tools are adding the prefix "_" before the UUID to fufil the constraints.
Bad style
Sometimes exporting software tools create id values, that contain semantic data, like train numbers or vehicle family codes.
<formation id="fTGV-ICE3" name="TGV-ICE3">...
Please use some more generic coding style in order to not invite the importing software to parse the id values!
Wrong style
|
Please use a generic coding style for the id value. Look for appropriate railML® attributes in the element and put the semantics there. Otherwise use the xs:anyAttribute mechanism.
The use of this Wrong style prevents certification of the export interface.
Import of railML® files
Recommendation
Software tools, which consume railML® files, should take the id values only for referencing issues.
In case of valid railML® files, no problems will occur.
Good style
In case of consuming "good or bad styled" id values the importing software provides routines for getting the semantics from better fitting attributes.
In case of consuming "wrong styled" id values the importing software is required to parse the attribute content for getting the semantics.
That way, the most robust import interface is assured.
Wrong style
|
The use of this Wrong style prevents certification of the import interface.
Differentiation from other indications
Many elements that come with an attribute id will also have the attributes code, name description.
- code: Like id it is machine readable, but a code is designed for interoperability. An id is valid within a single file. A code can be valid e.g. within a network and has to be unique within the network.
- name: A short, human readable Identifier. Uniqueness is not required.
- description: Human readable text that gives details. Uniqueness is not required.
|