私が抱えている問題の衰弱したバージョンはこれです。以下のようなXMLファイルの場合:ノード属性に基づいてxsltページシーケンスを動的に変更する方法は?
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item cols="1">Item 1</item>
<item cols="1">Item 2</item>
<item cols="1">Item 3</item>
<item cols="1">Item 4</item>
<item cols="1">Item 5</item>
<item cols="1">Item 6</item>
<item cols="1">Item 7</item>
<item cols="1">Item 8</item>
<item cols="1">Item 9</item>
<item cols="2">Item 10</item>
<item cols="1">Item 11</item>
<item cols="1">Item 12</item>
<item cols="1">Item 13</item>
<item cols="1">Item 14</item>
<item cols="1">Item 15</item>
<item cols="1">Item 16</item>
<item cols="1">Item 17</item>
<item cols="1">Item 18</item>
</items>
私が印刷できるようにする必要があります「を持つ項目の 『colsの『colsの= 2』を持っている= 1』一列のページレイアウトで、と」項目のダブルカラムページレイアウト。アイテムの順序を保持する必要があります。 @colsと同じ値を持つすべての連続したアイテムは、連続したフローとして表示する必要があります。 @colsの値が変わるたびに、私は新しいページに壊れて、必要に応じてレイアウトを変更する必要があります。
私はこのような何かをやっている:
<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:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="one-column-page-master">
<fo:region-body margin-top="3cm" region-name="body" column-count="1"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="two-column-page-master">
<fo:region-body margin-top="3cm" region-name="body" column-count="2"/>
<fo:region-before region-name="header" extent="2cm"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="one-column-page">
<fo:repeatable-page-master-reference master-reference="one-column-page-master"/>
</fo:page-sequence-master>
<fo:page-sequence-master master-name="two-column-page">
<fo:repeatable-page-master-reference master-reference="two-column-page-master"/>
</fo:page-sequence-master>
</fo:layout-master-set>
<xsl:for-each select="//item">
<xsl:choose>
<xsl:when test="@cols = preceding-sibling::item[1]/@cols">
<!--cols value hasn't changed, don't create a new page-sequence-->
<!--But we cannot directly add fo:flow as the child of fo:root! -->
<xsl:call-template name="itemtemplate"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="@cols = 1">
<fo:page-sequence master-reference="one-column-page">
<xsl:call-template name="itemtemplate"/>
</fo:page-sequence>
</xsl:when>
<xsl:otherwise>
<fo:page-sequence master-reference="two-column-page">
<xsl:call-template name="itemtemplate"/>
</fo:page-sequence>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</fo:root>
</xsl:template>
<xsl:template name="itemtemplate">
<fo:flow flow-name="body">
<fo:block margin-bottom="5cm">
<xsl:apply-templates/>
</fo:block>
</fo:flow>
</xsl:template>
</xsl:stylesheet>
しかし、もちろん、問題は、私のどちらかが< FO含める必要があるということです:私は、私のスタイルシートでページシーケンス... >を、そうでありませんかノートの属性に基づいて1つを入れることを「動的に」決めることはできません。 (私が最初にスタイルシートを動的に作成するメタプログラムを持っていない限り、私は単純な静的スタイルシートを使ってこれを達成することを望んでいました)。
XSLT 2.0のグループ化機能がこの問題を解決するかどうかは不思議です。サンプル入力に必要な出力XML(FO)を表示して、目的のターゲットをよりよく理解できるようにしてください。 – LarsH