tesmc
asked on
XSLT: how to increment number value if attribute present
i have the following input
<xml>
<Flight ID="F1">
<Flight ID="F2">
<Flight ID="F3" AddNew="Yes">
<Flight ID="F4">
</xml>
I want my output to read:
<xml>
<Flight ID="1"/>
<Flight ID="2"/>
<Flight ID="4"/>
<Flight ID="5"/>
</xml>
I have following xsl .which loops through each @ID and builds the ID by grabbing number after 'F'. And this is ok but I want to increment the number if AddNew="Yes" exists.
<xsl:variable name="Seg" select="//Flight/@ID"/>
<xsl:for-each select="$Seg">
<xsl:variable name="ID">
<xsl:value-of select="substring-after(cu rrent(), 'F')"/>
</xsl:variable>
<xsl:attribute name="ID" >
<xsl:value-of select="$ID"/>
</xsl:attribute>
.....
<xml>
<Flight ID="F1">
<Flight ID="F2">
<Flight ID="F3" AddNew="Yes">
<Flight ID="F4">
</xml>
I want my output to read:
<xml>
<Flight ID="1"/>
<Flight ID="2"/>
<Flight ID="4"/>
<Flight ID="5"/>
</xml>
I have following xsl .which loops through each @ID and builds the ID by grabbing number after 'F'. And this is ok but I want to increment the number if AddNew="Yes" exists.
<xsl:variable name="Seg" select="//Flight/@ID"/>
<xsl:for-each select="$Seg">
<xsl:variable name="ID">
<xsl:value-of select="substring-after(cu
</xsl:variable>
<xsl:attribute name="ID" >
<xsl:value-of select="$ID"/>
</xsl:attribute>
.....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you for your help.
ASKER
Yes that worked fine.
can you explain count(preceding-sibling::F