XSl-FO生成レポートのFAQの概要

8548 ワード

1、横線を引く
<xsl:template name="DrawLine">
		<fo:block space-before="-7pt" space-after="1pt">
			<fo:leader leader-pattern="rule" rule-style="dotted"
				rule-thickness="0.35pt" color="black" leader-length="100%" />
		</fo:block>
	</xsl:template>

 
2、
<xsl:template name="ReportTable">
		<fo:block>
			<fo:table>
				<fo:table-column column-width="100pt" />
				<fo:table-column column-width="100pt" />
				<fo:table-column column-width="100pt" />
				<fo:table-header>
					<fo:table-row>
						<fo:table-cell>
							<fo:block space-before="3pt" space-after="5pt"
								font-size="8pt" line-height="11pt">
								<xsl:value-of select="Year" />
							</fo:block>
						</fo:table-cell>
						<fo:table-cell>
							<fo:block space-before="3pt" space-after="5pt"
								text-align="right" font-size="8pt" line-height="11pt">
								<xsl:value-of select="Additions" />
							</fo:block>
						</fo:table-cell>
						<fo:table-cell>
							<fo:block space-before="3pt" space-after="5pt"
								text-align="right" font-size="8pt" line-height="11pt">
								<xsl:value-of select="Withdrawals" />
							</fo:block>
						</fo:table-cell>
					</fo:table-row>
				</fo:table-header>
				<fo:table-body>
					<xsl:for-each select="//ts[@d!='-1']">
						<xsl:variable name="d">
							<xsl:value-of select="@d" />
						</xsl:variable>
						<fo:table-row height="11pt">
							<fo:table-cell>
								<fo:block font-size="8pt">
									<xsl:value-of select="$starYear + @d" />
								</fo:block>
							</fo:table-cell>
							<fo:table-cell>
								<fo:block font-size="8pt" text-align="right">
									<xsl:value-of select="$starYear + @d" />
								</fo:block>
							</fo:table-cell>
							<fo:table-cell>
								<fo:block font-size="8pt" text-align="right">
									<xsl:value-of select="$starYear + @d" />
								</fo:block>
							</fo:table-cell>
						</fo:table-row>
						<xsl:if test="position() mod 5 = 0 and position() != last()">
							<fo:table-row>
								<fo:table-cell number-columns-spanned="7">
									<fo:block space-before="-7pt" space-after="1pt">
										<fo:leader leader-pattern="rule" rule-style="dotted"
											rule-thickness="0.35pt" color="black" leader-length="100%" />
									</fo:block>
								</fo:table-cell>
							</fo:table-row>
						</xsl:if>
					</xsl:for-each>
				</fo:table-body>
			</fo:table>
		</fo:block>
	</xsl:template>

 
3、レポートの強制ページング方法
 fo:table-row  break-after="page"  , row 

 
4、黒トップのタイトルテンプレート
<xsl:variable name="greyheader">rgb(217,217,217)</xsl:variable>
	<xsl:template name="HeaderBar">
		<xsl:param name="Title" />
		<xsl:param name="Color" select="$greyheader" />
		<xsl:param name="Fontwt">
			bold
		</xsl:param>
		<xsl:param name="Indent">
			3pt
		</xsl:param>
		<xsl:param name="SpaceAfter">
			5pt
		</xsl:param>
		<xsl:param name="FrameStyle" />
		<xsl:param name="Text" />
		<xsl:param name="TextFontSize" />
		<fo:table table-layout="fixed" space-after="{$SpaceAfter}"
			inline-progression-dimension.optimum="100%">
			<xsl:if test="$Color!=''">
				<xsl:attribute name="background-color">
          <xsl:value-of select="$Color" />
        </xsl:attribute>
			</xsl:if>
			<xsl:attribute name="font-size">
        <xsl:choose>
			<xsl:when test="$TextFontSize!=''">
				<xsl:value-of select="$TextFontSize" />
			</xsl:when>
          <xsl:when test="$FrameStyle='large'">
            <xsl:value-of select="$FtSzH2" />
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$FtSzH1" />
          </xsl:otherwise>
        </xsl:choose>
      </xsl:attribute>
			<xsl:attribute name="height">
        <xsl:choose>
          <xsl:when test="$FrameStyle='large'">12.5pt</xsl:when>
          <xsl:otherwise>10.4pt</xsl:otherwise>
        </xsl:choose>
      </xsl:attribute>
			<xsl:if test="$FrameStyle='large'">
				<xsl:attribute name="border-width">0pt</xsl:attribute>
			</xsl:if>
			<fo:table-column />
			<fo:table-body>
				<fo:table-row keep-with-next="always">
					<xsl:attribute name="height">
            <xsl:choose>
              <xsl:when test="$FrameStyle='large'">3.5pt</xsl:when>
              <xsl:otherwise>2pt</xsl:otherwise>
            </xsl:choose>
          </xsl:attribute>
				</fo:table-row>
				<fo:table-row keep-with-next="always">
					<fo:table-cell>
						<fo:block font-weight="{$Fontwt}" text-indent="{$Indent}"
							space-after="0pt">
							<xsl:value-of select="$Title" />
							<xsl:if test="$Text != ''">
								<fo:inline font-weight="normal" white-space-collapse="false">
									<xsl:attribute name="font-size">
                    <xsl:choose>
                    <xsl:when test="$TextFontSize!=''">
						<xsl:value-of select="$TextFontSize" />
                    </xsl:when>
                      <xsl:when test="$FrameStyle='large'">
                        <xsl:value-of select="$FtSzT2" />
                      </xsl:when>
                      <xsl:otherwise>
                        <xsl:value-of select="$FtSzT0" />
                      </xsl:otherwise>
                    </xsl:choose>
                  </xsl:attribute>
									<xsl:text></xsl:text>
									<xsl:value-of select="$Text" />
								</fo:inline>
							</xsl:if>
						</fo:block>
					</fo:table-cell>
				</fo:table-row>
			</fo:table-body>
		</fo:table>
	</xsl:template>

5 SVGで曲線を描く場合はFOPバージョンによって表示が異なり、正しく表示するためにstyle属性を導入して点線を配置します.
<svg:line stroke-width="0.15" stroke="#000000" x1="{$OriginX}" x2="{number($InnerCanvasWidth + $addmorespace - 3)}" y1="{number($InnerCanvasHeight - $addingScale + 6) }" y2="{number($InnerCanvasHeight - $addingScale + 6) }" style="stroke:black;fill:none;stroke-width:0.1;stroke-linecap:butt;stroke-dasharray:0.1,2;"/>