Sorting xsl:sort与前面的同级XSLT 1.0 xsl-FO muenchian xsl:key

Sorting xsl:sort与前面的同级XSLT 1.0 xsl-FO muenchian xsl:key,sorting,xslt-1.0,xsl-fo,muenchian-grouping,xslkey,Sorting,Xslt 1.0,Xsl Fo,Muenchian Grouping,Xslkey,我想访问排序列表中前面的兄弟姐妹。我使用的是Antenna House 6.2和XSLT1.0。我尝试将msxsl扩展用于node-set(),但调用node-set()失败。有人说,在1.0中无法访问排序列表中的前一个同级,还有人提到了Muenching分组和使用xsl:key,所以我现在正在尝试。我看了这一页: 该表已正确排序,但我还无法找出如何使用键检索已排序列表的前一个同级。我需要更多的钥匙吗?我在partNumberValue上排序,然后是figureNumber,figureNumb

我想访问排序列表中前面的兄弟姐妹。我使用的是Antenna House 6.2和XSLT1.0。我尝试将msxsl扩展用于
node-set()
,但调用
node-set()
失败。有人说,在1.0中无法访问排序列表中的前一个同级,还有人提到了Muenching分组和使用
xsl:key
,所以我现在正在尝试。我看了这一页:

该表已正确排序,但我还无法找出如何使用键检索已排序列表的前一个同级。我需要更多的钥匙吗?我在
partNumberValue
上排序,然后是
figureNumber
figureNumber
可能有一个
figureNumberVariant
。如有任何建议,我们将不胜感激

XML:


...
在
GGACC空气阀总成
A.
射频
JJACC空气阀总成
B
1.
铭牌盖
...
应收账
锁线
1.
盾
2.
螺丝钉
XSLT:


部分
数字
无花果
不
项目
不
数量。
预期产出:

<fo:table-row>
        <fo:table-cell><fo:block>1025-129</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 02</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 050</fo:block></fo:table-cell>
        <fo:table-cell><fo:block>1</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
        <fo:table-cell><fo:block>1476-3248-1</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 02 02</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 040</fo:block></fo:table-cell>
        <fo:table-cell><fo:block>1</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
        <fo:table-cell><fo:block>2079-1302-1</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 01 02</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 000</fo:block></fo:table-cell>
        <fo:table-cell><fo:block>1</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
        <fo:table-cell><fo:block>3082-1604-1</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 01 01</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 010</fo:block></fo:table-cell>
        <fo:table-cell><fo:block>1</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
        <fo:table-cell><fo:block>63358</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 02 01</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 030</fo:block></fo:table-cell>
        <fo:table-cell><fo:block>1</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
        <fo:table-cell><fo:block>8910-276</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 01 02</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 000</fo:block></fo:table-cell>
        <fo:table-cell><fo:block>1</fo:block></fo:table-cell>
</fo:table-row> 
<fo:table-row>
        <fo:table-cell><fo:block>8910-281</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 01 01</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 001</fo:block></fo:table-cell>
        <fo:table-cell><fo:block>1</fo:block></fo:table-cell>
</fo:table-row>

1025-129
02
 050
1.
1476-3248-1
02 02
 040
1.
2079-1302-1
01 02
 000
1.
3082-1604-1
01 01
 010
1.
63358
02 01
 030
1.
8910-276
01 02
 000
1.
8910-281
01 01
 001
1.
如果
node-set()
不起作用,则需要再次进行排序以获取上一项:

<xsl:key name="all" match="catalogSeqNumber" use="true()" />

<xsl:template name="SortParts">
  <xsl:apply-templates
      select="catalogSeqNumber[key('kfigNo', @figureNumber)]">
      <xsl:sort select="itemSeqNumber/partRef/@partNumberValue"/>
      <xsl:sort select="@figureNumber"/>
      <xsl:sort select="@item"/>
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="catalogSeqNumber">
  <xsl:variable
      name="figNo"
      select="concat(@figureNumber,@figureNumberVariant)"/>
  <xsl:variable name="current-position" select="position()"/>
  <xsl:variable name="prfigNo">
    <xsl:for-each select="key('all', true())">
      <xsl:sort select="itemSeqNumber/partRef/@partNumberValue"/>
      <xsl:sort select="@figureNumber"/>
      <xsl:sort select="@item"/>
      <xsl:if test="position() = $current-position - 1">
        <xsl:value-of select="concat(@figureNumber,@figureNumberVariant)" />
      </xsl:if>
    </xsl:for-each>
  </xsl:variable>
  <fo:table-row>
    <fo:table-cell padding="3pt">
      <fo:block>
        <xsl:value-of
            select="itemSeqNumber/partRef/@partNumberValue"/>
      </fo:block>
    </fo:table-cell>
    <fo:table-cell padding="3pt">
      <fo:block>
        <xsl:if test="$figNo">
          <xsl:text> </xsl:text>
          <xsl:value-of select="$figNo"/>
          <xsl:text> </xsl:text>
          <xsl:value-of select="$prfigNo"/>
        </xsl:if>
      </fo:block> 
    </fo:table-cell>
    <fo:table-cell padding="3pt">
      <fo:block>
        <xsl:value-of select="concat(@item,@itemVariant)"/>
      </fo:block>
    </fo:table-cell>
    <fo:table-cell padding="3pt">
      <fo:block>
        <xsl:value-of
            select="itemSeqNumber/quantityPerNextHigherAssy"/>
      </fo:block>
    </fo:table-cell>
  </fo:table-row>
</xsl:template>


您的示例显示了一个充实的
catalogSeqNumber
,但问题、排序和结果似乎取决于至少有两个
catalogSeqNumber
。您是否可以再添加至少一个
catalogSeqNumber
,其中包含足够的信息以生成结果并显示结果表行应包含的内容?我已经更新了问题,谢谢您,Tony。可能重复的
select=“catalogSeqNumber[key('kfigNo',@figureNumber)]”
对我来说没有意义。XML中的每个
catalogSeqNumber
都有一个
@figureNumber
,并且该
@figureNumber
将始终有一个从
键()查找返回的值,因此您仍然选择了每个
catalogSeqNumber
。如果要对三件事进行排序,请使用三个单独的
xsl:sort
,例如:
<fo:table-row>
        <fo:table-cell><fo:block>1025-129</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 02</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 050</fo:block></fo:table-cell>
        <fo:table-cell><fo:block>1</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
        <fo:table-cell><fo:block>1476-3248-1</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 02 02</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 040</fo:block></fo:table-cell>
        <fo:table-cell><fo:block>1</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
        <fo:table-cell><fo:block>2079-1302-1</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 01 02</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 000</fo:block></fo:table-cell>
        <fo:table-cell><fo:block>1</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
        <fo:table-cell><fo:block>3082-1604-1</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 01 01</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 010</fo:block></fo:table-cell>
        <fo:table-cell><fo:block>1</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
        <fo:table-cell><fo:block>63358</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 02 01</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 030</fo:block></fo:table-cell>
        <fo:table-cell><fo:block>1</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
        <fo:table-cell><fo:block>8910-276</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 01 02</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 000</fo:block></fo:table-cell>
        <fo:table-cell><fo:block>1</fo:block></fo:table-cell>
</fo:table-row> 
<fo:table-row>
        <fo:table-cell><fo:block>8910-281</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 01 01</fo:block></fo:table-cell>
        <fo:table-cell><fo:block> 001</fo:block></fo:table-cell>
        <fo:table-cell><fo:block>1</fo:block></fo:table-cell>
</fo:table-row>
<xsl:key name="all" match="catalogSeqNumber" use="true()" />

<xsl:template name="SortParts">
  <xsl:apply-templates
      select="catalogSeqNumber[key('kfigNo', @figureNumber)]">
      <xsl:sort select="itemSeqNumber/partRef/@partNumberValue"/>
      <xsl:sort select="@figureNumber"/>
      <xsl:sort select="@item"/>
  </xsl:apply-templates>
</xsl:template>

<xsl:template match="catalogSeqNumber">
  <xsl:variable
      name="figNo"
      select="concat(@figureNumber,@figureNumberVariant)"/>
  <xsl:variable name="current-position" select="position()"/>
  <xsl:variable name="prfigNo">
    <xsl:for-each select="key('all', true())">
      <xsl:sort select="itemSeqNumber/partRef/@partNumberValue"/>
      <xsl:sort select="@figureNumber"/>
      <xsl:sort select="@item"/>
      <xsl:if test="position() = $current-position - 1">
        <xsl:value-of select="concat(@figureNumber,@figureNumberVariant)" />
      </xsl:if>
    </xsl:for-each>
  </xsl:variable>
  <fo:table-row>
    <fo:table-cell padding="3pt">
      <fo:block>
        <xsl:value-of
            select="itemSeqNumber/partRef/@partNumberValue"/>
      </fo:block>
    </fo:table-cell>
    <fo:table-cell padding="3pt">
      <fo:block>
        <xsl:if test="$figNo">
          <xsl:text> </xsl:text>
          <xsl:value-of select="$figNo"/>
          <xsl:text> </xsl:text>
          <xsl:value-of select="$prfigNo"/>
        </xsl:if>
      </fo:block> 
    </fo:table-cell>
    <fo:table-cell padding="3pt">
      <fo:block>
        <xsl:value-of select="concat(@item,@itemVariant)"/>
      </fo:block>
    </fo:table-cell>
    <fo:table-cell padding="3pt">
      <fo:block>
        <xsl:value-of
            select="itemSeqNumber/quantityPerNextHigherAssy"/>
      </fo:block>
    </fo:table-cell>
  </fo:table-row>
</xsl:template>