View stylesheet

XML schemas http://dd.sdr.edw.ro/GetSchema?id=TBL7212
Output type ODS
Description OpenDocument
XSL file sdr-lakes-station-ods.xsl (Last modified: 13 Apr 2011 14:34 )
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:dd715="http://dd.sdr.edw.ro/namespace.jsp?ns_id=715" xmlns:dd716="http://dd.sdr.edw.ro/namespace.jsp?ns_id=716">
	<xsl:template match="dd715:StationsLakes">
		<office:document-content office:version="1.0" 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:automatic-styles>
				<style:style style:name="cell1" style:family="table-cell">
					<style:text-properties fo:text-align="left" fo:font-size="10pt"/>
				</style:style>
				<style:style style:name="cell2" style:family="table-cell">
					<style:text-properties fo:text-align="center" fo:font-size="12pt" fo:font-style="italic"/>
				</style:style>
				<style:style style:name="Heading1" style:family="table-cell">
					<style:text-properties fo:text-align="left" fo:font-size="10pt" fo:font-style="italic" style:text-align-source="fix" fo:font-weight="bold"/>
				</style:style>
				<style:style style:name="Heading2" style:family="table-cell">
					<style:text-properties fo:text-align="center" fo:font-size="10pt" fo:font-weight="bold"/>
				</style:style>
			</office:automatic-styles>
			<office:body>
				<office:spreadsheet>
					<table:table>
						<xsl:attribute name="table:name">StationsLakes</xsl:attribute>
						<xsl:attribute name="schema-url">http://dd.eionet.europa.eu/GetSchema?id=TBL4361</xsl:attribute>
						<xsl:attribute name="table-schema-urls">http://dd.eionet.europa.eu/GetSchema?id=TBL4361</xsl:attribute>
						<table:table-columns>
							<table:table-column table:default-cell-value-type="number" table:default-cell-style-name="cell1">
								<xsl:attribute name="table:number-columns-repeated">
									<xsl:value-of select="count(./dd715:Row[1]/*)"/>
								</xsl:attribute>
							</table:table-column>
						</table:table-columns><!-- create header rows -->
						<table:table-rows>
							<xsl:apply-templates select="dd715:Row"/>
						</table:table-rows>
					</table:table>
				</office:spreadsheet>
			</office:body>
		</office:document-content>
	</xsl:template>
	<xsl:template match="dd715:Row">
		<xsl:if test="position()=1">
			<xsl:call-template name="header"/>
		</xsl:if>
		<table:table-row>
			<xsl:for-each select="*">
				<xsl:if test="count(preceding-sibling::*[local-name() = local-name(current())])=0">
					<table:table-cell xmlns:table="http://openoffice.org/2000/table">
						<text:p xmlns:text="http://openoffice.org/2000/text">
							<xsl:call-template name="getValue"/>
						</text:p>
					</table:table-cell>
				</xsl:if>
			</xsl:for-each>
		</table:table-row>
	</xsl:template><!--   template for building table cells with values --><!--  a named template, which creates the table header row -->
	<xsl:template name="header">
		<table:table-header-rows><!--table:table-row   table:default-cell-value-type='string' table:default-cell-style-name='Heading1' >			<table:table-cell>				<text:p>Groundwater Body Characteristics and Pressures</text:p>			</table:table-cell>		</table:table-row-->
			<table:table-row table:default-cell-value-type="string" table:default-cell-style-name="Heading1">
				<xsl:for-each select="*">
					<xsl:if test="count(preceding-sibling::*[local-name() = local-name(current())])=0">
						<table:table-cell table:style-name="Heading2">
							<text:p>
								<xsl:value-of select="local-name()"/>
							</text:p>
						</table:table-cell>
					</xsl:if>
				</xsl:for-each>
			</table:table-row>
		</table:table-header-rows>
	</xsl:template>
	<xsl:template name="getValue">
		<xsl:choose>
			<xsl:when test="count(following-sibling::*[local-name() = local-name(current())])=0">
				<xsl:value-of select="."/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="joinMultiValue">
					<xsl:with-param name="valueList" select="parent::*/child::*[local-name() = local-name(current())]"/>
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="joinMultiValue">
		<xsl:param name="valueList" select="''"/>
		<xsl:variable name="separator">
			<xsl:call-template name="getSeparator">
				<xsl:with-param name="element" select="local-name()"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:for-each select="$valueList">
			<xsl:choose>
				<xsl:when test="position() = 1">
					<xsl:value-of select="."/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="concat($separator, .)"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="getSeparator">
		<xsl:param name="element" select="''"/>
		<xsl:value-of select="','"/>
	</xsl:template>
</xsl:stylesheet>