[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
Hi Alexey, Thomas, Thanks for the tips.One of our clients had this kind of links and I just wanted to explore the way in which Docbook links are usually made.
I noticed that template "<xsl:template match="title" mode="xref-to">" too. Indeed, probably as it is almost never used (because almost nobody sets an @id on a title) it might also have some bugs in it.
I also found a workaround for the client's situation. Here's another workaround I found myself, instead of using:
<title xml:id="titleChapter">3 - Chapter Title</title>
you can use:
<title><anchor xml:id="titleChapter"/>3 - Chapter Title</title>
An anchor's ID is always preserved in the output.In my opinion if the Docbook specification allows an xml:id on an element, then the stylesheets should also handle linking to it but as a situation like linking to a title is very rare the stylesheets do not handle it at all.
-- Regards, Radu Radu Coravu <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com On 10/3/2013 7:46 PM, Alexey Neyman wrote:
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]