hi friends
i am new user.
i am in the process of collecting the main content and number of title from the input XML with XSLT.
I have doubt in variable increament. how to increamtent variable ?
this is my xml:
i expect output to be like this:
this is my xslt:
thanks in adv
saran
i am new user.
i am in the process of collecting the main content and number of title from the input XML with XSLT.
I have doubt in variable increament. how to increamtent variable ?
this is my xml:
Code:
<chunk-meta><title km="Pt.Ttl">PT</title></chunk-meta> <chunk-meta><title km="At.Ttl">no need</title></chunk-meta> <float><meta><title km="Ch.Ttl">CT</title></meta></float> <float><meta><title km="N.Ttl">no need</title></meta></float> <float-meta><meta><title km="H1.Ttl">HT</title></meta></float-meta>
Code:
<title km="Pt.Ttl">PT</title><no>1</no> <title km="Ch.Ttl">CT</title><no>2</no> <title km="H1.Ttl">HT</title><no>3</no>
this is my xslt:
Code:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> <xsl:template match="/"> <xsl:variable name="a" select="1"/> <xsl:for-each select="//"> <xsl:if test="title/@km[contains(.,'Pt.T')]"> <xsl:copy-of select="title"/><no><xsl:copy-of select="$a"/></xsl:if> <xsl:if test="title/@km[contains(.,'Ch.Ttl')]"><xsl:variable name="b" select="$a+1"/> <xsl:copy-of select="title"/><no><xsl:copy-of select="$b"/></xsl:if> <xsl:if test="title/@km[contains(.,'H1.Ttl')]"> <xsl:variable name="c" select="$b+1"/><xsl:copy-of select="title"/><no><xsl:copy-of select="$c"/></xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet>
thanks in adv
saran
Comment