SuperX-Kernmodul
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

688 lines
29 KiB

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://jasperreports.sourceforge.net/jasperreports">
<xsl:param name="font" select="'Liberation Sans'" /><!--TODO {$font} als style-->
<xsl:template name="generateJasperReport">
<xsl:param name="isMainReport" select="'true'" />
<xsl:param name="ergebniselementOrdnr" select="0" />
<xsl:param name="druckbreite" select="812" />
<xsl:param name="seitenbreite" select="842" />
<xsl:param name="seitenhoehe" select="595" />
<xsl:param name="seitenrand" select="12" />
<xsl:param name="isIgnorePagination" select="'true'" />
<xsl:param name="orientation" select="'Landscape'" />
<xsl:param name="stylesFile" select="'simple_table.jrtx'" />
<xsl:param name="font" select="'Liberation Sans'" /><!--TODO Arial als style-->
<!--Die Breite der Tabelle in pixel bei A4 Querformat:-->
<!-- Wenn keine Spaltenbreite definiert ist, wird 12 (Einheit Applet-Breite) verwendet. -->
<xsl:param name="std_spaltenbreite" select="'12'" />
<xsl:param name="std_zeilenhoehe_header" select="30" />
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
name="{/ergebnisse/ergebnis[@ordnr=$ergebniselementOrdnr]/maskenname}"
language="groovy"
pageWidth="{$seitenbreite}"
pageHeight="{$seitenhoehe}"
orientation="{$orientation}"
columnWidth="{$druckbreite}"
leftMargin="{$seitenrand}"
rightMargin="{$seitenrand}"
topMargin="{$seitenrand}"
bottomMargin="{$seitenrand}"
isIgnorePagination="{$isIgnorePagination}" >
<xsl:call-template name="jr_properties" />
<property name="net.sf.jasperreports.export.xls.exclude.origin.band.1" value="pageHeader"/>
<property name="net.sf.jasperreports.export.xls.exclude.origin.band.2" value="pageFooter"/>
<property name="net.sf.jasperreports.export.xlsx.exclude.origin.band.1" value="pageHeader"/>
<property name="net.sf.jasperreports.export.xlsx.exclude.origin.band.2" value="pageFooter"/>
<!-- zum Testen-->
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="beispiel_einzeltabelle_schmal"/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
<property name="com.jaspersoft.studio.property.dataset.dialog.DatasetDialog.sash.w1" value="466"/>
<property name="com.jaspersoft.studio.property.dataset.dialog.DatasetDialog.sash.w2" value="522"/>
<template><xsl:value-of select="concat('&quot;',$stylesFile,'&quot;')" /></template>
<xsl:call-template name="jr_styles" />
<queryString language="xPath"><xsl:value-of select="concat('/ergebnisse/ergebnis/ergebniselement[@ordnr=',$ergebniselementOrdnr,']/sqlerg/row')" />
</queryString>
<xsl:if test="$isMainReport='true'">
<xsl:call-template name="jr_fields_report_level" />
</xsl:if>
<xsl:call-template name="jr_fields" >
<xsl:with-param name="ergebniselementOrdnr" select="$ergebniselementOrdnr"/>
<!--<xsl:with-param name="isMacroReport" select="$isMacroReport" />-->
</xsl:call-template>
<variable name="tabellennr" class="java.lang.Integer">
<variableExpression><xsl:value-of select="$ergebniselementOrdnr"/></variableExpression>
</variable>
<xsl:call-template name="generateGroupHeaderBandSimple">
<xsl:with-param name="std_zeilenhoehe_header" select="$std_zeilenhoehe_header" />
<xsl:with-param name="druckbreite" select="$druckbreite" />
<xsl:with-param name="std_spaltenbreite" select="$std_spaltenbreite" />
</xsl:call-template>
<xsl:if test="$isMainReport='true'">
<xsl:call-template name="generateTitleBand" >
<xsl:with-param name="druckbreite" select="$druckbreite" />
</xsl:call-template>
</xsl:if>
<detail>
<xsl:for-each select="/ergebnisse/ergebnis/ergebniselement[@ordnr=$ergebniselementOrdnr]">
<band height="30" splitType="Stretch">
<xsl:for-each select="sqlerg/headers/header[not(starts-with(f_name,'hidden')) and not(starts-with(f_name,'next')) ]">
<xsl:variable name="columnWidth">
<xsl:call-template name="getColumnwidth">
<xsl:with-param name="druckbreite" select="$druckbreite"/>
<xsl:with-param name="std_spaltenbreite" select="$std_spaltenbreite"/>
<xsl:with-param name="ergebniselementOrdnr" select="$ergebniselementOrdnr"/>
<xsl:with-param name="colId" select="@id" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="columnX">
<xsl:call-template name="getColumnX">
<xsl:with-param name="druckbreite" select="$druckbreite"/>
<xsl:with-param name="std_spaltenbreite" select="$std_spaltenbreite"/>
<xsl:with-param name="ergebniselementOrdnr" select="$ergebniselementOrdnr"/>
<xsl:with-param name="colId" select="@id" />
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="jr_textField">
<xsl:with-param name="ergebnisElementOrdnr" select="$ergebniselementOrdnr" />
<xsl:with-param name="fieldName" select="wert" />
<xsl:with-param name="colId" select="@id" />
<xsl:with-param name="x" select="$columnX" />
<xsl:with-param name="width" select="$columnWidth" />
</xsl:call-template>
</xsl:for-each>
</band>
</xsl:for-each>
</detail>
</jasperReport>
</xsl:template>
<xsl:template name="jr_properties"><xsl:text>
</xsl:text>
<xsl:comment>Import von jr_properties</xsl:comment>
<property xmlns="http://jasperreports.sourceforge.net/jasperreports" name="net.sf.jasperreports.export.xls.create.custom.palette" value="true"/>
<property xmlns="http://jasperreports.sourceforge.net/jasperreports" name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>
<property xmlns="http://jasperreports.sourceforge.net/jasperreports" name="net.sf.jasperreports.export.xls.remove.empty.space.between.columns" value="true"/>
<property xmlns="http://jasperreports.sourceforge.net/jasperreports" name="net.sf.jasperreports.export.xls.remove.empty.space.between.rows " value="true"/>
</xsl:template>
<xsl:template name="jr_styles">
<xsl:param name="ergebniselementOrdnr" select="0" />
<xsl:variable name="flavorTableRowStyle">
<xsl:choose>
<xsl:when test="/ergebnisse/ergebnis/ergebniselement[@ordnr=$ergebniselementOrdnr]/sqlerg/@istreetable='true'">
<xsl:text>treeTable</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>listAlternatingBg</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="tableRowStyle">
<xsl:with-param name="flavorTableRowStyle" select="$flavorTableRowStyle" />
</xsl:call-template>
</xsl:template>
<xsl:template name="tableRowStyle">
<xsl:param name="flavorTableRowStyle" select="'listAlternatingBg'" />
<xsl:param name="ergebniselementOrdnr" select="0" />
<style name="TableRowDetail" mode="Opaque" forecolor="#000000" backcolor="#FFFFFF" hTextAlign="Right" vTextAlign="Middle" isBlankWhenNull="true" fontName="{$font}" fontSize="8">
<box rightPadding="2">
<pen lineColor="#FFFFFF"/>
</box>
<paragraph leftIndent="2" rightIndent="1" spacingBefore="0" spacingAfter="0"/>
<xsl:choose>
<xsl:when test="$flavorTableRowStyle='listAlternatingBg'">
<conditionalStyle>
<conditionExpression><![CDATA[Boolean.valueOf( $V{PAGE_COUNT} % 2 == 1 )]]></conditionExpression>
<style mode="Opaque" forecolor="#000000" backcolor="#E3E8EB"/>
</conditionalStyle>
</xsl:when>
<xsl:when test="$flavorTableRowStyle='treeTable' and count(/ergebnisse/ergebnis/ergebniselement[@ordnr=$ergebniselementOrdnr]/sqlerg/headers/header/wert='Ebene')=1">
<conditionalStyle>
<conditionExpression><![CDATA[$F{Ebene}==1]]></conditionExpression>
<style mode="Opaque" forecolor="#000000" backcolor="rgb(204,204,204)"/>
</conditionalStyle>
<conditionalStyle>
<conditionExpression><![CDATA[$F{Ebene}==2]]></conditionExpression>
<style mode="Opaque" forecolor="#000000" backcolor="rgb(224,224,224)"/>
</conditionalStyle>
<conditionalStyle>
<conditionExpression><![CDATA[$F{Ebene}==3]]></conditionExpression>
<style mode="Opaque" forecolor="#000000" backcolor="rgb(244,244,244)"/>
</conditionalStyle>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</style>
</xsl:template>
<xsl:template name="jr_fields_report_level">
<!-- nun die Felder: zuerst der Berichtsname-->
<field name="REPORT_HEADING_INSTITUTION" class="java.lang.String">
<fieldDescription><xsl:text><![CDATA[/ergebnisse/generalinfo/REPORT_HEADING_INSTITUTION]]></xsl:text></fieldDescription>
</field>
<field name="REPORT_HEADING_URL" class="java.lang.String">
<fieldDescription><xsl:text><![CDATA[/ergebnisse/generalinfo/REPORT_HEADING_URL]]></xsl:text></fieldDescription>
</field>
<field name="REPORT_LOGO_FILE" class="java.lang.String">
<fieldDescription><xsl:text><![CDATA[/ergebnisse/generalinfo/REPORT_LOGO_FILE]]></xsl:text></fieldDescription>
</field>
<field name="REPORT_HEADING_ADRESS" class="java.lang.String">
<fieldDescription><xsl:text><![CDATA[/ergebnisse/generalinfo/REPORT_HEADING_ADRESS]]></xsl:text></fieldDescription>
</field>
<field name="REPORT_EMAIL" class="java.lang.String">
<fieldDescription><xsl:text><![CDATA[/ergebnisse/generalinfo/REPORT_EMAIL]]></xsl:text></fieldDescription>
</field>
<field name="REPORT_DOCUMENTATION_URL" class="java.lang.String">
<fieldDescription><xsl:text><![CDATA[/ergebnisse/generalinfo/REPORT_DOCUMENTATION_URL]]></xsl:text></fieldDescription>
</field>
</xsl:template>
<xsl:template name="jr_fields">
<xsl:param name="ergebniselementOrdnr" select="0"/>
<xsl:variable name="isMacroReport" select="/ergebnisse/@isMakro" />
<field name="Berichtsname" class="java.lang.String">
<fieldDescription>
<xsl:choose>
<xsl:when test="$isMacroReport = 'true'">
<xsl:text><![CDATA[/ergebnisse/makro/name]]></xsl:text></xsl:when>
<xsl:otherwise><xsl:text><![CDATA[/ergebnisse/ergebnis[ @ordnr=']]></xsl:text>
<xsl:value-of select="$ergebniselementOrdnr"/>
<xsl:text><![CDATA[']/maskenname]]></xsl:text>
</xsl:otherwise>
</xsl:choose>
</fieldDescription>
</field>
<!-- dann der Erläuterungstext-->
<field name="Erlaeuterung" class="java.lang.String">
<fieldDescription><xsl:text><![CDATA[/ergebnisse/ergebnis[ @ordnr=']]></xsl:text>
<xsl:value-of select="$ergebniselementOrdnr"/>
<xsl:text><![CDATA[']/explanation]]></xsl:text></fieldDescription>
</field>
<xsl:comment> dann die Tabellenspalten </xsl:comment>
<xsl:for-each select="/ergebnisse/ergebnis/ergebniselement[@ordnr=$ergebniselementOrdnr]">
<xsl:for-each select="sqlerg/complete_headers/header">
<xsl:variable name="jasperFieldname">
<xsl:call-template name="createJasperFieldname">
<xsl:with-param name="fieldName_orig" select="wert"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="fldPrefix">
<xsl:if test="$isMacroReport='true'">
<xsl:text>tab_</xsl:text><xsl:value-of select="$ergebniselementOrdnr" />
</xsl:if>
</xsl:variable>
<xsl:if test="normalize-space($jasperFieldname)!=''"> <!-- keine leeren Feldnamen-->
<field name="{$jasperFieldname}"><!--{concat($fldPrefix,$jasperFieldname)}-->
<xsl:attribute name="class"><xsl:call-template name="getJavaType">
<xsl:with-param name="ordnr"><xsl:value-of select="$ergebniselementOrdnr"/></xsl:with-param>
<xsl:with-param name="col_id"><xsl:value-of select="@id"/></xsl:with-param></xsl:call-template></xsl:attribute>
<fieldDescription><xsl:text><![CDATA[col[@id="]]></xsl:text>
<xsl:value-of select="@id"/><xsl:text><![CDATA[" and wert!=""]]></xsl:text>
<xsl:if test="$isMacroReport='true'">
<xsl:text><![CDATA[ and ../../../@ordnr=']]></xsl:text><xsl:value-of select="$ergebniselementOrdnr" /><xsl:text>'</xsl:text>
</xsl:if>
<xsl:text><![CDATA[]/wert]]></xsl:text>
</fieldDescription>
</field>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
<!-- dann die Legende-->
<xsl:for-each select="distinct-values(//ergebnisse/ergebnis/completefields/feld/@varname)">
<xsl:variable name="jasperFieldname">
<xsl:call-template name="createJasperFieldname">
<xsl:with-param name="fieldName_orig" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="varname">
<xsl:value-of select="." />
</xsl:variable>
<!-- zuerst Label -->
<field name="{concat('legende_',$jasperFieldname,'_label')}" class="java.lang.String">
<fieldDescription><xsl:text><![CDATA[/ergebnisse/ergebnis/completefields/feld [@varname="]]></xsl:text><xsl:value-of select="$varname"/><xsl:text><![CDATA["]/@varname]]></xsl:text></fieldDescription>
</field>
<!--dann Wert-->
<field name="{concat('legende_',$jasperFieldname,'_value')}" class="java.lang.String">
<fieldDescription><xsl:text><![CDATA[/ergebnisse/ergebnis/felder/feld [@varname="]]></xsl:text><xsl:value-of select="$varname"/><xsl:text><![CDATA["]/value_caption]]></xsl:text></fieldDescription>
</field>
</xsl:for-each>
<!--Standatum und User:-->
<field name="standdatum" class="java.lang.String">
<fieldDescription><xsl:text><![CDATA[/ergebnisse/ergebnis[ @ordnr='0']/stand]]></xsl:text></fieldDescription>
</field>
<field name="user" class="java.lang.String">
<fieldDescription><xsl:text><![CDATA[/ergebnisse/user]]></xsl:text></fieldDescription>
</field>
</xsl:template>
<xsl:template name="getJavaType">
<xsl:param name="ordnr" />
<xsl:param name="col_id" />
<xsl:choose>
<xsl:when test="count(/ergebnisse/ergebnis/ergebniselement[ @ordnr=$ordnr]/sqlerg/row)=0">
<xsl:text>java.lang.String</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="/ergebnisse/ergebnis/ergebniselement[ @ordnr=$ordnr]/sqlerg/row [@no='0']/col [@id=$col_id]">
<!--Transformation:
3=DecimalFormat
4=integer
-7=Boolean
6=date
8=timestamp
9=time
Default ist
1=string-->
<xsl:choose>
<xsl:when test="@typ='3'"> <!-- DecimalFormat -->
<xsl:text>java.lang.Double</xsl:text>
</xsl:when>
<xsl:when test="@typ='4'"> <!-- Integer -->
<xsl:text>java.lang.Integer</xsl:text>
</xsl:when>
<xsl:when test="@typ='-7'">
<xsl:text>java.lang.Boolean</xsl:text>
</xsl:when>
<xsl:when test="@typ='6'">
<xsl:text>java.util.Date</xsl:text>
</xsl:when>
<xsl:when test="@typ='8'">
<xsl:text>java.lang.Timestamp</xsl:text>
</xsl:when>
<xsl:when test="@typ='9'">
<xsl:text>java.lang.Time</xsl:text>
</xsl:when>
<xsl:otherwise>
<!--Typ=1 ist string und wird defaultmäßig behandelt -->
<xsl:text>java.lang.String</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="createJasperFieldname">
<xsl:param name="fieldName_orig" />
<xsl:variable name="feldname_ohne_umbruch">
<xsl:call-template name="remove_linebreaksAndQuot"><xsl:with-param name="volltext"><xsl:value-of select="$fieldName_orig" /></xsl:with-param></xsl:call-template>
</xsl:variable>
<xsl:variable name="feldnameOhneBackslashN">
<xsl:call-template name="search_replace">
<xsl:with-param name="string"><xsl:value-of select="$feldname_ohne_umbruch" /></xsl:with-param>
<xsl:with-param name="search"><xsl:text>\n</xsl:text></xsl:with-param>
<xsl:with-param name="replace"><xsl:text> </xsl:text></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="search_replace">
<xsl:with-param name="string"><xsl:value-of select="$feldnameOhneBackslashN" /></xsl:with-param>
<xsl:with-param name="search"><xsl:text>\000</xsl:text></xsl:with-param>
<xsl:with-param name="replace"><xsl:text> </xsl:text></xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template name="getColumnX">
<xsl:param name="druckbreite"/>
<xsl:param name="std_spaltenbreite"/>
<xsl:param name="ergebniselementOrdnr" />
<xsl:param name="colId" />
<xsl:variable name="x"><xsl:text>0</xsl:text>
<xsl:for-each select="/ergebnisse/ergebnis/ergebniselement[@ordnr=$ergebniselementOrdnr]/sqlerg/headers/header[ @width &gt; 0 and not(starts-with(f_name,'hidden')) and not(starts-with(f_name,'next')) and @id &lt; $colId ]">
<xsl:variable name="previousColumnWidth">
<xsl:call-template name="getColumnwidth">
<xsl:with-param name="druckbreite" select="$druckbreite"/>
<xsl:with-param name="std_spaltenbreite" select="$std_spaltenbreite"/>
<xsl:with-param name="ergebniselementOrdnr" select="$ergebniselementOrdnr"/>
<xsl:with-param name="colId" select="@id" />
</xsl:call-template>
</xsl:variable>
<xsl:text>+</xsl:text><xsl:value-of select ="$previousColumnWidth" />
</xsl:for-each></xsl:variable>
<!--<xsl:value-of select="sum(for $s in tokenize('1+2+3','+') return number($s))" />-->
<xsl:call-template name="sumStringList">
<xsl:with-param name="pText" select="$x"/>
<xsl:with-param name="pSum" select="0"/>
<xsl:with-param name="pDelim" select="'+'"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="getColumnwidth">
<xsl:param name="druckbreite" />
<xsl:param name="std_spaltenbreite" />
<xsl:param name="ergebniselementOrdnr" />
<xsl:param name="colId" />
<xsl:variable name="defbreite"><xsl:value-of select="sum(/ergebnisse/ergebnis/ergebniselement[@ordnr=$ergebniselementOrdnr]/sqlerg/headers/header[ @width &gt; 0 and not(starts-with(f_name,'hidden')) and not(starts-with(f_name,'next')) ]/@width )" /></xsl:variable>
<xsl:variable name="ndefbreite"><xsl:value-of select="count(/ergebnisse/ergebnis/ergebniselement[@ordnr=$ergebniselementOrdnr]/sqlerg/headers/header[ @width = '' and not(starts-with(f_name,'hidden')) and not(starts-with(f_name,'next'))])" /></xsl:variable>
<xsl:variable name="gesamtbreite"><xsl:value-of select="$defbreite+($ndefbreite* $std_spaltenbreite)" /></xsl:variable>
<xsl:variable name="width"><xsl:value-of select="/ergebnisse/ergebnis/ergebniselement[@ordnr=$ergebniselementOrdnr]/sqlerg/headers/header[@id=$colId]/@width"/></xsl:variable>
<xsl:choose>
<xsl:when test="$width != ''">
<xsl:variable name="spbreite"><xsl:value-of select="$druckbreite*($width div $gesamtbreite)" />
</xsl:variable>
<xsl:choose>
<xsl:when test="$spbreite &gt; 2">
<xsl:value-of select="round($spbreite)" />
</xsl:when>
<xsl:otherwise>
<xsl:text>12</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="round($druckbreite*($std_spaltenbreite div $gesamtbreite))" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="sumStringList">
<xsl:param name="pText" select="."/>
<xsl:param name="pSum" select="0"/>
<xsl:param name="pDelim" select="'+'"/>
<xsl:choose>
<xsl:when test="not(string-length($pText) >0)">
<xsl:value-of select="$pSum"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="vnewList"
select="concat($pText,$pDelim)"/>
<xsl:variable name="vHead" select=
"substring-before($vnewList, $pDelim)"/>
<xsl:call-template name="sumStringList">
<xsl:with-param name="pText" select=
"substring-after($pText, $pDelim)"/>
<xsl:with-param name="pSum" select="$pSum+$vHead"/>
<xsl:with-param name="pDelim" select="$pDelim"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="jr_textField">
<xsl:param name="ergebnisElementOrdnr" />
<xsl:param name="fieldName" />
<xsl:param name="colId" />
<xsl:param name="x" select="'0'" />
<xsl:param name="width" select="'0'" />
<xsl:param name="height" select="'30'" />
<xsl:variable name="jasperFieldname">
<xsl:call-template name="createJasperFieldname">
<xsl:with-param name="fieldName_orig" select="$fieldName"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="fldPrefix">
<xsl:choose>
<xsl:when test="/ergebnisse/@isMakro='true'">
<xsl:text>tab_</xsl:text><xsl:value-of select="$ergebnisElementOrdnr" /></xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="fieldType">
<xsl:call-template name="getFieldType">
<xsl:with-param name="ergebnisElementOrdnr" select="$ergebnisElementOrdnr" />
<xsl:with-param name="colId" select="$colId" />
</xsl:call-template>
</xsl:variable>
<xsl:if test="normalize-space($jasperFieldname)!=''"> <!-- keine leeren Feldnamen-->
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<xsl:attribute name="pattern">
<xsl:choose>
<xsl:when test="$fieldType='4'"> <!--integer-->
<xsl:text>#</xsl:text>
</xsl:when>
<xsl:when test="$fieldType='3'"> <!--decimal-->
<xsl:text>#,###.00;-#,###.00</xsl:text>
</xsl:when>
<xsl:when test="$fieldType='6'"> <!--date-->
<xsl:text>dd.MM.yyyy</xsl:text>
</xsl:when>
<xsl:when test="$fieldType='8'"> <!--timestamp-->
<xsl:text>dd.MM.yyyy hh:mm:ss</xsl:text>
</xsl:when>
<xsl:when test="$fieldType='9'"> <!--time-->
<xsl:text>hh:mm:ss</xsl:text>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<reportElement style="TableRowDetail" stretchType="ContainerHeight" x="{$x}" y="0" width="{$width}" height="{$height}" />
<xsl:if test="$fieldType!='3' and $fieldType!='4' "><!--Zahlen immer rechtsbündig, alles andere links-->
<textElement textAlignment="Left"/>
</xsl:if>
<textFieldExpression><xsl:value-of select="concat('$F{',fldPrefix,$jasperFieldname,'}')" /></textFieldExpression>
</textField>
</xsl:if>
</xsl:template>
<xsl:template name="getFieldType">
<xsl:param name="ergebnisElementOrdnr" />
<xsl:param name="colId" />
<xsl:value-of select="/ergebnisse/ergebnis/ergebniselement[@ordnr=$ergebnisElementOrdnr]/sqlerg/row[@no='0']/col[@id=$colId]/@typ" />
</xsl:template>
<xsl:template name="getLegendExpression">
<xsl:text>""</xsl:text>
<xsl:for-each select="distinct-values(//ergebnisse/ergebnis/completefields/feld/@varname)">
<xsl:variable name="jasperFieldname">
<xsl:call-template name="createJasperFieldname">
<xsl:with-param name="fieldName_orig" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="varname">
<xsl:value-of select="." />
</xsl:variable>
<xsl:value-of select="concat('+(($F{','legende_',$jasperFieldname,'_value','}==null || $F{','legende_',$jasperFieldname,'_value','}==&quot;&quot;)?','&quot;&quot;:(')" />
<xsl:value-of select="concat('$F{','legende_',$jasperFieldname,'_label','}')" /><xsl:text>+": "+</xsl:text>
<xsl:value-of select="concat('$F{','legende_',$jasperFieldname,'_value','}')" /><xsl:text>+";"))
</xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template name="generateTableHeader">
<xsl:param name="druckbreite" />
<xsl:param name="std_spaltenbreite" />
<xsl:param name="zeilenhoehe" select="30" />
<xsl:param name="ordnr" select="0"/>
<xsl:param name="y_offset" select="0"/>
<xsl:for-each select="/ergebnisse/ergebnis/ergebniselement[@ordnr=$ordnr]"><!--derzeit nur eine Tabelle erlaubt-->
<xsl:choose>
<xsl:when test="sqlerg/headers/@hasAggregationHeaders='true'" >
<!-- verschachtelter Header -->
<xsl:for-each select="sqlerg/aggregationHeaders/tr">
<xsl:variable name="rowCounter" select="position()-1" />
<xsl:for-each select="th" >
<xsl:variable name="colId"><xsl:value-of select="position()-1" /></xsl:variable>
<xsl:if test="@isHidden='false'">
<xsl:comment><xsl:text>colId=</xsl:text><xsl:value-of select="$colId"/></xsl:comment>
<xsl:variable name="columnWidth">
<xsl:call-template name="getColumnwidth">
<xsl:with-param name="druckbreite" select="$druckbreite"/>
<xsl:with-param name="std_spaltenbreite" select="$std_spaltenbreite"/>
<xsl:with-param name="ergebniselementOrdnr" select="$ordnr"/>
<xsl:with-param name="colId" select="$colId" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="columnX">
<xsl:call-template name="getColumnX">
<xsl:with-param name="druckbreite" select="$druckbreite"/>
<xsl:with-param name="std_spaltenbreite" select="$std_spaltenbreite"/>
<xsl:with-param name="ergebniselementOrdnr" select="$ordnr"/>
<xsl:with-param name="colId" select="$colId" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="rowspan">
<xsl:choose>
<xsl:when test="@rowspan &gt;1">
<xsl:value-of select="@rowspan"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>1</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="colspan">
<xsl:choose>
<xsl:when test="@colspan &gt;1">
<xsl:value-of select="@colspan"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>1</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<staticText>
<reportElement style="TableColumnHeader" mode="Opaque" x="{$columnX}" y="{$y_offset+( $rowCounter * $zeilenhoehe )}" width="{$columnWidth * $colspan}" height="{$zeilenhoehe*$rowspan}" backcolor="#7A93AB" />
<text><xsl:value-of select="." /></text>
</staticText>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="sqlerg/headers/header[not(starts-with(f_name,'hidden')) and not(starts-with(f_name,'next')) ]">
<xsl:variable name="columnWidth">
<xsl:call-template name="getColumnwidth">
<xsl:with-param name="druckbreite" select="$druckbreite"/>
<xsl:with-param name="std_spaltenbreite" select="$std_spaltenbreite"/>
<xsl:with-param name="ergebniselementOrdnr" select="$ordnr"/>
<xsl:with-param name="colId" select="@id" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="columnX">
<xsl:call-template name="getColumnX">
<xsl:with-param name="druckbreite" select="$druckbreite"/>
<xsl:with-param name="std_spaltenbreite" select="$std_spaltenbreite"/>
<xsl:with-param name="ergebniselementOrdnr" select="$ordnr"/>
<xsl:with-param name="colId" select="@id" />
</xsl:call-template>
</xsl:variable>
<staticText>
<reportElement style="TableColumnHeader" mode="Opaque" x="{$columnX}" y="{$y_offset}" width="{$columnWidth}" height="{$zeilenhoehe}" backcolor="#7A93AB" />
<text><xsl:value-of select="wert" /></text>
</staticText>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template name="getZeilenhoeheTableHeader">
<xsl:param name="ordnr" select="0" />
<xsl:param name="std_zeilenhoehe_header" select="30" />
<xsl:param name="y_offset" select="0" />
<xsl:choose>
<xsl:when test="/ergebnisse/ergebnis/ergebniselement[@ordnr=$ordnr]/sqlerg/headers/@hasAggregationHeaders='true'">
<xsl:variable name="maxRownumberTableHeader">
<xsl:value-of select="count(/ergebnisse/ergebnis/ergebniselement[@ordnr=$ordnr]/sqlerg/aggregationHeaders/tr)"/>
</xsl:variable>
<xsl:value-of select="$y_offset + ( $std_zeilenhoehe_header * $maxRownumberTableHeader )"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$y_offset + $std_zeilenhoehe_header "/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="generateGroupHeaderBandSimple">
<xsl:param name="ergebniselementOrdnr" select="0" />
<xsl:param name="std_zeilenhoehe_header" />
<xsl:param name="druckbreite" />
<xsl:param name="std_spaltenbreite" />
<xsl:variable name="isMacroReport" select="/ergebnisse/@isMakro" />
<xsl:variable name="legendLabelHeight" select="20" />
<xsl:variable name="legendContentHeight" select="40" />
<xsl:variable name="subReportTitleHeight">
<xsl:choose>
<xsl:when test="$isMacroReport='false'">
<xsl:text>0</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>20</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<group name="tabellennr">
<groupExpression><![CDATA[$V{tabellennr}]]></groupExpression>
<groupHeader>
<band>
<xsl:attribute name="height">
<xsl:call-template name="getZeilenhoeheTableHeader">
<xsl:with-param name="ordnr" select="$ergebniselementOrdnr" />
<xsl:with-param name="std_zeilenhoehe_header" select="$std_zeilenhoehe_header" />
<xsl:with-param name="y_offset" select="$legendLabelHeight+$legendContentHeight + $subReportTitleHeight"/>
</xsl:call-template>
</xsl:attribute>
<!--subReportTitle-->
<xsl:if test="$isMacroReport = 'true'">
<textField>
<reportElement style="subReportTitle" x="0" y="0" width="{$druckbreite}" height="{$subReportTitleHeight}" />
<textFieldExpression><xsl:text disable-output-escaping="yes"><![CDATA[ $F{Berichtsname}]]></xsl:text></textFieldExpression>
</textField>
</xsl:if>
<!--Legende -->
<textField>
<reportElement style="LegendLabel" x="0" y="{$subReportTitleHeight}" width="{$druckbreite}" height="{$legendLabelHeight}" />
<textElement verticalAlignment="Bottom"/>
<textFieldExpression><![CDATA["Filterkriterien: "]]></textFieldExpression>
</textField>
<textField>
<reportElement style="LegendContent" x="0" y="{$subReportTitleHeight+$legendLabelHeight}" width="{$druckbreite}" height="{$legendContentHeight}" />
<textFieldExpression>
<xsl:call-template name="getLegendExpression" />
<xsl:text disable-output-escaping="yes"><![CDATA[ +"Datenstand: "+ $F{standdatum} + "; " + "Erstellt: "+ DATEFORMAT( TODAY(), "dd.MM.YYYY")]]></xsl:text></textFieldExpression>
</textField>
<!--nun Spaltenüberschriften-->
<xsl:call-template name="generateTableHeader">
<xsl:with-param name="druckbreite" select="$druckbreite" />
<xsl:with-param name="std_spaltenbreite" select="$std_spaltenbreite"/>
<xsl:with-param name="zeilenhoehe" select="$std_zeilenhoehe_header" />
<xsl:with-param name="ordnr" select="$ergebniselementOrdnr"/>
<xsl:with-param name="y_offset" select="$legendLabelHeight +$legendContentHeight+ $subReportTitleHeight"/>
</xsl:call-template>
</band>
</groupHeader>
</group>
</xsl:template>
<xsl:template name="generateTitleBand">
<xsl:param name="druckbreite" select="812" />
<title>
<band height="75">
<textField>
<reportElement x="0" y="0" width="{$druckbreite}" height="30" style="ReportHeadingInstitution"/>
<textFieldExpression><![CDATA[$F{REPORT_HEADING_INSTITUTION} + " | "+ $F{user}]]></textFieldExpression>
</textField>
<textField>
<reportElement style="ReportTitle" x="0" y="30" width="{$druckbreite}" height="45" />
<textFieldExpression><![CDATA[$F{Berichtsname}]]></textFieldExpression>
</textField>
</band>
</title>
</xsl:template>
</xsl:stylesheet>