Home » railML newsgroups » railML.infrastructure » How to mix switches and crossings en connections ?
How to mix switches and crossings en connections ? [message #1360] Tue, 07 June 2016 09:31 Go to next message
prenaud is currently offline  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 Go to previous messageGo to next message
christian.rahmig is currently offline  christian.rahmig
Messages: 436
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 #1364 is a reply to message #1361] Fri, 17 June 2016 10:04 Go to previous messageGo to next message
prenaud is currently offline  prenaud
Messages: 3
Registered: June 2016
Junior Member
Hello Christian,

I have checked the definition of the <xs:choice> element on different reference sites.

On the web site of W3C https://www.w3.org/TR/xmlschema11-1/ chapter 3.8.1 the definition is:

Quote:

(sequence) correspond, in order, to the specified {particles};
(choice) correspond to exactly one of the specified {particles};
(all) correspond to the specified {particles}. The elements can occur in any order.


On Microsoft MSDN https://msdn.microsoft.com/en-us/library/ms256109%28v=vs.110 %29.aspx the definition is:

Quote:
Allows one and only one of the elements contained in the selected group to be present within the containing element.


On the site W3Schools.com http://www.w3schools.com/xml/el_choice.asp :

Quote:
XML Schema choice element allows only one of the elements contained in the <choice> declaration to be present within the containing element.


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

Best regards,

Patrick
Re: How to mix switches and crossings en connections ? [message #1365 is a reply to message #1364] Fri, 17 June 2016 10:40 Go to previous messageGo to next message
christian.rahmig is currently offline  christian.rahmig
Messages: 436
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
Re: How to mix switches and crossings en connections ? [message #1368 is a reply to message #1365] Tue, 21 June 2016 15:00 Go to previous message
prenaud is currently offline  prenaud
Messages: 3
Registered: June 2016
Junior Member
The version 2.9.3 of the LibXML library indeed reports no error on the <connections> tag containing <switch> and <crossing> elements ...

Sorry to have annoying you for a problem of validation tool version.

Best regards,

Patrick
Previous Topic: Connection on TrackBegin and TrackEnd
Next Topic: Vertical track geometry
Goto Forum:
  


Current Time: Thu Mar 28 16:11:51 CET 2024