Subject: Re: [xsl] Creating Hierarchy From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Fri, 17 Oct 2008 11:52:34 -0400 |
At 2008-10-17 13:47 +0100, Rowan Sylvester-Bradley wrote:You'll find a description of an XSLT 2.0 stylesheet that does this (and some other things besides) at
http://www.idealliance.org/proceedings/xml04/papers/111/mhk-paper.html
Michael Kay http://www.saxonica.com/
Thanks to Michael and Ken for your replies. I've now got it more or less working using xsl:for-each-group. However, I've got another problem that I can't quite work out. Each of the main elements in the result file needs to have a unique ID attribute.
An ID attribute value must be a name token, so your "1","2",... won't be correct. But you could use something like "N1","N2",...
I.e. the id attributes just keep incrementing regardless of the hierarchy.
How do I generate the values of these id attributes?
Assuming the current node is <node>, then <xsl:number/> can be used without attributes to count the current node amongst its siblings in the source tree:
<xsl:attribute name="id">N<xsl:number/></xsl:attribute>
Cheers, Wendell
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Creating Hierarchy, G. Ken Holman | Thread | [xsl] Identifier attribute (was: Re, G. Ken Holman |
Re: [xsl] zero width no-break space, Wendell Piez | Date | [xsl] Identifier attribute (was: Re, G. Ken Holman |
Month |