我想访问排序列表中的前兄弟姐妹。我使用Antenna House 6.2和XSLT 1.0。我尝试使用msxsl扩展名node-set()
,但拨打node-set()
失败。有人说,访问排序列表中的前兄弟不能在1.0中完成,其他人提到Muenching Grouping和使用xsl:key
,所以我现在正在尝试。我已阅读此页:http://www.jenitennison.com/xslt/grouping/muenchian.htmlxsl:与前同胞XSLT 1.0排序XSL-FO muenchian xsl:key
该表排序正确,但我一直无法弄清楚如何使用键检索排序列表的前一兄弟。我需要更多的钥匙吗?我正在对partNumberValue
进行排序,然后figureNumber
和figureNumber
可能有figureNumberVariant
。任何建议表示赞赏。
XML:
<illustratedPartsCatalog>
<figure id="fig1">...</figure>
<catalogSeqNumber assyCode="05" figureNumber="01" indenture="0" item="000" subSubSystemCode="1" subSystemCode="1" systemCode="15">
<itemSeqNumber itemSeqNumberValue="00A">
<quantityPerNextHigherAssy>AT</quantityPerNextHigherAssy>
<partRef manufacturerCodeValue="" partNumberValue="8910-276">
</partRef>
<partSegment>
<itemIdentData>
<descrForPart>GGACC AIR VALVE ASSEMBLY</descrForPart></itemIdentData>
</partSegment><applicabilitySegment><usableOnCodeAssy>A</usableOnCodeAssy>
</applicabilitySegment></itemSeqNumber></catalogSeqNumber>
<catalogSeqNumber assyCode="05" figureNumber="01" indenture="0" item="001" itemVariant="A" subSubSystemCode="1" subSystemCode="2" systemCode="15">
<itemSeqNumber itemSeqNumberValue="00A">
<quantityPerNextHigherAssy>RF</quantityPerNextHigherAssy>
<partRef manufacturerCodeValue="" partNumberValue="8910-281">
</partRef>
<partSegment>
<itemIdentData>
<descrForPart>JJACC AIR VALVE ASSEMBLY</descrForPart></itemIdentData>
</partSegment><applicabilitySegment><usableOnCodeAssy>B</usableOnCodeAssy>
</applicabilitySegment></itemSeqNumber></catalogSeqNumber>
<catalogSeqNumber assyCode="05" figureNumber="01" indenture="1" item="000" subSubSystemCode="1" subSystemCode="1" systemCode="1">
<itemSeqNumber itemSeqNumberValue="00A">
<quantityPerNextHigherAssy>1</quantityPerNextHigherAssy>
<partRef manufacturerCodeValue="" partNumberValue="2079-1302-1">
</partRef>
<partSegment>
<itemIdentData>
<descrForPart>NAMEPLATE COVER</descrForPart></itemIdentData>
</partSegment>
<partLocationSegment>
<attachStoreShipPart attachStoreShipPartCode="1"/></partLocationSegment>
</itemSeqNumber></catalogSeqNumber>
<figure id="fig2">...</figure>
<catalogSeqNumber assyCode="05" figureNumber="02" indenture="1" item="030" subSubSystemCode="1" subSystemCode="2" systemCode="15">
<itemSeqNumber itemSeqNumberValue="00A">
<quantityPerNextHigherAssy>AR</quantityPerNextHigherAssy>
<partRef manufacturerCodeValue="" partNumberValue="63358">
</partRef>
<partSegment>
<itemIdentData>
<descrForPart>LOCK WIRE</descrForPart></itemIdentData></partSegment>
</itemSeqNumber></catalogSeqNumber>
<catalogSeqNumber assyCode="05" figureNumber="02" indenture="1" item="040" subSubSystemCode="1" subSystemCode="2" systemCode="15">
<itemSeqNumber itemSeqNumberValue="00A">
<quantityPerNextHigherAssy>1</quantityPerNextHigherAssy>
<partRef manufacturerCodeValue="" partNumberValue="1476-3248-1">
</partRef>
<partSegment>
<itemIdentData>
<descrForPart>SHIELD</descrForPart></itemIdentData></partSegment>
</itemSeqNumber></catalogSeqNumber>
<catalogSeqNumber assyCode="05" figureNumber="02" indenture="1" item="050" subSubSystemCode="1" subSystemCode="2" systemCode="15">
<itemSeqNumber itemSeqNumberValue="00A">
<quantityPerNextHigherAssy>2</quantityPerNextHigherAssy>
<partRef manufacturerCodeValue="" partNumberValue="1025-129">
</partRef>
<partSegment>
<itemIdentData>
<descrForPart>SCREW</descrForPart></itemIdentData></partSegment>
<partLocationSegment>
<attachStoreShipPart attachStoreShipPartCode="1"/></partLocationSegment>
</itemSeqNumber></catalogSeqNumber>
</illustratedPartsCatalog>
XSLT:
<xsl:key name="kfigNo" match="catalogSeqNumber" use="@figureNumber" />
<xsl:template match="illustratedPartsCatalog">
<xsl:apply-templates />
<fo:table>
<fo:table-header>
<fo:table-row>
<fo:table-cell>
<fo:block>PART</fo:block>
<fo:block>NUMBER</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>FIG</fo:block>
<fo:block>NO.</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>ITEM</fo:block>
<fo:block>NO.</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>QTY.</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<xsl:call-template name="SortParts"/>
</fo:table-body>
</fo:table>
</xsl:template>
<xsl:template name="SortParts">
<xsl:for-each select="catalogSeqNumber[key('kfigNo', @figureNumber)]">
<xsl:sort select="concat(itemSeqNumber/partRef/@partNumberValue, @figureNumber,@item)"/>
<xsl:call-template name="catalogSeqNumber-NI">
<xsl:with-param name="figNo" select="concat(@figureNumber,@figureNumberVariant)"/>
<xsl:with-param name="prfigNo" select="concat(preceding-sibling::catalogSeqNumber/@figureNumber,preceding-sibling::catalogSeqNumber/@figureNumberVariant)" />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="catalogSeqNumber-NI">
<xsl:param name="figNo"/>
<xsl:param name="prfigNo" />
<fo:table-row>
<fo:table-cell>
<fo:block>
<xsl:value-of select=" ./itemSeqNumber/partRef/@partNumberValue"/>
</fo:block>
</fo:table-cell>
<fo:table-cell>
<xsl:choose>
<xsl:when test="$figNo">
<fo:block>
<xsl:text> </xsl:text><xsl:value-of select="$figNo"/><xsl:text> </xsl:text> <xsl:value-of select="$prfigNo"/>
</fo:block>
</xsl:when>
<xsl:otherwise>
<fo:block />
</xsl:otherwise>
</xsl:choose>
</fo:table-cell>
<fo:table-cell>
<fo:block> <xsl:value-of select="concat(@item,@itemVariant)"/> </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block>
<xsl:value-of select="./itemSeqNumber/quantityPerNextHigherAssy"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
预期输出:
<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>
你的例子显示了一个实体'catalogSeqNumber',但问题,排序和结果似乎取决于至少有两个'catalogSeqNumber'。你是否至少可以添加一个'catalogSeqNumber',它有足够的信息来产生一个结果,并且显示结果表行应该包含什么? –
我已经更新了这个问题,谢谢,Tony。 – Caroline
[选择下面的排序节点的兄弟节点]的可能的副本(http://stackoverflow.com/questions/38516360/selecting-the-following-sibling-of-a-sorted-node) –