###発生している問題
XSLを作成し、XMLファイルをブラウザ表示する中で、
tableの「rowspan」に正しく対応したXSLを作成できず、困っております。
課題となっているポイントとしては、
インプットとなるXMLは、既定のフォーマットとして、
「rowspan」が指定された行の、次の行(以降)に本来不要となる列データ(<td>)が
常時空データの列として入っているため、単純に変換した場合、
テーブルがズレて表示されてしまいます。
そのため、XSLの中で「rowspan」に関連する不要な列を「colspan」の指定状況も踏まえ判断し、
削除する(出力しない)制御を記載することが必要と考えているのですが、
その記載方法がわからない状況です。
※なお、空要素列を全て削除する(出力対象外とする)処理は、
実データ上、出力が必要な列も存在するためできないです。
ご教示の程、何卒よろしくお願いいたします。
###該当のXSLおよびXML
以下に現状のXSLファイル内容(table制御関連部分)と、
インプットとなるXMLのサンプルを記載させていただきます。
■XSL <xsl:template match="tbl"> <table border="1" width="100%" cellpadding="0" style="font:10pt"> <xsl:apply-templates /> </table> </xsl:template> <xsl:template match="row"> <tr> <xsl:apply-templates /> </tr> </xsl:template> <xsl:template match="cell"> <td> <xsl:apply-templates select="@rowspan" /> <xsl:apply-templates select="@width" /> <xsl:apply-templates select="@colspan" /> <xsl:apply-templates /> </td> </xsl:template> <xsl:template match="@width"> <xsl:variable name="tblwidth"> <xsl:value-of select="." />*100<xsl:text>%</xsl:text> </xsl:variable> <xsl:attribute name="width"><xsl:value-of select="$tblwidth"/></xsl:attribute> </xsl:template> <xsl:template match="@rowspan"> <xsl:attribute name="rowspan"><xsl:value-of select="."/></xsl:attribute> </xsl:template> <xsl:template match="@colspan"> <xsl:attribute name="colspan"><xsl:value-of select="."/></xsl:attribute> </xsl:template> <xsl:template match="br"> <br /> </xsl:template> <xsl:template match="text()"> <xsl:value-of select="."/> </xsl:template>
■XML <tbl> <row> <cell colspan="3" width=".447">AAA</cell> <cell width=".138">1mg</cell> <cell width=".138">2mg</cell> <cell width=".138">4mg</cell> <cell width=".139">6mg</cell> </row> <row> <cell colspan="3" width=".447">BBB</cell> <cell width=".138">0.3mg/日</cell> <cell width=".138">0.6mg/日</cell> <cell width=".138">1.2mg/日</cell> <cell width=".139">1.8mg/日</cell> </row> <row> <cell rowspan="5" width=".149">CCC</cell> <cell rowspan="3" width=".149">DDD</cell> <cell width=".149">EEE</cell> <cell width=".138">≦29</cell> <cell width=".138">30~89</cell> <cell width=".138">90~149</cell> <cell width=".139">150~209</cell> </row> <row> <cell width=".149"></cell> <cell width=".149"></cell> <cell width=".149"></cell> <cell width=".138">≦10</cell> <cell width=".138">20~40</cell> <cell width=".138">50~70</cell> <cell width=".139">80~100</cell> </row> <row> <cell width=".149"></cell> <cell width=".149"></cell> <cell width=".149">GGG</cell> <cell width=".138">≦9</cell> <cell width=".138">10~29</cell> <cell width=".138">30~49</cell> <cell width=".139">50~69</cell> </row> <row> <cell width=".149"></cell> <cell colspan="2" width=".298">HHH</cell> <cell width=".138">≦19</cell> <cell width=".138">20~59</cell> <cell width=".138">60~99</cell> <cell width=".139">100~139</cell> </row> <row> <cell width=".149"></cell> <cell colspan="2" width=".298">III</cell> <cell width=".138">2.1</cell> <cell width=".138">4.2</cell> <cell width=".138">8.4</cell> <cell width=".139">12.6</cell> </row> </tbl>
###現状の変換結果および不要列の注記
■現状の変換結果および不要列の注記 <table border="1" width="100%" cellpadding="0" style="font:10pt"> <tr> <td width=".447*100%" colspan="3" >AAA</td> <td width=".138*100%">1mg</td> <td width=".138*100%">2mg</td> <td width=".138*100%">4mg</td> <td width=".139*100%">6mg</td> </tr> <tr> <td width=".447*100%" colspan="3" >BBB</td> <td width=".138*100%">0.3mg/日</td> <td width=".138*100%">0.6mg/日</td> <td width=".138*100%">1.2mg/日</td> <td width=".139*100%">1.8mg/日</td> </tr> <tr> <td rowspan="5" width=".149*100%">CCC</td> <td rowspan="3" width=".149*100%">DDD</td> <td width=".149*100%">EEE</td> <td width=".138*100%">≦29</td> <td width=".138*100%">30~89</td> <td width=".138*100%">90~149</td> <td width=".139*100%">150~209</td> </tr> <tr> <td width=".149*100%"></td> ←不要 <td width=".149*100%"></td> ←不要 <td width=".149*100%"></td> <td width=".138*100%">≦10</td> <td width=".138*100%">20~40</td> <td width=".138*100%">50~70</td> <td width=".139*100%">80~100</td> </tr> <tr> <td width=".149*100%"></td> ←不要 <td width=".149*100%"></td> ←不要 <td width=".149*100%">GGG</td> <td width=".138*100%">≦9</td> <td width=".138*100%">10~29</td> <td width=".138*100%">30~49</td> <td width=".139*100%">50~69</td> </tr> <tr> <td width=".149*100%"></td> ←不要 <td width=".298*100%" colspan="2" >HHH</td> <td width=".138*100%">≦19</td> <td width=".138*100%">20~59</td> <td width=".138*100%">60~99</td> <td width=".139*100%">100~139</td> </tr> <tr> <td width=".149*100%"></td> ←不要 <td width=".298*100%" colspan="2" >III</td> <td width=".138*100%">2.1</td> <td width=".138*100%">4.2</td> <td width=".138*100%">8.4</td> <td width=".139*100%">12.6</td> </tr> /table>
###補足情報(言語/FW/ツール等のバージョンなど)
対象ブラウザはIEのみ
XSLTプロセッサは何をお使いでしょうか?(MSXML,Saxon?など) XSLT 1.0なら大変ですが、XSLT 2.0が使えればまだ方策はあるように思えます.(それともこの問題自身がすでに解決済みでしょうか?)