Xml 增量计数变量
输入: XSL:Xml 增量计数变量,xml,xslt,Xml,Xslt,输入: XSL: 在当前的XSL中,我需要在标记之后有一个标记,在该标记中,我必须计数(从1开始)并增加,当然,在for each中选择的操作标记的数量 因此,所需的输出: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes" /> <xsl:strip-space elements
在当前的XSL中,我需要在
标记之后有一个标记
,在该标记中,我必须计数(从1开始)并增加,当然,在for each中选择的操作标记的数量
因此,所需的输出:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="trip">
<xsl:variable name="ID">
<xsl:value-of select="code"/>
</xsl:variable>
<xsl:variable name="Date">
<xsl:value-of select="substring-before(from_instant,'T')"/>
</xsl:variable>
<trip>
<ID>
<xsl:value-of select="$ID"/>
</ID>
<Date>
<xsl:value-of select="$Date"/>
</Date>
<xsl:for-each select="section/action[action_kind/code = 'P']|section/action[action_kind/code = 'D']">
<xsl:variable name="Order_Key">
<xsl:value-of select="action_kind/code"/>
</xsl:variable>
<xsl:variable name="address">
<xsl:value-of select="addressId"/>
</xsl:variable>
<xsl:if test="$address != 'CAV'">
<ordini>
<order_Key>
<xsl:value-of select="$Order_Key"/>
</order_Key>
</ordini>
</xsl:if>
</xsl:for-each>
</trip>
</xsl:template>
</xsl:stylesheet>
3295
2018-07-30
1.
2.
我在trip标签或ordini标签中输出了更多变量,但与我的问题无关。
另外,请不要有多个标签,所以我需要他们在输出中的所有
<root>
<trip>
<ID>3295</ID>
<Date>2018-07-30</Date>
<ordini>
<order_Key/>
<number>1</number>
</ordini>
<ordini>
<order_Key/>
<number>2</number>
</ordini>
</trip>
</root>
。。。。。。等等
我在for each中尝试了position、number、count,但得到了一个空xsl
请帮忙,谢谢 请提供最少但完整的XML和XSLT示例,以及所需和当前输出,以演示问题。您使用的变量
$address
甚至没有声明。getAdditionalOrderINfo不相关,您也可以忽略它,XML更大(我在根标记后面放了一条注释,还有一些其他信息包括这个)。已编辑以包含我忘记包含的addressId:)。此外,编辑以引用另一个标记[用于Aniket V[
<root>
<trip>
<ID>3295</ID>
<Date>2018-07-30</Date>
<ordini>
<order_Key/>
<number>1</number>
</ordini>
<ordini>
<order_Key/>
<number>2</number>
</ordini>
</trip>
</root>
<root><trip>...</trip><trip>...</trip> and so on </root>