- PR -

culumn-numberの取得方法

1
投稿者投稿内容
しむらん
会議室デビュー日: 2004/08/27
投稿数: 1
投稿日時: 2004-08-27 12:17
始めまして。
column-number="{position()}"で正しい数値が取得できず、困っています。

XSLTとXMLからSAXONを使用して、XSL-FOを生成しようとしています。
内容は、DB検索結果をXMLファイルにし、その結果を表に埋め込みます。
したがって、表の行数は、不定です。

以下のようなスタイルシートとDB検索結果を書いたのですが、culumn-number="{position()}"の数値が正しく取得できてないようで、XSL-FO出力が期待どおりにいきません。

-----スタイルシート(抜粋)-----
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xml.apache.org/fop/extensions" xmlns:foa="http://fabio">
<xsl:param name="library"/>
<xsl:include href="kadai5Vars.xsl"></xsl:include>
中略
<xsl:template match="librarys/persons" foa:name="UserInfoTable_1" foa:group="simple-table" foa:class="table">
<fo:table foa:name="UserInofTable_1" foa:class="table" foa:group="simple-table" foa:content="static" table-layout="fixed" xsl:use-attribute-sets="Table_1">
<fo:table-column column-number="1" column-width="40.0mm" ></fo:table-column>
<fo:table-column column-number="2" column-width="198.0pt" ></fo:table-column>
<fo:table-body >
<xsl:apply-templates></xsl:apply-templates>
</fo:table-body>
</fo:table>
</xsl:template>

<xsl:template match="librarys/persons/person" foa:class="table-row" foa:type="table-row" foa:name="UserInfoTable_1" foa:group="simple-table">
<fo:table-row foa:name="UserInofTable_1" foa:class="table-row" foa:group="simple-table" foa:content="static" xsl:use-attribute-sets="Row">
<xsl:apply-templates></xsl:apply-templates>
</fo:table-row>
</xsl:template>

<xsl:template match="librarys/persons/person/id[@class='header']" foa:class="table-cell" foa:name="UserInfoTable_1" foa:group="simple-table" foa:type="table-cell">
<fo:table-cell foa:name="UserInfoTable_1" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" foa:content="static" column-number="{position()}" xsl:use-attribute-sets="Cell_1">
<fo:block>
<xsl:apply-templates></xsl:apply-templates>
</fo:block>
</fo:table-cell>
</xsl:template>
<xsl:template match="librarys/persons/person/id[@class='value']" foa:class="table-cell" foa:name="UserInfoTable_1" foa:group="simple-table" foa:type="table-cell">
<fo:table-cell foa:name="UserInfoTable_1" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" foa:content="static" column-number="{position()}" xsl:use-attribute-sets="Cell_2">
<fo:block>
<xsl:apply-templates></xsl:apply-templates>
</fo:block>
</fo:table-cell>
</xsl:template>
-----ここまで-----

-----DB検索結果のxml(抜粋)-----
<librarys>
 <persons>
  <person id="0001">
   <id class="header">ID</id>
   <id class="value">0000001</id>
  </person>
-----ここまで-----

-----SAXON出力のfoファイル(抜粋)-----
<fo:block text-align="justify" font-size="9.5pt" font-family=""MS ゴシック"" border-color="black" space-before.optimum="10mm" border-style="none" space-after.optimum="10mm" foa:name="UserTable" foa:group="paragraph" foa:class="block" foa:content="dynamic">
<fo:table border-collapse="collapse" border-style="none" foa:name="UserInofTable_1" foa:class="table" foa:group="simple-table" foa:content="static" table-layout="fixed" width="311.6pt">
<fo:table-column column-number="1" column-width="40.0mm"/>
<fo:table-column column-number="2" column-width="198.0pt"/>
<fo:table-body>
<fo:table-row font-family=""MS ゴシック"" foa:name="UserInofTable_1" foa:class="table-row" foa:group="simple-table" foa:content="static">
<fo:table-cell padding-left="5.4pt" padding-top="0mm" padding-bottom="0mm" border-color="black" border-width="1.0pt" border-style="solid" padding-right="5.4pt" foa:name="UserInfoTable_1" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" foa:content="static" column-number="2">
<fo:block>ID</fo:block>
</fo:table-cell>
<fo:table-cell padding-right="5.4pt" border-style="solid" border-width="1.0pt" border-left-style="none" padding-top="0mm" border-color="black" padding-bottom="0mm" padding-left="5.4pt" foa:name="UserInfoTable_1" foa:group="simple-table" foa:type="table-cell" foa:class="table-cell" foa:content="static" column-number="4">
<fo:block>0000001</fo:block>
</fo:table-cell>
</fo:table-row>
-----ここまで-----

foファイルの結果がculumn-number="2"とculumn-number="4"になってしまいます。
"1"と"2"を期待しているのに・・・
2列の表を作成したいのに。

SAXON8、6.5.3どちらも同じ結果になります。
いろいろと、オープンなツールをかました上、サンプルを参照しているので、単位はそろってないし、余計な要素が含まれてて、見にくくて、すみませんが・・・
どなたか、教えてください。助けてください。
よろしくお願いします。


[ メッセージ編集済み 編集者: しむらん 編集日時 2004-08-27 12:19 ]

[ メッセージ編集済み 編集者: しむらん 編集日時 2004-08-27 18:52 ]

[ メッセージ編集済み 編集者: しむらん 編集日時 2004-08-27 19:05 ]
MMX
ぬし
会議室デビュー日: 2001/10/26
投稿数: 861
投稿日時: 2004-09-06 15:52
<xsl:apply-templates>
から、起こされて、
<xsl:template match="librarys/persons/person"
にマッチした、「カレントノードリスト」の形は?

<xsl:apply-templates select="person">とか
<xsl:apply-templates select="*">
すると position() が効く、「カレントノードリスト」になるようです。

しかし、<xsl:template match="librarys/persons/person[position()=1]">
直後に
<xsl:value-of select="position()"/>
すると、2になりますね。
#########################
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:param name="library"/>
<xsl:template match="librarys">
<ROOT>
<xsl:apply-templates/>
------------------------------
<xsl:apply-templates select="*" mode="S"/>
</ROOT>
</xsl:template>
<xsl:template match="P">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="P" mode="S">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="id">
<xsl:value-of select="position()"/>
</xsl:template>
</xsl:stylesheet>

-------------------------
<librarys>
<P>
   <id >Z</id>
   <id >Y</id>
</P>
<P>   <id >X</id>
   <id >W</id>
   <id >U</id>
</P>
</librarys>
---------------------- 結果
selectの付かないapply-templats のは違う。

<?xml version="1.0" encoding="UTF-8"?><ROOT>
   2
   4   2
   4
   6
------------------------------
12123</ROOT>

[ メッセージ編集済み 編集者: MMX 編集日時 2004-09-06 16:12 ]
1

スキルアップ/キャリアアップ(JOB@IT)