この問題は、シートの基になるデータ構造の table:table-cell 要素に対する number-columns-repeated 属性が原因です。詳細については、 http://user.services.openoffice.org/en/forum/viewtopic.php?f=45& t= 29674およびhttp://user.services.openoffice.org/en/forum/viewtopicを参照してください。 .php?f=9&t=11865 .
後者のリンクは問題を解決したと主張していますが、解決策は私が探していたものではありません. より柔軟な xml 生成を可能にする単純なインデックス ベースのソリューションが必要でした。これが私が解決しようとしたものです。
ユーザー定義関数を利用するために xslt 2.0 を使用しました。ここにスタイルシートがあります...
<xsl:output method="xml" indent="yes" encoding="UTF-8" omit-xml-declaration="no"/>
<xsl:function name="my:getColumnValue">
<xsl:param name="tableRow" as="node()"/>
<xsl:param name="colIndex"/>
<xsl:param name="currentIndex"/>
<xsl:choose>
<xsl:when test="$currentIndex < $colIndex">
<xsl:variable name="repeatColumns" select="$tableRow/table:table-cell[$currentIndex]/@table:number-columns-repeated"/>
<xsl:choose>
<xsl:when test="$repeatColumns">
<xsl:choose>
<xsl:when test="$currentIndex + $repeatColumns - 1 >= $colIndex"><xsl:value-of select="$tableRow/table:table-cell[$currentIndex]"/></xsl:when>
<xsl:otherwise><xsl:value-of select="my:getColumnValue($tableRow, $colIndex - $repeatColumns + 1, $currentIndex + 1)"/></xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise><xsl:value-of select="my:getColumnValue($tableRow, $colIndex, $currentIndex + 1)"/></xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$tableRow/table:table-cell[$colIndex]"/></xsl:otherwise>
</xsl:choose>
</xsl:function>
<xsl:template match="//table:table">
<Tests>
<!-- Process all table rows -->
<xsl:variable name="colCount" select="count(table:table-row[1]/table:table-cell)"/>
<xsl:for-each select="table:table-row">
<xsl:if test="position() > 1">
<Test>
<SrNo><xsl:value-of select="my:getColumnValue(.,1,1)"/></SrNo>
<Name><xsl:value-of select="my:getColumnValue(.,2,1)"/></Name>
<Age><xsl:value-of select="my:getColumnValue(.,3,1)"/></Age>
<Height><xsl:value-of select="my:getColumnValue(.,4,1)"/></Height>
<Address><xsl:value-of select="my:getColumnValue(.,5,1)"/></Address>
</Test>
</xsl:if>
</xsl:for-each>
</Tests>
</xsl:template>
上記で使用されているタグは単なるプレースホルダーです。xslt 内の適切なものに置き換えてください。このソリューションは、xslt プロセッサによって許可される再帰呼び出しの数によって制限されます。
xslt 1.0 が送信ノードをパラメーターとしてサポートしている場合、上記の udf を置き換えて、テンプレート ベースのソリューションを取得できます。バグを見つけたら、私に知らせてください。