-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtransform-scheduled-stop-point-ids.xsl
47 lines (37 loc) · 1.53 KB
/
transform-scheduled-stop-point-ids.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?xml version="1.0" encoding="UTF-8"?>
<!--
SPDX-FileCopyrightText: NOI Techpark <[email protected]>
SPDX-License-Identifier: CC0-1.0
-->
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:n="http://www.netex.org.uk/netex"
xsi:schemaLocation="http://www.netex.org.uk/netex https://raw.githubusercontent.com/NeTEx-CEN/NeTEx/master/xsd/NeTEx_publication.xsd"
exclude-result-prefixes="n" >
<!-- Identity template to copy every node and attribute by default -->
<xsl:mode on-no-match="shallow-copy"/>
<!--
Transform the IDs of ScheduledStopPoints from this format
it:apb:ScheduledStopPoint:it-22101-7010-51-32073:
to this
it:22101:7010:51:32073
.
This is because the SIRI feeds use the latter format, and we need to match up the two sources.
-->
<xsl:template match="//n:ScheduledStopPoint/@id">
<xsl:attribute name="id">
<xsl:value-of select="replace(replace(., '.*ScheduledStopPoint:(.+?):$', '$1'), '-', ':')"/>
</xsl:attribute>
</xsl:template>
<xsl:template match="//n:RoutePointRef/@ref">
<xsl:attribute name="ref">
<xsl:value-of select="replace(replace(., '.*ScheduledStopPoint:(.+?):$', '$1'), '-', ':')"/>
</xsl:attribute>
</xsl:template>
<xsl:template match="//n:ScheduledStopPointRef/@ref">
<xsl:attribute name="ref">
<xsl:value-of select="replace(replace(., '.*ScheduledStopPoint:(.+?):$', '$1'), '-', ':')"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>