Re: [docbook-apps] xrefs to elements don't work</span></a></span> </h1> <p class="darkgray font13"> <span class="sender pipe"><a href="/search?l=docbook-apps@lists.oasis-open.org&q=from:%22Bob+Stayton%22" rel="nofollow"><span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">Bob Stayton</span></span></a></span> <span class="date"><a href="/search?l=docbook-apps@lists.oasis-open.org&q=date:20130405" rel="nofollow">Fri, 05 Apr 2013 09:18:27 -0700</a></span> </p> </div> <div itemprop="articleBody" class="msgBody"> <!--X-Body-of-Message--> <pre>Hi Eric, Actually, creating an xref to a title used to work in the stylesheets. Currently it gets the generated text right, but the link is to the id of the title element, and most title elements do not output an @id attribute, so the link fails. It seems this feature was broken some time ago when the xref templates were rewritten to support universal linking in DocBook 5.</pre><pre> This customization of the template named 'simple.xlink' from fo/inline.xsl fixes the id problem. It only corrects the problem for @linkend references, not for @xlink:href references used in universal linking, but it should suffice for your needs. Search for 'linkend.candidate' to see where I made the changes. <xsl:template name="simple.xlink"> <xsl:param name="node" select="."/> <xsl:param name="content"> <xsl:apply-templates/> </xsl:param> <xsl:param name="linkend.candidate" select="$node/@linkend"/> <xsl:param name="xhref" select="$node/@xlink:href"/> <xsl:choose> <xsl:when test="$xhref and (not($node/@xlink:type) or $node/@xlink:type='simple')"> <!-- Is it a local idref? --> <xsl:variable name="is.idref"> <xsl:choose> <!-- if the href starts with # and does not contain an "(" --> <!-- or if the href starts with #xpointer(id(, it's just an ID --> <xsl:when test="starts-with($xhref,'#') and (not(contains($xhref,'&#40;')) or starts-with($xhref, '#xpointer&#40;id&#40;'))">1</xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:variable> <!-- Is it an olink ? --> <xsl:variable name="is.olink"> <xsl:choose> <!-- If xlink:role="<a rel="nofollow" href="http://docbook.org/xlink/role/olink"">http://docbook.org/xlink/role/olink"</a>; --> <!-- and if the href contains # --> <xsl:when test="contains($xhref,'#') and @xlink:role = $xolink.role">1</xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:choose> <xsl:when test="$is.olink = 1"> <xsl:call-template name="olink"> <xsl:with-param name="content" select="$content"/> </xsl:call-template> </xsl:when> <xsl:when test="$is.idref = 1"> <xsl:variable name="idref"> <xsl:call-template name="xpointer.idref"> <xsl:with-param name="xpointer" select="$xhref"/> </xsl:call-template> </xsl:variable> <xsl:variable name="targets" select="key('id',$idref)"/> <xsl:variable name="target" select="$targets[1]"/> <xsl:call-template name="check.id.unique"> <xsl:with-param name="linkend" select="$idref"/> </xsl:call-template> <xsl:choose> <xsl:when test="count($target) = 0"> <xsl:message> <xsl:text>XLink to nonexistent id: </xsl:text> <xsl:value-of select="$idref"/> </xsl:message> <xsl:copy-of select="$content"/> </xsl:when> <xsl:otherwise> <fo:basic-link internal-destination="{$idref}"> <xsl:apply-templates select="." mode="simple.xlink.properties"/> <xsl:copy-of select="$content"/> </fo:basic-link> </xsl:otherwise> </xsl:choose> </xsl:when> <!-- otherwise it's a URI --> <xsl:otherwise> <fo:basic-link external-destination="url({$xhref})"> <xsl:apply-templates select="." mode="simple.xlink.properties"/> <xsl:copy-of select="$content"/> </fo:basic-link> <!-- * Call the template for determining whether the URL for this --> <!-- * hyperlink is displayed, and how to display it (either inline or --> <!-- * as a numbered footnote). --> <xsl:call-template name="hyperlink.url.display"> <xsl:with-param name="url" select="$xhref"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:when test="$linkend.candidate"> <xsl:variable name="targets.candidate" select="key('id',$linkend.candidate)"/> <xsl:variable name="target.candidate" select="$targets.candidate[1]"/> <xsl:variable name="target.id"> <xsl:choose> <xsl:when test="$target.candidate/self::title and $target.candidate/parent::*/@id"> <xsl:value-of select="$target.candidate/parent::*/@id"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$target.candidate/@id"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="targets" select="key('id',$target.id)"/> <xsl:variable name="target" select="$targets[1]"/> <xsl:variable name="linkend" select="$target/@id"/> <xsl:call-template name="check.id.unique"> <xsl:with-param name="linkend" select="$linkend"/> </xsl:call-template> <xsl:choose> <xsl:when test="count($target) = 0"> <xsl:message> <xsl:text>XLink to nonexistent id: </xsl:text> <xsl:value-of select="$linkend"/> </xsl:message> <xsl:copy-of select="$content"/> </xsl:when> <xsl:otherwise> <fo:basic-link internal-destination="{$linkend}"> <xsl:apply-templates select="." mode="simple.xlink.properties"/> <xsl:copy-of select="$content"/> </fo:basic-link> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:copy-of select="$content"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> Bob Stayton Sagehill Enterprises b...@sagehill.net From: Eric Nordlund Sent: Thursday, April 04, 2013 6:00 PM To: docbook-apps@lists.oasis-open.org Subject: [docbook-apps] xrefs to <title> elements don't work My company has a hundred or so books that were authored with Arbortext's graphic XML editor. I'm having a problem processing these books with XSL-FO because so many of the xrefs in these books are to title elements instead of the parent procedure, section, example, table, etc., elements. Is there a way to make these work in the XSL-FO output? I was thinking I could have a template that could recognize when an xref/@linkend pointed to the id of a title and then change the linkend to the id of the title's parent element, but I don't really know how to do that. Is there another way to do what I need to do? Eric Nordlund Customer Documentation and Training Cray Inc. 901 5th Ave Seattle, WA 98164 (206)701-2232 </pre> </div> <div class="msgButtons margintopdouble"> <ul class="overflow"> <li class="msgButtonItems"><a class="button buttonleft " accesskey="p" href="msg18891.html">Previous message</a></li> <li class="msgButtonItems textaligncenter"><a class="button" accesskey="c" href="thrd5.html#18903">View by thread</a></li> <li class="msgButtonItems textaligncenter"><a class="button" accesskey="i" href="mail5.html#18903">View by date</a></li> <li class="msgButtonItems textalignright"><a class="button buttonright " accesskey="n" href="msg18906.html">Next message</a></li> </ul> </div> <a name="tslice"></a> <div class="tSliceList margintopdouble"> <ul class="icons monospace"> <li class="icons-email"><span class="subject"><a href="msg18886.html">[docbook-apps] xrefs to <title> elements don't work</a></span> <span class="sender italic">Eric Nordlund</span></li> <li><ul> <li class="icons-email"><span class="subject"><a href="msg18890.html">Re: [docbook-apps] xrefs to <title> elements d...</a></span> <span class="sender italic">Thomas Schraitle</span></li> <li><ul> <li class="icons-email"><span class="subject"><a href="msg18891.html">Re: [docbook-apps] xrefs to <title> elemen...</a></span> <span class="sender italic">Aaron DaMommio</span></li> </ul></li> <li class="icons-email tSliceCur"><span class="subject">Re: [docbook-apps] xrefs to <title> elements d...</span> <span class="sender italic">Bob Stayton</span></li> <li><ul> <li class="icons-email"><span class="subject"><a href="msg18906.html">RE: [docbook-apps] xrefs to <title> elemen...</a></span> <span class="sender italic">Eric Nordlund</span></li> <li><ul> <li class="icons-email"><span class="subject"><a href="msg18966.html">Re: [docbook-apps] xrefs to <title> el...</a></span> <span class="sender italic">Bob Stayton</span></li> <li><ul> <li class="icons-email"><span class="subject"><a href="msg18967.html">Re: [docbook-apps] xrefs to <title>...</a></span> <span class="sender italic">Bob Stayton</span></li> </ul> </ul> </ul> </ul> </ul> </div> <div class="overflow msgActions margintopdouble"> <div class="msgReply" > <h2> Reply via email to </h2> <form method="POST" action="/mailto.php"> <input type="hidden" name="subject" value="Re: [docbook-apps] xrefs to <title> elements don't work"> <input type="hidden" name="msgid" value="0B34779A2C3A492FBB55DDD0F9497A9C@totoro"> <input type="hidden" name="relpath" value="docbook-apps@lists.oasis-open.org/msg18903.html"> <input type="submit" value=" Bob Stayton "> </form> </div> </div> </div> <div class="aside" role="complementary"> <div class="logo"> <a href="/"><img src="/logo.png" width=247 height=88 alt="The Mail Archive"></a> </div> <form class="overflow" action="/search" method="get"> <input type="hidden" name="l" value="docbook-apps@lists.oasis-open.org"> <label class="hidden" for="q">Search the site</label> <input class="submittext" type="text" id="q" name="q" placeholder="Search docbook-apps"> <input class="submitbutton" name="submit" type="image" src="/submit.png" alt="Submit"> </form> <div class="nav margintop" id="nav" role="navigation"> <ul class="icons font16"> <li class="icons-home"><a href="/">The Mail Archive home</a></li> <li class="icons-list"><a href="/docbook-apps@lists.oasis-open.org/">docbook-apps - all messages</a></li> <li class="icons-about"><a href="/docbook-apps@lists.oasis-open.org/info.html">docbook-apps - about the list</a></li> <li class="icons-expand"><a href="/search?l=docbook-apps@lists.oasis-open.org&q=subject:%22Re%5C%3A+%5C%5Bdocbook%5C-apps%5C%5D+xrefs+to+%3Ctitle%3E+elements+don%27t+work%22&o=newest&f=1" title="e" id="e">Expand</a></li> <li class="icons-prev"><a href="msg18891.html" title="p">Previous message</a></li> <li class="icons-next"><a href="msg18906.html" title="n">Next message</a></li> </ul> </div> <div class="listlogo margintopdouble"> </div> <div class="margintopdouble"> </div> </div> </div> <div class="footer" role="contentinfo"> <ul> <li><a href="/">The Mail Archive home</a></li> <li><a href="/faq.html#newlist">Add your mailing list</a></li> <li><a href="/faq.html">FAQ</a></li> <li><a href="/faq.html#support">Support</a></li> <li><a href="/faq.html#privacy">Privacy</a></li> <li class="darkgray">0B34779A2C3A492FBB55DDD0F9497A9C@totoro</li> </ul> </div> </body> </html> <script>(function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'9daaa29bde64c235',t:'MTc3MzIzMjkwNQ=='};var a=document.createElement('script');a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();</script>