xsl-list
[Top] [All Lists]

Re: generate-id for identical elements

2004-09-23 11:44:45
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="{(_at_)id}"/>
   <a href="#{(_at_)target}"><xsl:value-of select="."/></a>

Just an idea...
Anton