[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] Questions about IDs defined on some Docbook elements
Radu, On Thursday, October 03, 2013 04:29:41 am Radu Coravu wrote: > Let's say in a Docbook 5 document I have a chapter title someplace like > > this: > > <title xml:id="titleChapter">3 - Chapter Title - Missing ID</title> > > and in some other place of the document I use a link to it: > > <link xlink:href="#titlePart">titlePart</link> First, note that the @xml:id on <title/> is not the same as the @xlink:href on the link. You probably wanted them to match. > From what I tested the XHTML-based outputs will never create an anchor > for the "titleChapter" ID. > Is there a parameter which can be set in order to create HTML anchors > for all ID's defined in the XML document? The generation of the code for chapter/title is in the titlepage template: <xsl:template match="title" mode="chapter.titlepage.recto.auto.mode"> <div xsl:use-attribute-sets="chapter.titlepage.recto.style"> <xsl:apply-templates select="." mode="chapter.titlepage.recto.mode"/> </div> </xsl:template> I don't see any controls here for generating IDs for the <title/> - if needed, you'd need to customize these templates. > Or does the specification say somewhere the list of possible elements to > which you can link? From what I see in the stylesheets, there has been some rudimentary special case for linking to <title/>; see html/xref.xsl for example: <xsl:template match="title" mode="xref-to"> <xsl:param name="referrer"/> <xsl:param name="xrefstyle"/> <xsl:param name="verbose" select="1"/> <!-- if you xref to a title, xref to the parent... --> <xsl:choose> <!-- FIXME: how reliable is this? --> <xsl:when test="contains(local-name(parent::*), 'info')"> <xsl:apply-templates select="parent::*[2]" mode="xref-to"> <xsl:with-param name="referrer" select="$referrer"/> <xsl:with-param name="xrefstyle" select="$xrefstyle"/> <xsl:with-param name="verbose" select="$verbose"/> </xsl:apply-templates> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="parent::*" mode="xref-to"> <xsl:with-param name="referrer" select="$referrer"/> <xsl:with-param name="xrefstyle" select="$xrefstyle"/> <xsl:with-param name="verbose" select="$verbose"/> </xsl:apply-templates> </xsl:otherwise> </xsl:choose> </xsl:template> However, this only deals with the generated text, but does not adjust the link target to point to the parent element. Moreover, as far as I understand the template above has a bug when it tries to deal with *info elements: "parent::*[2]" should have been "ancestor::*[2]", as parent::* produces a nodeset with a single node in it. Regards, Alexey.
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]