View stylesheet

XML schemas http://rod.eionet.europa.eu/obligations/137?V200807
Output type XML
Depends on
Description Converts Excel to XML
XSL file aqq_content.xslt (Last modified: 27 Oct 2009 15:18 )
<?xml version="1.0" encoding="ISO-8859-1"?>
<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">
	
	<xsl:output method="xml" indent="yes"/>

	<xsl:template match="/">
<!--		<xsl:text disable-output-escaping="yes">&lt;?xml-stylesheet type="text/xsl" href="FORM26.xslt"?&gt;</xsl:text>-->
		<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:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation: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" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:rdfa="http://docs.oasis-open.org/opendocument/meta/rdfa#" office:version="1.2">
			<office:body>
				<office:spreadsheet>
					<xsl:for-each select="//table:table">
						<xsl:variable name="TableName">
							<xsl:value-of select="@table:name"/>
						</xsl:variable>
						<table:table>
							<xsl:attribute name="table:name">
								<xsl:value-of select="$TableName"/>
							</xsl:attribute>
							<xsl:for-each select="table:table-row">
								<xsl:variable name="TableRow">
									<xsl:value-of select="position()"/>
								</xsl:variable>
								<table:table-row>
									<xsl:for-each select="table:table-cell[position() &lt; last()]">
										<xsl:variable name="TableCell">
											<xsl:value-of select="position()"/>
										</xsl:variable>
										<xsl:choose>
											<xsl:when test="@table:number-columns-repeated">
												<xsl:call-template name="ColumnsRepeatedOFF">
													<xsl:with-param name="Times" select="@table:number-columns-repeated"/>
													<xsl:with-param name="TableName" select="$TableName"/>
													<xsl:with-param name="TableRow" select="$TableRow"/>
													<xsl:with-param name="TableCell" select="$TableCell"/>
												</xsl:call-template>
											</xsl:when>
											<xsl:otherwise>
												<xsl:call-template name="ColumnsRepeatedOFF">
													<xsl:with-param name="Times" select="1"/>
													<xsl:with-param name="TableName" select="$TableName"/>
													<xsl:with-param name="TableRow" select="$TableRow"/>
													<xsl:with-param name="TableCell" select="$TableCell"/>
												</xsl:call-template>
											</xsl:otherwise>
										</xsl:choose>
									</xsl:for-each>
								</table:table-row>
							</xsl:for-each>
						</table:table>
					</xsl:for-each>
				</office:spreadsheet>
			</office:body>
		</office:document-content>
	</xsl:template>
	
	<xsl:template name="ColumnsRepeatedOFF">
		<xsl:param name="Times" select="1"/>
		<xsl:param name="TableName"/>
		<xsl:param name="TableRow"/>
		<xsl:param name="TableCell"/>
		<xsl:if test="$Times &gt; 0">
			<table:table-cell>
				<xsl:if test="text:p">
					<xsl:choose>
						<xsl:when test="$TableName = '2' and $TableRow = '5' and $TableCell &gt; '1'">
								<xsl:call-template name="SplitCell">
									<xsl:with-param name="String" select="text:p"/>
								</xsl:call-template>
						</xsl:when>
						<xsl:otherwise>
							<text:p>
								<xsl:value-of select="text:p"/>
							</text:p>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:if>
			</table:table-cell>
			<xsl:call-template name="ColumnsRepeatedOFF">
				<xsl:with-param name="Times" select="$Times - 1"/>
				<xsl:with-param name="TableName" select="$TableName"/>
				<xsl:with-param name="TableRow" select="$TableRow"/>
				<xsl:with-param name="TableCell" select="$TableCell"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>

	<xsl:template name="ReplaceSeparators">
		<xsl:param name="String"/>
		<xsl:param name="Separator"/>
		<xsl:choose>
			<xsl:when test="contains($String, $Separator)">
				<xsl:value-of select="substring-before($String, $Separator)"/>
				<xsl:value-of select="' '"/>
				<xsl:call-template name="ReplaceSeparators">
					<xsl:with-param name="String" select="substring-after($String, $Separator)"/>
					<xsl:with-param name="Separator" select="$Separator"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$String"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="SplitString">
		<xsl:param name="String"/>
		<xsl:param name="Separator"/>
		<xsl:choose>
			<xsl:when test="contains($String, $Separator)">
				<text:p><xsl:value-of select="substring-before($String, $Separator)"/></text:p>
				<xsl:call-template name="SplitString">
					<xsl:with-param name="String" select="substring-after($String, $Separator)"/>
					<xsl:with-param name="Separator" select="$Separator"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<text:p>
					<xsl:value-of select="$String"/>
				</text:p>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="SplitCell">
		<xsl:param name="String"/>
		<xsl:variable name="String1">
			<xsl:call-template name="ReplaceSeparators">
				<xsl:with-param name="String" select="$String"/>
				<xsl:with-param name="Separator" select="';'"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="String2">
			<xsl:call-template name="ReplaceSeparators">
				<xsl:with-param name="String" select="$String1"/>
				<xsl:with-param name="Separator" select="','"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="NiceString">
			<xsl:value-of select="normalize-space($String2)"/>
		</xsl:variable>
		<xsl:call-template name="SplitString">
			<xsl:with-param name="String" select="$NiceString"/>
			<xsl:with-param name="Separator" select="' '"/>
		</xsl:call-template>
	</xsl:template>

</xsl:stylesheet>