How to mix switches and crossings en connections ? [message #1360] |
Tue, 07 June 2016 09:31 |
prenaud
Messages: 3 Registered: June 2016
|
Junior Member |
|
|
Hello,
We use the RailML 2.1 format in our company to describe the track plan for our customers.
As I'm a newbie with the RailML format, I have a question concerning the tag <connections> in the <trackTopology> description.
This tag is defined in the file infrastructure.xsd as a choice between elements of type <switch> and elements of type <crossing> :
<xs:complexType name="eConnections">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="switch" type="rail:eSwitch" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="crossing" type="rail:eCrossing" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:complexType>
But, on the tracks I have switches AND crossings ...
Of course, when I have the two types of elements <switch> AND <crossing> in the same <connections> tag for one track, the validation tools report an error :
Quote:element crossing: Schemas validity error : Element 'crossing': This element is not expected. Expected is one of ( switch, crossing_additional_infos
How can I describe both the switches and the crossings for one track ?
Thanks for your help.
Patrick RENAUD
ALSTOM Transport France
|
|
|
Re: How to mix switches and crossings en connections ? [message #1361 is a reply to message #1360] |
Wed, 15 June 2016 08:01 |
christian.rahmig
Messages: 465 Registered: January 2016
|
Senior Member |
|
|
Dear Patrick,
thank you for your post and welcome to the railML infrastructure forum
community.
Am 11.06.2016 um 11:57 schrieb Patrick Renaud:
> [...]
>
> <xs:complexType name="eConnections">
> <xs:choice minOccurs="0" maxOccurs="unbounded">
> <xs:element name="switch" type="rail:eSwitch"
> minOccurs="0" maxOccurs="unbounded"/>
> <xs:element name="crossing" type="rail:eCrossing"
> minOccurs="0" maxOccurs="unbounded"/>
> </xs:choice>
> </xs:complexType>
>
> [...]
>
> How can I describe both the switches and the crossings for
> one track ?
There should be no problem in modelling both switches and crossings in
the same <trackTopology><connections> element.
As you can see from the schema, it is modelled as 'choice' that may
occur several times. So, you have the choice between <switch> and
<crossing> as many times as you want.
I validated this with the following code example code snippet:
<connections>
<switch id="s85" pos="518.102673">
<connection id="c64" course="left" ref="c65" orientation="outgoing"/>
</switch>
<crossing id="cr0909" pos="23.45">
<connection orientation="incoming" ref="c65" id="c99"/>
</crossing>
</connections>
Please let me know if your problem remains.
Best regards
Christian
--
Christian Rahmig
railML.infrastructure coordinator
Christian Rahmig – Infrastructure scheme coordinator
railML.org (Registry of Associations: VR 5750)
Altplauen 19h; 01187 Dresden; Germany www.railML.org
|
|
|
|
Re: How to mix switches and crossings en connections ? [message #1365 is a reply to message #1364] |
Fri, 17 June 2016 10:40 |
christian.rahmig
Messages: 465 Registered: January 2016
|
Senior Member |
|
|
Dear Patrick,
Am 17.06.2016 um 10:04 schrieb Patrick Renaud:
> [...]
>
> These three definitions are coherent and indicate that a
> <xs:choice> element cannot contains both the sub-elements it
> defines.
>
> In other words, in the RailML, a <connections> element
> cannot contains both <switch> AND <crossing> elements.
>
> Your code snippet is not valid with the validation tool
> xmllint which is based on the library LibXML 2.7.7
Your first sentence is correct. A <xs:choice> element can only contain
one sub element. However, you forgot the <xs:choice> element's optional
parameters minOccurs and maxOccurs. In [1] you can read their definition:
* minOccurs: Optional. Specifies the minimum number of times the
choice element can occur in the parent element. The value can be any
number >= 0. Default value is 1
* maxOccurs: Optional. Specifies the maximum number of times the
choice element can occur in the parent element. The value can be any
number >= 0, or if you want to set no limit on the maximum number, use
the value "unbounded". Default value is 1
In the case of the railML switch/crossing modelling, we used these
parameters to define that the <xs:choice> element may occur 0 to
unbounded times:
<xs:choice minOccurs="0" maxOccurs="unbounded">
Therefore, a <connections> element may contain an arbitrary number of
<switch> and <crossing> elements. All tools and their included XML
validators that we are working with (XMLSpy, oXygen, eclipse) confirm
that approach.
Did anybody else of the forum readers experience similar problems like
this? Any feedback appreciated...
[1] http://www.w3schools.com/xml/el_choice.asp
Best regards
--
Christian Rahmig
railML.infrastructure coordinator
Christian Rahmig – Infrastructure scheme coordinator
railML.org (Registry of Associations: VR 5750)
Altplauen 19h; 01187 Dresden; Germany www.railML.org
|
|
|
|