Gavin wrote: > Just wondering on the implementation of generate-id when @id are already > present. > > Example, in sample.xml we have > > <section id="link-class"> > > which gives us a generated file with > > <a name="N102CC"></a><a name="link-class"></a> > > Now, I don't see the generated-id as being referenced anywhere, whereas > 'link-class' is referenced from the toc. > > This seems to be the situation for all <section id="..."> , they all get a > generated id also. > > In document-to-html.xsl we have :- > > <xsl:template match="section"> > <!-- count the number of section in the ancestor-or-self axis to compute > the title element name later on --> > <xsl:variable name="sectiondepth" > select="count(ancestor-or-self::section)"/><a name="{generate-id()}"/> > <xsl:apply-templates select="@id"/> > ... > > which causes the above behaviour. > > So, just wanted to query, should we use the given id and not use generate-id > unless an id is not given? (as 'id' is not a required attribute of section) > ? That way we have one named anchor or the other, not both.
The following template is responsible for processing the section tag in [1]. <xsl:template match="section"> ... <a name="{generate-id()}"/> (1) <xsl:apply-templates select="@id"/> (2) ... </xsl:template> It should be safe to remove (1) and replace (2) and other references to @id with: <xsl:call-template name="generate-id"/> It would be even better to wrap the heading with a div. This way we can easily generate something like: <div id="section-id"> <a name="section-id"/> <h2>Section Heading</h2> ... </div> The id attribute on the wrapper div will do what (1) is supposed to do and is generally a better solution so we could also remove (1) unless there's a good reason not to do so. -Sina [1] $FORREST/main/webapp/skins/common/xslt/html/document-to-html.xsl