Re: [xsl] generate-id for identical elements

Subject: Re: [xsl] generate-id for identical elements
From: "Anton Triest" <anton@xxxxxxxx>
Date: Thu, 23 Sep 2004 20:44:45 +0200
Jay Bryant wrote:
>
> My concern is not how to get generate-id to accept a string as a path 
> (though I would be curious about that). My concern is to be able to create 
> cross-references to identical elements (that do have different parent 
> elements). I have total control over the XML input and the XSL stylesheet, 
> so I am open to ANY idea that will get the job done.

Hi Jay,

if you have control over the input, couldn't you add an id
to the elements you want to reference, something like

   <chapter title="Chapter 2" id="c2">
     <topic title="Introduction" id="c2-intro"/>
   </chapter>
   <chapter title="Chapter 3" id="c3">
     <topic title="Introduction" id="c3-intro"/>
   </chapter>

then use that id in your ref elements:

   <ref target="c2-intro">Introduction</ref>

Then, in the stylesheet, all you have to do is use the attributes directly:

   <a name="{@id}"/>
   <a href="#{@target}"><xsl:value-of select="."/></a>

Just an idea...
Anton

Current Thread