Dev:Syntactic Guidelines: Difference between revisions

From railML 2 Wiki
Jump to navigation Jump to search
[unchecked revision][checked revision]
(Content copied from Assemblas Wiki page "Code_Policy")
 
({{mirror}})
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Camel Case ==
{{mirror}}
 
== White spaces ==
 
=== Empty end-tags ===
 
<p>Implementation with 1 space before closing empty end-tags</p>
<p>example: <pre><xs:restriction base="xs:ID" /></pre></p>
 
=== Indents ===
 
<p>Implementation with 2 spaces</p>
<p>example:
<syntaxhighlight line lang="xml">
<xs:element name="railml">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="metadata" type="dc:elementContainer" minOccurs="0" />
      <xs:element ref="rail:infrastructure" minOccurs="0" />
</syntaxhighlight>
</p>
 
== Line Breaks ==
 
=== Each component declaration must be followed by a line break. ===
 
<p>example:
<syntaxhighlight line lang="xml">
<xs:attributeGroup name="aPlaces">
  <xs:attribute name="category" type="rail:tPlaceCategory" use="required" />
  <xs:attribute name="count" type="rail:tCounter" use="required" />
</syntaxhighlight>
</p>
 
=== There is no maximum line length ===
 
<p>Each component has to be fully declared on one line without line breaks.</p>
<p>example:
<pre><xs:schema xmlns:rail="http://www.railml.org/schemas/2009" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dc="http://purl.org/dc/elements/1.1/" targetNamespace="http://www.railml.org/schemas/2009" elementFormDefault="qualified" version="2.0"></pre>
</p>
 
== XML Default Values ==
 
=== Empty elements and attributes ===
 
<p>see also: [http://www.w3.org/TR/REC-xml/#NT-EmptyElemTag W3C XML Recommendation "Tags for Empty Elements"]</p>
<p>Implementation with shortened syntax instead of extra closing tag</p>
<p>example: <pre><xs:element ref="rail:infrastructure" minOccurs="0" /></pre></p>
 
== XML Schema Default Values ==
 
=== Optional and required attributes ===
 
<p>see also: [http://www.w3.org/TR/xmlschema-1/#declare-attribute W3C XML Schema Recommendation "XML Representation of Attribute Declaration Schema Components"]</p>
 
==== Implementation without <code>use="optional"</code> ====
 
<p>example: <pre><xs:attribute name="description" type="rail:tElementDescription" /></pre></p>
 
==== Implementation with <code>use="required"</code> ====
 
<p>example: <pre><xs:attribute name="id" type="rail:tGenericID" use="required" /></pre></p>
 
=== Elements with minimum 1 or maximum 1 occurrence ===
 
<p>see also: [http://www.w3.org/TR/xmlschema-1/#declare-element W3C XML Schema Recommendation "XML Representation of Element Declaration Schema Components"]</p>
 
==== Implementation without <code>minOccurs="1"</code> ====
 
<p>example: <pre><xs:element name="train" type="rail:eTrain" maxOccurs="unbounded" /></pre></p>
 
==== Implementation without <code>maxOccurs="1"</code> ====
 
<p>example: <pre><xs:element ref="rail:timetable" minOccurs="0" /></pre></p>
 
=== Occurence restrictions into elements ===
 
<p>If possible, all occurence restrictions have to go into element definitions.</p>
<p><code>xs:sequence</code> should stand without the attributes <code>minOccurs</code> and/or <code>maxOccurs</code>.</p>
<p>example:
<syntaxhighlight line lang="xml">
<xs:extension base="rail:tElementWithIDAndName">
  <xs:sequence>
    <xs:element name="metadata" type="dc:elementContainer" minOccurs="0" />
  </xs:sequence>
</syntaxhighlight>
</p>
 
== Pathes inside XML documents ==
 
=== Attribute <code>xsi:schemaLocation</code> ===
 
<p>see also: [http://www.w3.org/TR/xmlschema-1/#schema-loc W3C XML Schema Recommendation "How schema definitions are located on the Web"]</p>
 
==== Implementation with slashes, no backslashes permitted ====
 
<p>example:<pre><railml xmlns="http://www.railml.org/schemas/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.railml.org/schemas/2009 ../schema/railML.xsd"></pre>
</p>

Revision as of 21:34, 23 January 2020

🗒️ This page is mirrored from page Dev:Syntactic Guidelines in The railML® 3 wiki.

[Template fetch failed for https://wiki3.railml.org/index.php?title=Dev:Syntactic_Guidelines&action=raw: HTTP 404]