This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: xsl unique position
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] xsl unique position
- From: David Carlisle <davidc at nag dot co dot uk>
- Date: Fri, 9 Mar 2001 13:37:26 GMT
- References: <20010309130133.2D8B136F9@sitemail.everyone.net>
- Reply-To: xsl-list at lists dot mulberrytech dot com
> I am losing the variable due to duplication
your example code doesn't use any variables.
<xsl:template match="Member">
<xsl:apply-templates select="*"/>
<xsl:element name="input">
<xsl:attribute name="type">hidden</xsl:attribute>
<xsl:attribute name="name">Member<xsl:value-of
select="position()"/><xsl:value-of select="position()"/></xsl:attribute>
<xsl:attribute name="value"></xsl:attribute>
</xsl:element><br/>
</xsl:template>
<xsl:template match="Name">
Name:
<xsl:element name="input">
<xsl:attribute name="type">text</xsl:attribute>
<xsl:attribute name="name">Name<xsl:value-of
select="position()"/></xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="."/></xsl:attribute>
</xsl:element><br/>
</xsl:template>
It's hard to see what's happening there as you've written it in the
longest form possible. The above is equivalent to
<xsl:template match="Member">
<xsl:apply-templates select="*"/>
<input type="hidden" name="Member{position()}{position()}" value=""/>
<br/>
</xsl:template>
<xsl:template match="Name">
Name:
<input type="text" name="Name{position()}" value="{.}"/>
<xsl:attribute name="type">text</xsl:attribute>
<br/>
</xsl:template>
there's various things you can use to generate unique names.
you could use name="{generate-id()}" but that may not give you very nice
names or name="Name{count(preceding::Name)}" etc.
David
(Did you mean to duplicate position() in the name of your member input
field ?)
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit
http://www.star.net.uk/stats.asp
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list