如果第一行项为2,第二行项为3,则bbb信息显示值应等于qty。如果第一行项为2,第二行项为3,则bbb信息显示值应等于qty。
If qty is 2 at first line item and 3 at second line item, the values of bbb info displaying should be equals to qty.
预期产出应为: qty 2 bbb 1111 2222 qty 3 bbb 3333 4444 5555
'''
<?xml version="1.0" encoding="Windows-1252" standalone="no"?>
<xyz>
<ddd>
<abc>
<!-- First line item -->
<aaa qty = "2" />
</abc>
<abc>
<!-- Second line item -->
<aaa qty = "3" />
</abc>
</ddd>
<bbb serial = "1111"/>
<bbb serial = "2222"/>
<bbb serial = "3333"/>
<bbb serial = "4444"/>
<bbb serial = "5555"/>
</xyz>
'''
'''
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match = "xyz/ddd" >
<xsl:for-each select="abc">
<!--<xsl:value-of select="aaa/@qty"/>-->
<xsl:variable name="loop">
<xsl:for-each select="ancestor::xyz/bbb">
<xsl:value-of select="concat(@serial,',')"/>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="$loop"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
'''
If qty is 2 at first line item and 3 at second line item, the values of bbb info displaying should equals to qty.
qty 2 bbb 1111 2222
qty 3 bbb 3333 4444 5555
发布于 2022-07-09 09:07:29
您还没有说明您想使用什么技术,但是在XSLT3.0中您可以这样做
<xsl:iterate select="//aaa/@qty">
<xsl:param name="start" select="1"/>
<qty count="{.}">
<xsl:copy-of select="subsequence(//bbb, $start, xs:integer(.))"/>
<xsl:next-iteration>
<xsl:with-param name="start" select="xs:integer(.)"/>
</xsl:next-iteration>
</qty>
</xsl:iterate>
https://stackoverflow.com/questions/72919676
复制