<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:p="http://polarion.com/xml-export"
xmlns:x="http://www.w3.org/1999/xhtml"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="x p">
<xsl:key name="type" match="/p:workItems/p:workItem/p:fields/p:type" use="@id"/>
<xsl:template match="/">
<fo:root
xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Arial">
<fo:layout-master-set>
<fo:simple-page-master master-name="toc" page-width="210mm" page-height="297mm"
margin-top="1cm" margin-bottom="1cm"
margin-left="2cm" margin-right="2cm">
<fo:region-body margin-top="2cm" margin-bottom="1cm"/>
<fo:region-before extent="2cm"/>
<fo:region-after extent="1cm"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="WorkItems" page-width="210mm" page-height="297mm"
margin-top="1cm" margin-bottom="1cm"
margin-left="2cm" margin-right="2cm">
<fo:region-body margin-top="2cm" margin-bottom="1cm"/>
<fo:region-before extent="2cm"/>
<fo:region-after extent="1cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="toc" format="i" force-page-count="no-force">
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="center" font-size="14pt"
border-bottom="thin solid black">
WorkItem Export - Table of Contents
</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after">
<fo:block font-size="12pt" text-align="center" border-top="thin solid black">
<fo:page-number/>
</fo:block>
</fo:static-content>
<xsl:apply-templates mode="toc"/>
</fo:page-sequence>
<fo:page-sequence master-reference="WorkItems" initial-page-number="1">
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="center" font-size="14pt" border-bottom="thin solid black">WorkItem Export -
<fo:retrieve-marker retrieve-class-name="type"
retrieve-position="first-including-carryover"/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after">
<fo:block font-size="12pt" text-align="center" border-top="thin solid black">
Page
<fo:page-number/> /
<fo:page-number-citation ref-id="last-page"/>
</fo:block>
</fo:static-content>
<xsl:apply-templates mode="content"/>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="/p:workItems" mode="toc">
<fo:flow flow-name="xsl-region-body">
<fo:block font-size="30pt" font-weight="bold">
Table of Contents
</fo:block>
<xsl:for-each select="p:workItem/p:fields/p:type[generate-id(.)=generate-id(key('type',@id)[1])]">
<xsl:apply-templates select="." mode="toc">
<xsl:with-param name="num">
<xsl:value-of select="position()"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:for-each>
</fo:flow>
</xsl:template>
<xsl:template match="/p:workItems/p:workItem/p:fields/p:type" mode="toc">
<xsl:param name="num"/>
<fo:block font-size="smaller" space-after="2mm"
space-before="2mm" text-align-last="justify"
font-weight="bold">
<fo:basic-link internal-destination="{@id}">
<xsl:value-of select="$num"/>.
<xsl:value-of select="@name"/>s
<fo:leader leader-pattern="dots"/>
<fo:page-number-citation ref-id="{@id}"/>
</fo:basic-link>
</fo:block>
<xsl:variable name="type" select="@id"/>
<xsl:apply-templates select="/p:workItems/p:workItem/p:fields[p:type/@id = $type]" mode="toc"/>
</xsl:template>
<xsl:template match="/p:workItems/p:workItem/p:fields" mode="toc">
<fo:block font-size="smaller" space-after="2mm"
space-before="2mm" start-indent="3mm" text-align-last="justify"
font-style="italic">
<fo:basic-link internal-destination="{generate-id(.)}">
<xsl:value-of select="p:id" /> -
<xsl:value-of select="p:title" />
<fo:leader leader-pattern="dots"/>
<fo:page-number-citation ref-id="{generate-id(.)}"/>
</fo:basic-link>
</fo:block>
</xsl:template>
<xsl:template match="/p:workItems" mode="content">
<fo:flow flow-name="xsl-region-body">
<xsl:for-each select="/p:workItems/p:workItem/p:fields/p:type[generate-id(.)=generate-id(key('type',@id)[1])]">
<xsl:apply-templates select="." mode="content">
<xsl:with-param name="num">
<xsl:value-of select="position()"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:for-each>
<fo:block id="last-page"/>
</fo:flow>
</xsl:template>
<xsl:template match="/p:workItems/p:workItem/p:fields/p:type" mode="content">
<xsl:param name="num"/>
<fo:block font-size="36pt" text-align="left" font-weight="bold" id="{@id}" break-before="page">
<fo:marker marker-class-name="type">
<xsl:value-of select="@name"/>s
</fo:marker>
<xsl:value-of select="$num"/>.
<xsl:value-of select="@name"/>s
</fo:block>
<fo:block>
<xsl:value-of select="p:property[@id = 'description']"/>
</fo:block>
<xsl:variable name="type" select="@id"/>
<xsl:apply-templates select="/p:workItems/p:workItem/p:fields[p:type/@id = $type]" mode="content"/>
</xsl:template>
<xsl:template match="/p:workItems/p:workItem/p:fields" mode="content">
<fo:block font-size="20pt" text-align="left" font-style="italic" id="{generate-id(.)}" space-before="5mm">
<xsl:value-of select="p:id" /> -
<xsl:value-of select="p:title" />
</fo:block>
<xsl:apply-templates select="p:description" />
</xsl:template>
<xsl:template match="p:description">
<xsl:variable name="text" select="p:text"/>
<xsl:if test="$text">
<fo:block>
<xsl:value-of select="$text"/>
</fo:block>
</xsl:if>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="p:html">
<fo:block>
<xsl:apply-templates select="./*"/>
</fo:block>
</xsl:template>
</xsl:stylesheet>
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.