[英]Marklogic XSLT 2.0 bug with grouping (starting-with)
我正在使用xdmp:xslt-invoke()
来转换 Marklogic 中的文档。 效果很好,但是今天我在使用<xsl:for-each-group select="..." group-starting-with="...">
时遇到了问题(而使用group-adjacent
在其他部分按预期工作我的 XSLT)
XML 输入
<DOC>
<AL>
<TABLEAU FILET="1" FRAME="ALL" ID="L90F6543EAA5E12-EFL">
<TGROUP COLS="2">
<COLSPEC COLNAME="COL1" COLNUM="1"/>
<COLSPEC COLNAME="COL2" COLNUM="2"/>
<TBODY>
<ROW>
<ENTRY ALIGN="CENTER" COLNAME="COL1" COLSEP="1" ROWSEP="1" VALIGN="TOP">
<AL>
<MOTREP>Éléments à inclure dans l'assiette</MOTREP>
</AL>
</ENTRY>
<ENTRY ALIGN="CENTER" COLNAME="COL2" COLSEP="1" ROWSEP="1" VALIGN="TOP">
<AL>
<MOTREP>Éléments exclus de l'assiette</MOTREP>
</AL>
</ENTRY>
</ROW>
</TBODY>
</TGROUP>
</TABLEAU>
</AL>
</DOC>
XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.0">
<xsl:template match="AL">
<xsl:variable name="self" as="element()" select="."/>
<xsl:for-each-group select="node()" group-starting-with="LST | TABLEAU">
<xsl:choose>
<xsl:when test="local-name(current-group()[1]) = ('LST', 'TABLEAU')">
<xsl:apply-templates select="current-group()" mode="#current"/>
</xsl:when>
<xsl:otherwise>
<AL>
<xsl:apply-templates select="current-group()" mode="#current"/>
</AL>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:template>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
XML output 与撒克逊 HE 9.8.0.12
<DOC>
<TABLEAU FILET="1" FRAME="ALL" ID="L90F6543EAA5E12-EFL">
<TGROUP COLS="2">
<COLSPEC COLNAME="COL1" COLNUM="1"/>
<COLSPEC COLNAME="COL2" COLNUM="2"/>
<TBODY>
<ROW>
<ENTRY ALIGN="CENTER" COLNAME="COL1" COLSEP="1" ROWSEP="1" VALIGN="TOP">
<AL xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<MOTREP>Éléments à inclure dans l'assiette</MOTREP>
</AL>
</ENTRY>
<ENTRY ALIGN="CENTER" COLNAME="COL2" COLSEP="1" ROWSEP="1" VALIGN="TOP">
<AL xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<MOTREP>Éléments exclus de l'assiette</MOTREP>
</AL>
</ENTRY>
</ROW>
</TBODY>
</TGROUP>
</TABLEAU>
</DOC>
XML output 与 Marklogic 10.0-3 XSLT 处理器
<DOC>
<TABLEAU FRAME="ALL" ID="L90F6543EAA5E12-EFL">
<TGROUP COLS="2">
<TBODY>
<ROW>
<ENTRY ALIGN="CENTER" COLNAME="COL1" COLSEP="1" ROWSEP="1" VALIGN="TOP">
<TABLEAU FRAME="ALL" ID="L90F6543EAA5E12-EFL">
<TGROUP COLS="2">
<TBODY>
<ROW>
<ENTRY ALIGN="CENTER" COLNAME="COL1" COLSEP="1" ROWSEP="1" VALIGN="TOP">
<AL xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<MOTREP>Éléments à inclure dans l'assiette test1</MOTREP>
</AL>
</ENTRY>
<ENTRY ALIGN="CENTER" COLNAME="COL2" COLSEP="1" ROWSEP="1" VALIGN="TOP">
<AL xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<MOTREP>Éléments exclus de l'assiette</MOTREP>
</AL>
</ENTRY>
</ROW>
</TBODY>
</TGROUP>
</TABLEAU>
</ENTRY>
<ENTRY ALIGN="CENTER" COLNAME="COL2" COLSEP="1" ROWSEP="1" VALIGN="TOP">
<TABLEAU FRAME="ALL" ID="L90F6543EAA5E12-EFL">
<TGROUP COLS="2">
<TBODY>
<ROW>
<ENTRY ALIGN="CENTER" COLNAME="COL1" COLSEP="1" ROWSEP="1" VALIGN="TOP">
<AL xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<MOTREP>Éléments à inclure dans l'assiette test1</MOTREP>
</AL>
</ENTRY>
<ENTRY ALIGN="CENTER" COLNAME="COL2" COLSEP="1" ROWSEP="1" VALIGN="TOP">
<AL xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<MOTREP>Éléments exclus de l'assiette</MOTREP>
</AL>
</ENTRY>
</ROW>
</TBODY>
</TGROUP>
</TABLEAU>
</ENTRY>
</ROW>
</TBODY>
</TGROUP>
</TABLEAU>
</DOC>
它看起来像一个错误还是我错过了什么?
在此先感谢,马蒂厄·里考德-杜萨吉
当您在xsl:for-each-group
内部使用<xsl:apply-templates select="current-group()">
时,似乎确实有些东西正在流血并且上下文变得混乱。
这似乎是一个错误,其中在将xsl:apply-templates
用于current-group()
时,意外内容被传送到 output 。
如果您在xsl:when
中更改为xsl:copy-of
:
<xsl:when test="local-name(current-group()[1]) = ('LST', 'TABLEAU')">
<xsl:copy-of select="current-group()" />
</xsl:when>
那么它就不会产生额外的TABLEAU
元素和子元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.