<?xml version="1.0" encoding="UTF-8"?>
<!-- XSLT Filter um Lokdaten aus iTrain in Calc zu importieren -->
<!-- Status: ok -->
<!-- Hinweise und Fehler an tuxator@tuxator.de -->

<!-- ############################################################################################### -->
<!--              Struktur des feedback-Knotens der iTrain-XML-Datei                               -->
<!-- ############################################################################################### -->
<!-- <feedbacks count="61"> -->
<!--  <feedback name="GBM SB Gleis 6B2" type="occupancy" selected="false"> -->
<!--    <description>GBM SB Gleis 6B</description> -->
<!--    <length unit="cm">51.0</length> -->
<!--    <interface name="TAMS MC" address="1"/> -->
<!--    <delay off="1000" unit="ms"/> -->
<!--    <options/> -->
<!--  </feedback> -->
<!-- </feedbacks> -->
<!-- ############################################################################################### -->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:tra="http://www.berros.eu/xml/train" exclude-result-prefixes="tra">
	<xsl:decimal-format name="westeuropa" decimal-separator=',' grouping-separator='.' />
    <xsl:template match="/">
		<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.0">
		  
		<office:automatic-styles>

			<!-- Formate für Spalten -->
			<!-- Name -->
			<style:style style:name="co1" style:family="table-column">
				<style:table-column-properties fo:break-before="auto" style:column-width="18.0mm"/>
			</style:style>
			<!-- Typ -->
			<style:style style:name="co2" style:family="table-column">
				<style:table-column-properties fo:break-before="auto" style:column-width="32.0mm"/>
			</style:style>
			<!-- selected -->
			<style:style style:name="co3" style:family="table-column">
				<style:table-column-properties fo:break-before="auto" style:column-width="18.0mm"/>
			</style:style>
			<!-- Beschreibung -->
			<style:style style:name="co4" style:family="table-column">
				<style:table-column-properties fo:break-before="auto" style:column-width="108.0mm"/>
			</style:style>
			<!-- Länge -->
			<style:style style:name="co5" style:family="table-column">
				<style:table-column-properties fo:break-before="auto" style:column-width="18.0mm"/>
			</style:style>
			<!-- Adresse -->
			<style:style style:name="co6" style:family="table-column">
				<style:table-column-properties fo:break-before="auto" style:column-width="18.0mm"/>
			</style:style>
			<!-- Delay on -->
			<style:style style:name="co7" style:family="table-column">
				<style:table-column-properties fo:break-before="auto" style:column-width="18.0mm"/>
			</style:style>
			<!-- Delay off -->
			<style:style style:name="co8" style:family="table-column">
				<style:table-column-properties fo:break-before="auto" style:column-width="18.0mm"/>
			</style:style>
			<!-- Options -->
			<style:style style:name="co9" style:family="table-column">
				<style:table-column-properties fo:break-before="auto" style:column-width="21.5mm"/>
			</style:style>
			<!-- Kommentar -->
			<style:style style:name="co10" style:family="table-column">
				<style:table-column-properties fo:break-before="auto" style:column-width="108.0mm"/>
			</style:style>

			<!-- Formate für Zellen -->
			<!-- ce1 linksbündig, 1pt Umrandung -->
			<style:style style:name="ce1" style:family="table-cell" style:parent-style-name="Default">
				<style:table-cell-properties fo:border="1pt solid #000000" style:text-align-source="fix" style:repeat-content="false"/>
				<style:paragraph-properties fo:text-align="start"/>
			</style:style>
			<!-- ce2 rechtsbündig, 1pt Umrandung -->
			<style:style style:name="ce2" style:family="table-cell" style:parent-style-name="Default">
				<style:table-cell-properties fo:border="1pt solid #000000" style:text-align-source="fix" style:repeat-content="false"/>
				<style:paragraph-properties fo:text-align="end"/>
			</style:style>
			<!-- ce3 mittig, Fett, 1pt Umrandung,  Hintergrundfarbe -->
			<style:style style:name="ce3" style:family="table-cell" style:parent-style-name="Default">
				<style:table-cell-properties fo:border="1pt solid #000000" fo:background-color="#009185" style:vertical-align="middle"/>
				<style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
				<style:paragraph-properties fo:text-align="center"/>
			</style:style>

		</office:automatic-styles>
		<!-- Aufbau Tabelle -->
		<office:body>
			<office:spreadsheet>
				<table:table>

				<!-- 10 Spalten für Rückmelder formatieren -->
				<table:table-column table:style-name="co1" table:default-cell-style-name="Default"/> <!-- Name -->
				<table:table-column table:style-name="co2" table:default-cell-style-name="Default"/> <!-- Typ -->
				<table:table-column table:style-name="co3" table:default-cell-style-name="Default"/> <!-- Selected -->
				<table:table-column table:style-name="co4" table:default-cell-style-name="Default"/> <!-- Beschreibung -->
				<table:table-column table:style-name="co5" table:default-cell-style-name="Default"/> <!-- Länge -->
				<table:table-column table:style-name="co6" table:default-cell-style-name="Default"/> <!-- Adresse -->
				<table:table-column table:style-name="co7" table:default-cell-style-name="Default"/> <!-- Delay on -->
				<table:table-column table:style-name="co8" table:default-cell-style-name="Default"/> <!-- Delay off -->
				<table:table-column table:style-name="co9" table:default-cell-style-name="Default"/> <!-- Options -->
				<table:table-column table:style-name="co10" table:default-cell-style-name="Default"/> <!-- Kommentar -->
				
				<!-- Überschriften -->
				<!-- 1.Zeile -->
				<table:table-row>
					<table:table-cell table:style-name="ce3" table:number-rows-spanned="3"><text:p>Name</text:p></table:table-cell>
					<table:table-cell table:style-name="ce3" table:number-rows-spanned="3"><text:p>Typ</text:p></table:table-cell>
					<table:table-cell table:style-name="ce3" table:number-rows-spanned="3"><text:p>Selected</text:p></table:table-cell>
					<table:table-cell table:style-name="ce3" table:number-rows-spanned="3"><text:p>Beschreibung</text:p></table:table-cell>
					<table:table-cell table:style-name="ce3" table:number-rows-spanned="3"><text:p>Länge</text:p></table:table-cell>
					<table:table-cell table:style-name="ce3" table:number-rows-spanned="3"><text:p>Adresse</text:p></table:table-cell>
					<table:table-cell table:style-name="ce3" table:number-columns-spanned="2" table:number-rows-spanned="2"><text:p>Delay</text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3" table:number-rows-spanned="3"><text:p>Optionen</text:p></table:table-cell>
					<table:table-cell table:style-name="ce3" table:number-rows-spanned="3"><text:p>Kommentar</text:p></table:table-cell>
				</table:table-row>
				<!-- 2.Zeile -->
				<table:table-row>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
				</table:table-row>
				<!-- 3.Zeile -->
				<table:table-row>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p>on</text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p>off</text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
					<table:table-cell table:style-name="ce3"><text:p></text:p></table:table-cell>
				</table:table-row>
				
				<!-- alle Rückmelder-Daten -->
				<xsl:for-each select="/tra:train-control/tra:control-items/tra:feedbacks/tra:feedback">
					<table:table-row>
						<!-- Name -->
						<table:table-cell table:style-name="ce1"><text:p><xsl:value-of select="./@name"/></text:p></table:table-cell>
						<!-- Typ -->
						<table:table-cell table:style-name="ce1">
							<xsl:if test="./@type = 'occupancy'">
								<text:p>Belegtmelder</text:p>
							</xsl:if>
							<xsl:if test="./@type = 'reed'">
								<text:p>Readkontakt</text:p>
							</xsl:if>
							<xsl:if test="./@type = 'light_barrier'">
								<text:p>Lichtschranke</text:p>
							</xsl:if>
							<xsl:if test="./@type = 'button'">
								<text:p>Taste</text:p>
							</xsl:if>
							<xsl:if test="./@type = 'Value'">
								<text:p>Wert</text:p>
							</xsl:if>
							<xsl:if test="./@type = ''">
								<text:p>Sonstige</text:p>
							</xsl:if>
						</table:table-cell>
						<!-- selected -->
						<table:table-cell table:style-name="ce1"><text:p><xsl:value-of select="./@selected"/></text:p></table:table-cell>
						<!-- Beschreibung -->
						<table:table-cell table:style-name="ce1"><text:p><xsl:value-of select="tra:description"/></text:p></table:table-cell>
						<!-- Länge -->
						<table:table-cell table:style-name="ce2">
							<xsl:if test="tra:length">
								<text:p><xsl:value-of select="format-number(tra:length, '##00.0##', 'westeuropa')"/></text:p>
							</xsl:if>
						</table:table-cell>
						<!-- Adresse -->
						<table:table-cell table:style-name="ce2"><text:p><xsl:value-of select="tra:interface/@address"/></text:p></table:table-cell>
						<!-- Delay on -->
						<table:table-cell table:style-name="ce2">
							<xsl:if test="tra:delay/@on">
								<text:p><xsl:value-of select="number(tra:delay/@on)"/></text:p>
							</xsl:if>
						</table:table-cell>
						<!-- Delay off -->
						<table:table-cell table:style-name="ce2">
							<xsl:if test="tra:delay/@off">
								<text:p><xsl:value-of select="number(tra:delay/@off)"/></text:p>
							</xsl:if>
						</table:table-cell>
						<!-- Optionen -->
						<table:table-cell table:style-name="ce1">
							<xsl:if test="tra:options/tra:option = 'inverted'">
								<text:p>invertiert</text:p>
							</xsl:if>
						</table:table-cell>
						<!-- Kommentar -->
						<table:table-cell table:style-name="ce1"><text:p><xsl:value-of select="tra:comment"/></text:p></table:table-cell>
					</table:table-row>
				</xsl:for-each>
				</table:table>
			</office:spreadsheet>
		</office:body>
		</office:document-content>
	</xsl:template>
</xsl:stylesheet>
