Announcement

Collapse
No announcement yet.

XSL soll den Tabellenkopf auf jeder Seite wiederholen

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • XSL soll den Tabellenkopf auf jeder Seite wiederholen

    Hallo Ihr,

    ich bin zu doof! Ich habe eine XML Datei, welche ich gerne per xsl drucken möchte. Das funktioniert soweit auch ganz gut. Leider wird aber der Tabellenkopf nicht auf jeder Seite wiederholt.

    Dies wäre der letzte Punkt um die Sache richtig rund zu machen. Beim Suchen im www bin ich auf die verschiedensten Ansätze gestoßen, aber leide bekomme ich dies nicht auf mein Problem adaptiert.

    Meine XML sieht in etwa so aus:
    Code:
    <?xml version="1.0" encoding="windows-1252" ?>
    <TODOLIST FILENAME="D:\Programme\ToDoList 5.7\Resources\Introduction.tdl" PROJECTNAME="Sample Tasklist" FILEFORMAT="9" NEXTUNIQUEID="26" LASTMODIFIED="2009-07-17" FILEVERSION="92" EARLIESTDUEDATE="0.00000000" CHECKEDOUTTO="PC-THE2">
    <TASK TITLE="This a Task" ID="1" ICONINDEX="-1" COMMENTS="New tasks can be created using" POS="1" LASTMOD="40011.57346065" LASTMODSTRING="17.07.2009 13:45" NUMPERSON="1" PERSON="Mary" ALLOCATEDBY="Frank" STATUS="Delayed" NUMCATEGORY="1" CATEGORY="Work" PRIORITY="5" RISK="0" PERCENTDONE="0" COST="0.00000000" CALCCOST="0.00000000" TIMEESTIMATE="0.00000000" TIMEESTUNITS="I" TIMESPENT="0.00000000" TIMESPENTUNITS="M" STARTDATE="39739.00000000" STARTDATESTRING="18.10.2008" CREATIONDATE="39739.00000000" CREATIONDATESTRING="18.10.2008" COMMENTSTYPE="PLAIN_TEXT" PRIORITYCOLOR="15732480" PRIORITYWEBCOLOR="#000FF0"/>
    <TASK TITLE="A Task can contain..." ID="2" ICONINDEX="-1" POS="2" LASTMOD="40011.57333333" LASTMODSTRING="17.07.2009 13:45" NUMPERSON="1" PERSON="Mary" ALLOCATEDBY="Frank" STATUS="Cancelled" NUMCATEGORY="1" CATEGORY="Work" PRIORITY="5" RISK="0" PERCENTDONE="0" COST="0.00000000" CALCCOST="0.00000000" TIMEESTIMATE="0.00000000" TIMEESTUNITS="I" TIMESPENT="0.00000000" TIMESPENTUNITS="M" STARTDATE="39739.00000000" STARTDATESTRING="18.10.2008" CREATIONDATE="39739.00000000" CREATIONDATESTRING="18.10.2008" PRIORITYCOLOR="15732480" PRIORITYWEBCOLOR="#000FF0">
    <TASK TITLE="Subtasks" ID="3" ICONINDEX="-1" COMMENTS="Any task can become a subtask by dragging it " POS="1" LASTMOD="40011.57353009" LASTMODSTRING="17.07.2009 13:45" NUMPERSON="1" PERSON="Pete" ALLOCATEDBY="Frank" STATUS="Delayed" NUMCATEGORY="1" CATEGORY="Work" PRIORITY="10" RISK="0" PERCENTDONE="0" COST="0.00000000" CALCCOST="0.00000000" TIMEESTIMATE="0.00000000" TIMEESTUNITS="I" TIMESPENT="0.00000000" TIMESPENTUNITS="M" STARTDATE="39739.00000000" STARTDATESTRING="18.10.2008" CREATIONDATE="39739.00000000" CREATIONDATESTRING="18.10.2008" COMMENTSTYPE="PLAIN_TEXT" PRIORITYCOLOR="255" PRIORITYWEBCOLOR="#FF0000"/>
    <TASK TITLE="Which in turn can contain other ..." ID="4" ICONINDEX="-1" POS="2" LASTMOD="40011.57329861" LASTMODSTRING="17.07.2009 13:45" NUMPERSON="1" PERSON="Pete" ALLOCATEDBY="Frank" STATUS="Approved" NUMCATEGORY="1" CATEGORY="Work" PRIORITY="10" RISK="0" PERCENTDONE="0" COST="0.00000000" CALCCOST="0.00000000" TIMEESTIMATE="0.00000000" TIMEESTUNITS="I" TIMESPENT="0.00000000" TIMESPENTUNITS="M" STARTDATE="39739.00000000" STARTDATESTRING="18.10.2008" CREATIONDATE="39739.00000000" CREATIONDATESTRING="18.10.2008" PRIORITYCOLOR="255" PRIORITYWEBCOLOR="#FF0000">
    <TASK TITLE="Subtasks" ID="5" ICONINDEX="-1" COMMENTS="And this is the means by which complex " POS="1" LASTMOD="40011.57357639" LASTMODSTRING="17.07.2009 13:45" NUMPERSON="1" PERSON="Pete" ALLOCATEDBY="Frank" STATUS="Delayed" NUMCATEGORY="1" CATEGORY="Work" PRIORITY="10" RISK="0" PERCENTDONE="0" COST="0.00000000" CALCCOST="0.00000000" TIMEESTIMATE="0.00000000" TIMEESTUNITS="I" TIMESPENT="0.00000000" TIMESPENTUNITS="M" STARTDATE="39739.00000000" STARTDATESTRING="18.10.2008" CREATIONDATE="39739.00000000" CREATIONDATESTRING="18.10.2008" COMMENTSTYPE="PLAIN_TEXT" PRIORITYCOLOR="255" PRIORITYWEBCOLOR="#FF0000"/>
    </TASK>
    </TASK>
    <TASK TITLE="This is a completed task" ID="9" ICONINDEX="-1" COMMENTS="A task can be marked as complete in a number " POS="3" LASTMOD="40011.57364583" LASTMODSTRING="17.07.2009 13:46" NUMPERSON="1" PERSON="Pete" ALLOCATEDBY="Frank" STATUS="Delayed" NUMCATEGORY="1" CATEGORY="Work" PRIORITY="5" RISK="0" PERCENTDONE="100" CALCPERCENTDONE="100" COST="0.00000000" CALCCOST="0.00000000" DONEDATE="39739.00000000" DONEDATESTRING="18.10.2008" STARTDATE="39739.00000000" STARTDATESTRING="18.10.2008" CREATIONDATE="39739.00000000" CREATIONDATESTRING="18.10.2008" COMMENTSTYPE="PLAIN_TEXT" TEXTCOLOR="12632256" TEXTWEBCOLOR="#C0C0C0" PRIORITYCOLOR="57630" PRIORITYWEBCOLOR="#1EE100">
    <TASK TITLE="Subtasks" ID="10" ICONINDEX="-1" COMMENTS="whose parent tasks are complete are displayed " POS="1" LASTMOD="40011.57371528" LASTMODSTRING="17.07.2009 13:46" NUMPERSON="1" PERSON="Pete" ALLOCATEDBY="Frank" NUMCATEGORY="1" CATEGORY="Work" PRIORITY="5" RISK="0" PERCENTDONE="0" COST="0.00000000" CALCCOST="0.00000000" STARTDATE="39739.00000000" STARTDATESTRING="18.10.2008" CREATIONDATE="39739.00000000" CREATIONDATESTRING="18.10.2008" COMMENTSTYPE="PLAIN_TEXT" PRIORITYCOLOR="15732480" PRIORITYWEBCOLOR="#000FF0"/>
    </TASK>
    <CATEGORY CATEGORY0="Home" CATEGORY1="Work" CATEGORY2="Travel" CATEGORY3="Groceries"/>
    <STATUS STATUS0="Cancelled" STATUS1="Awaiting Confirmation" STATUS2="Delayed" STATUS3="Approved"/>
    <PERSON PERSON0="Bob" PERSON1="Jane" PERSON2="Pete" PERSON3="Mary"/>
    <ALLOCATEDBY ALLOCATEDBY0="Frank" ALLOCATEDBY1="Margaret"/>
    </TODOLIST>
    Die XSL dazu ist im zweiten Post.

    Im Ergebnis sieht es nun so aus wie ich es möchte, doch es sollte der Tabellenkopf auf jeder Seite erscheinen (siehe Anhang).

    Kann mir bitte jemand eine Stups in die Richtung geben, wie ich dies hinbekommen kann. Als ich versucht habe dies mit fo:table zu machen und die Element umschlossen habe, habe ich immer den Fehler bekommen, dass ich die Elemente nicht verwenden kann.

    Ich bin für jede Hilfe dankebar!!
    Attached Files

  • #2
    Nun im zweiten Post die XSL:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    	<xsl:strip-space elements="*"/>
    	<xsl:output method="html" indent="yes" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" encoding="UTF-8"/>
    	<xsl:template match="/">
    		<xsl:element name="html">
    			<xsl:apply-templates select="TODOLIST"/>
    		</xsl:element>
    	</xsl:template>
    	<!-- 00 - body of report -->
    	<xsl:template match="TODOLIST">
    		<xsl:element name="head">
    			<xsl:element name="title">
    				<xsl:value-of select="@PROJECTNAME"/>
    			</xsl:element>
    			<xsl:element name="style">
    				<xsl:attribute name="type">text/css</xsl:attribute>
    				<xsl:text>
    table.finished{
    	border-bottom: 1px solid Black;
    	border-right: 1px solid Black;
    	border-top: 2px solid Black;
    	border-left: 2px solid Black;
    	width: 100%;
    	vertical-align: top;
    }
    tr.header{
    	background-color: #004C5B;
    	color: #FFFFFF;
    	font-weight: bold;
    }
    tr.lead{
    	font-weight: bold;
    }
    td.header{
    	border-bottom: 2px solid Black;
    	border-right: 1px solid Black;
    }
    td.bbasic{
    	border-bottom: 1px solid Black;
    	border-right: 1px solid Black;
    }
    td.status{
    	text-align: left;
    	vertical-align: top;
    	font-size: 10pt;
    }
    td.pos{
    	text-align: left;
    	vertical-align: top;
    	font-size: 9pt;
    }
    td.prior{
    	text-align:center;
    	vertical-align: top;
    	color: white;
    	font-size: 10pt;
    }
    td.category{
    	text-align:left;
    	vertical-align: top;
    	font-size: 10pt;
    }
    td.task{
    	text-align:left;
    	vertical-align: top;
    }
    td.to{
    	text-align:left;
    	vertical-align: top;
    	font-size: 10pt;
    }
    td.by{
    	text-align:left;
    	vertical-align: top;
    	font-size: 10pt;
    }
    td.empty{
    	text-align: left;
    	color: #DCDCDC;
    	font-size: 8pt;
    }
    span.tab{
    	padding-left:20px;
    	margin: 0 0 0 0;
    }
    .noborder{
    	margin: 0 5 0 0;
    }
    div.commentbox{
    	width: 80%;
    	float: right;
    	margin: 10 1 1 0;
    	padding:5px;
    	font-style: italic;
    	font-size: 8pt;
    	display: block;
    	border: 2px dotted Black;
    }
    body {
    	font-family: Arial;
    	font-size: 10pt;
    }</xsl:text>
    			</xsl:element>
    		</xsl:element>
    		<xsl:element name="body">
    			<xsl:element name="h1">Projekt: <xsl:value-of select="@PROJECTNAME"/>
    			</xsl:element>
    			<xsl:element name="table">
    				<xsl:attribute name="class">finished</xsl:attribute>
    				<xsl:attribute name="cellspacing">0</xsl:attribute>
    				<xsl:attribute name="cellpadding">5</xsl:attribute>
    				<xsl:apply-templates select="TASK"/>
    			</xsl:element>
    		</xsl:element>
    	</xsl:template>
    	<!-- 10 - table of tasks context -->
    	<xsl:template match="TASK">
    		<xsl:choose>
    			<xsl:when test="parent::TODOLIST">
    				<xsl:if test="not(@CALCPERCENTDONE=empty)">
    					<!-- 11 - create header only for first row-->
    					<xsl:if test="position()=1">
    						<xsl:call-template name="get_Header"/>
    					</xsl:if>
    					<!-- 12 - lead task, child of todolist element -->
    					<xsl:call-template name="get_LeadTask"/>
    					<xsl:apply-templates select="TASK"/>
    				</xsl:if>
    			</xsl:when>
    			<xsl:otherwise>
    					<xsl:call-template name="get_Task"/>
    					<xsl:apply-templates select="TASK"/>
    			</xsl:otherwise>
    		</xsl:choose>
    	</xsl:template>
    	<xsl:template name="get_Header">
    		<xsl:element name="tr">
    			<xsl:attribute name="class">header</xsl:attribute>
    				<xsl:attribute name="class">header</xsl:attribute>
    				<xsl:attribute name="width">20</xsl:attribute>
    				<xsl:text>Pos</xsl:text>
    			</xsl:element>-->
    			<fo:table table-omit-header-at-break="false">
    			 <xsl:element name="td">
    				<xsl:attribute name="class">header</xsl:attribute>
    				<xsl:attribute name="width">15</xsl:attribute>
    				<xsl:text>!</xsl:text>
    			</xsl:element>
    			<xsl:element name="td">
    				<xsl:attribute name="class">header</xsl:attribute>
    				<xsl:attribute name="width">80</xsl:attribute>
    				<xsl:text>Status</xsl:text>
    			</xsl:element>
    			<xsl:element name="td">
    				<xsl:attribute name="class">header</xsl:attribute>
    				<xsl:attribute name="width">100</xsl:attribute>
    				<xsl:text>An</xsl:text>
    			</xsl:element>
    			<xsl:element name="td">
    				<xsl:attribute name="class">header</xsl:attribute>
    				<xsl:attribute name="width">100</xsl:attribute>
    				<xsl:text>Von</xsl:text>
    			</xsl:element>
    			<xsl:element name="td">
    				<xsl:attribute name="class">header</xsl:attribute>
    				<xsl:attribute name="width">100</xsl:attribute>
    				<xsl:text>Kunde</xsl:text>
    			</xsl:element>
    			<xsl:element name="td">
    				<xsl:attribute name="class">header</xsl:attribute>
    				<xsl:text>Aufgaben</xsl:text>
    			</xsl:element>
    			</fo:table>
    		</xsl:element>
    	</xsl:template>
    	<xsl:template name="get_LeadTask">
    		<xsl:element name="tr">
    			<xsl:attribute name="class">lead</xsl:attribute>
    			<xsl:call-template name="get_Task_Details"/>
    		</xsl:element>
    	</xsl:template>
    	<xsl:template name="get_Task">
    		<xsl:element name="tr">
    			<xsl:call-template name="get_Task_Details"/>
    		</xsl:element>
    	</xsl:template>
    	<xsl:template name="get_Task_Details">
    		<!--<xsl:call-template name="get_Pos"/> -->
    		<xsl:call-template name="get_Priority"/>
    		<xsl:call-template name="get_Status"/>
    		<xsl:call-template name="get_to"/>
    		<xsl:call-template name="get_by"/>
    		<xsl:call-template name="get_Category"/>
    		<xsl:call-template name="get_Task_title"/>
    	</xsl:template>
    	<!-- 40 - @Pos. as Pos ID 	
    	<xsl:template name="get_Pos">
    		<xsl:element name="td">
    			<xsl:choose>
    				<xsl:when test="(@POS)">
    					<xsl:attribute name="class">pos bbasic</xsl:attribute>
    					<xsl:value-of select="@POS"/>
    				</xsl:when>
    				<xsl:otherwise>
    					<xsl:attribute name="class">pos bbasic empty</xsl:attribute>
    					<xsl:text>nicht definiert</xsl:text>
    				</xsl:otherwise>
    			</xsl:choose>
    		</xsl:element>
    	</xsl:template>-->
    	<xsl:template name="get_Status">
    		<xsl:element name="td">
    			<xsl:choose>
    				<xsl:when test="(@status)">
    					<xsl:attribute name="class">status bbasic</xsl:attribute>
    					<xsl:value-of select="@Status"/>
    				</xsl:when>
    				<xsl:otherwise>
    					<xsl:attribute name="class">status bbasic empty</xsl:attribute>
    					<xsl:text>nicht definiert</xsl:text>
    				</xsl:otherwise>
    			</xsl:choose>
    		</xsl:element>
    	</xsl:template>
    	<xsl:template name="get_Priority">
    		<xsl:element name="td">
    			<xsl:attribute name="class">prior bbasic</xsl:attribute>
    			<xsl:attribute name="style">background-color: <xsl:value-of select="@PRIORITYWEBCOLOR"/>;</xsl:attribute>
    			<xsl:value-of select="@PRIORITY"/>
    		</xsl:element>
    	</xsl:template>
    	<xsl:template name="get_to">
    		<xsl:element name="td">
    			<xsl:choose>
    				<xsl:when test="(@PERSON)">
    					<xsl:attribute name="class">to bbasic</xsl:attribute>
    					<xsl:value-of select="@PERSON"/>
    				</xsl:when>
    				<xsl:otherwise>
    					<xsl:attribute name="class">to bbasic empty</xsl:attribute>
    					<xsl:text>niemand</xsl:text>
    				</xsl:otherwise>
    			</xsl:choose>
    		</xsl:element>
    	</xsl:template>
    	<xsl:template name="get_by">
    		<xsl:element name="td">
    			<xsl:choose>
    				<xsl:when test="(@ALLOCATEDBY)">
    					<xsl:attribute name="class">by bbasic</xsl:attribute>
    					<xsl:value-of select="@ALLOCATEDBY"/>
    				</xsl:when>
    				<xsl:otherwise>
    					<xsl:attribute name="class">by bbasic empty</xsl:attribute>
    					<xsl:text>niemand</xsl:text>
    				</xsl:otherwise>
    			</xsl:choose>
    		</xsl:element>
    	</xsl:template>
    	<xsl:template name="get_Category">
    		<xsl:element name="td">
    			<xsl:choose>
    				<xsl:when test="(@CATEGORY)">
    					<xsl:attribute name="class">category bbasic</xsl:attribute>
    					<xsl:value-of select="@CATEGORY"/>
    				</xsl:when>
    				<xsl:otherwise>
    					<xsl:attribute name="class">category bbasic empty</xsl:attribute>
    					<xsl:text>nicht definiert</xsl:text>
    				</xsl:otherwise>
    			</xsl:choose>
    		</xsl:element>
    	</xsl:template>
    	<xsl:template name="get_Task_title">
    		<xsl:element name="td">
    			<xsl:attribute name="class">task bbasic</xsl:attribute>
    			<xsl:call-template name="tab"/>
    			<xsl:value-of select="@TITLE"/>
    			<xsl:if test="@COMMENTS">
    				<xsl:element name="br"/>
    				<xsl:call-template name="tab"/>
    				<xsl:element name="div">
    					<xsl:attribute name="class">commentbox</xsl:attribute>
    					<xsl:call-template name="fix-breaks">
    						<xsl:with-param name="text">
    							<xsl:value-of select="@COMMENTS"/>
    						</xsl:with-param>
    					</xsl:call-template>
    				</xsl:element>
    			</xsl:if>
    		</xsl:element>
    	</xsl:template>
    	<xsl:template name="tab">
    		<xsl:if test="count(ancestor::TASK)>0">
    			<xsl:for-each select="(ancestor::TASK)">
    				<xsl:element name="span">
    					<xsl:attribute name="class">tab</xsl:attribute>
    				</xsl:element>
    			</xsl:for-each>
    		</xsl:if>
    	</xsl:template>
    	<xsl:template name="fix-breaks">
    		<xsl:param name="text" />
    		<xsl:choose>
    			<xsl:when test="contains($text,'
    ')">
    				<xsl:value-of select="substring-before($text,'
    ')" />
    				<xsl:element name="br"/>
    				<xsl:call-template name="fix-breaks">
    					<xsl:with-param name="text">
    						<xsl:value-of select="substring-after($text,'
    ')" />
    					</xsl:with-param>
    				</xsl:call-template>
    			</xsl:when>
    			<xsl:otherwise>
    				<xsl:value-of select="$text" />
    			</xsl:otherwise>
    		</xsl:choose>
    	</xsl:template>
    </xsl:stylesheet>

    Comment

    Working...
    X