[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Using COUNT to create unique anchors

Subject: RE: Using COUNT to create unique anchors
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 27 Nov 2006 22:01:57 -0000
how to create unique number
I'm not sure what your input is (haven't been following the thread closely).
xsl:number says that in the absence of a count attribute, it only counts
nodes at each level that have the same name as the context node. I would
expect to fix your problem by changing the "count" attribute, but I can't
account for your current output.

Michael Kay
http://www.saxonica.com/ 


> -----Original Message-----
> From: Austin, Darrel [mailto:Darrel.Austin@xxxxxxxxxxxxxxxxxx] 
> Sent: 27 November 2006 21:18
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Using COUNT to create unique anchors
> 
> > the code I posted didn't require that, it generated a 
> unique id using 
> > xsl:number. The trick with cross referencing in xslt is to always 
> > generate the id on the _referenced_ node
> 
> D'oh! Yep, my mistake. I wasn't referencing the same nodes. 
> 
> So, I'm liking the xsl:number a bit better than the 
> generate-ID, only because it seems to reflect the hierarchy a 
> bit better.
> 
> Follow-up question:
> 
> This is my XSL:
> 
> <xsl:for-each select="ruleItem">
> 
> 	<xsl:variable name="id">
> 		<xsl:number level="multiple"/>
> 	</xsl:variable>
> 
> 	<li><a href="#id{$id}"><xsl:value-of select="number" />:
> <xsl:value-of select="title" /></a>
> 		<xsl:if test="ruleItem">
> 			<ul>
> 				<xsl:call-template name="rulelistTOC" />
> 			</ul>
> 		</xsl:if>
> 	</li>
> </xsl:for-each>
> 
> The output (numbering) of this looks like this:
> 
> 1.1
> 1.2
>   1.2.1
>   1.2.2
> 1.3
> 
> This is OK, but I'd prefer:
> 
> 1
> 2
>   2.1
>   2.2
> 3
> 
> I assume it does the former because every node is a child of 
> the parent node of the document. As such, there maybe isn't 
> away around that?
> 
> -Darrel

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.