[Home] [By Thread] [By Date] [Recent Entries]
On 5/22/07, J. S. Rawat <jrawat@xxxxxxxxxxxxxx> wrote:
Lot of thanks for your nice clue !!! I have written <xsl:strip-space elements="*"/> and it is working fine.
An alternative approach is to only select the nodes you want to process, eg replace: <xsl:template match="contrib-group"> <contributors> <xsl:apply-templates/> </contributors> </xsl:template>
Then position() will work as expected. Another alternatively is to replace position() with count(preceding-sibling::contrib) which will only count <contrib> elements, ignoring the whitespace presentational nodes between each element. Another alternative is to control the flow differently - apply-templates to the first <contrib> element and output markup specific to the first, then apply-templates to the rest. This is achieved easily with a mode, eg: <xsl:template match="contrib-group"> <contributors> <xsl:apply-templates select="contrib[1]" mode="first"/> </contributors> </xsl:template> <xsl:template match="contrib" mode="first"> <person_name sequence="first" contributor_role="author"> <xsl:apply-templates select="name"/> </person_name> <xsl:apply-templates select="following-sibling::contrib"/> </xsl:template> <xsl:template match="contrib"> <person_name sequence="additional" contributor_role="author"> <xsl:apply-templates select="name"/> </person_name> </xsl:template> However as both variations are identical other than the @sequence then I'd just use an AVT, eg. sequence="{if (not(preceding-sibling::contrib)) then 'first' else 'additional'}" cheers andrew
|

Cart



