OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] Xref Numbering Thanks and Follow Up


Title: Re: [docbook-apps] Xref Numbering Thanks and Follow Up
Laurence
I had another look at my customization.  The following now works OK with Docbook 5.  I've also included some test files based on extracts from a real document.  Rather than permanently change all the xref text, I've used named xrefstyles for more flexibility, but these require adding the xrefstyle to each <xref>.  I also wanted all the xref titles to appear in italic, and included Bob's text from
<!-- Make all cross reference titles appear in italic -->
<!-- by default chapters are italicized but all sect cross references are not in italic -->
<!-- p.247 of 3rd. ed. and p.271 of 4th. ed. of "DocBook XSL The Complete Guide" -->
But this doesn't seem to work for me - see separate posting on this problem.
Hope this is of some use.
Ron    
(You will need to change the location of the 1.74.0 stylesheets of course)


Customization layer (file project.xsl):
---------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:xsl
="http://www.w3.org/1999/XSL/Transform"
  xmlns:exsl
="http://exslt.org/common"
  xmlns:d
="http://docbook.org/ns/docbook"
  xmlns:fo
="http://www.w3.org/1999/XSL/Format"
  version
="1.0"
  exclude-result-prefixes
="exsl">
<!-- import the 1.74.0 release name space aware stylesheet  -->
 
<xsl:import href="/Applications/Utilities/oxygen/9.3/oxygen/frameworks/docbook/5.0/docbook-xsl-ns-1.74.0/fo/docbook.xsl"/>
 
<!-- set base directory to where the PDF file is to be stored -->
 
<xsl:param name="base.dir" select="'/Library/WebServer/Documents/_XML/_PDFout/_test/'" />
 
<!-- set the output filename for the file  -->
 
<xsl:param name="root.filename" select="'Xref_test'" />
 
<!-- activate XEP extensions -->
 
<xsl:param name="xep.extensions" select ="1" />
 
<!-- turn on chapter numbering - 1, 2, 3 ...  -->
 
<xsl:param name="chapter.autolabel" select="1"/>
 
<!-- turn on section numbering for all sect levels -->
 
<!-- and include chapter number in section number - e.g. 1.1, 1.1.2, 1.1.2.3, etc -->
 
<xsl:param name="section.autolabel" select="1"/>
 
<xsl:param name="section.autolabel.max.depth" select="12"/>
 
<xsl:param name="section.label.includes.component.label" select="1"/>
 
<!-- add page number to xref citations  -->
 
<xsl:param name="insert.xref.page.number" select="yes"/>
 
<xsl:param name="xref.with.number.and.title" select="1"/>
 
<!-- define named xrefstyles for appendix, chapter, figure, part, sect1,sect2, sect3 section, table (all same: use xrefstyle="page_ref") -->
 
<!-- &#x00A0;(space) %n(number/label) &#x002C;(,) &#X0020;(space) &#x201C;(left") %t(title) &#x201D;(right")  &#x002C;(,) &#x00A0;(space) &#x0070;(p) &#x002E;(.) %p(page no.) -->
 
<!-- e.g. Chapter 3, "title of chapter", p.123 -->
 
<xsl:param name="local.l10n.xml" select="document('')" />
 
<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
   
<l:l10n language="en">
     
<l:context name="xref-number-and-title">
       
<l:template name="page.citation" text="&#x00A0;&#x0070;&#x002E;%p"/>
       
<l:template name="appendix" style="page_ref" text="Appendix&#x00A0;%n&#x002C;&#x00A0;&#x201C;%t&#x201D;&#x002C;&#x00A0;&#x0070;&#x002E;%p"/>
       
<l:template name="chapter"  style="page_ref" text="Chapter&#x00A0;%n&#x002C;&#x00A0;&#x201C;%t&#x201D;&#x002C;&#x00A0;&#x0070;&#x002E;%p"/>
       
<l:template name="figure"   style="page_ref" text="Figure&#x00A0;%n&#x002C;&#x00A0;&#x201C;%t&#x201D;&#x002C;&#x00A0;&#x0070;&#x002E;%p"/>
       
<l:template name="part"     style="page_ref" text="Part&#x00A0;%n&#x002C;&#x00A0;&#x201C;%t&#x201D;&#x002C;&#x00A0;&#x0070;&#x002E;%p"/>
       
<l:template name="sect1"    style="page_ref" text="Section&#x00A0;%n&#x002C;&#x00A0;&#x201C;%t&#x201D;&#x002C;&#x00A0;&#x0070;&#x002E;%p"/>
       
<l:template name="sect2"    style="page_ref" text="Section&#x00A0;%n&#x002C;&#x00A0;&#x201C;%t&#x201D;&#x002C;&#x00A0;&#x0070;&#x002E;%p"/>
        <l:template name="sect3"    style="page_ref" text="Section&#x00A0;%n&#x002C;&#x00A0;&#x201C;%t&#x201D;&#x002C;&#x00A0;&#x0070;&#x002E;%p"/>
       
<l:template name="sect4"    style="page_ref" text="Section&#x00A0;%n&#x002C;&#x00A0;&#x201C;%t&#x201D;&#x002C;&#x00A0;&#x0070;&#x002E;%p"/>
       
<l:template name="sect5"    style="page_ref" text="Section&#x00A0;%n&#x002C;&#x00A0;&#x201C;%t&#x201D;&#x002C;&#x00A0;&#x0070;&#x002E;%p"/>
       
<l:template name="section"  style="page_ref" text="Section&#x00A0;%n&#x002C;&#x00A0;&#x201C;%t&#x201D;&#x002C;&#x00A0;&#x0070;&#x002E;%p"/>
       
<l:template name="table"    style="page_ref" text="Table&#x00A0;%n&#x002C;&#x00A0;&#x201C;%t&#x201D;&#x002C;&#x00A0;&#x0070;&#x002E;%p"/>
     
</l:context>
   
</l:l10n>
 
</l:i18n>
<!-- Make all cross reference titles appear in italic -->
<!-- by default chapters are italicised but all sect cross references are not in italic -->
<!-- p.247 of 3rd. ed. and p.271 of 4th. ed. of "DocBook XSL The Complete Guide" -->
<!-- this is straight out of Bob's book, but doesn't work -->
 <xsl:template match="sect1|sect2|sect3|sect4|sect5|section" mode="insert.title.markup">
   
<xsl:param name="purpose"/>
   
<xsl:param name="xrefstyle"/>
   
<xsl:param name="title"/>
   
<xsl:choose>
     
<xsl:when test="$purpose='xref'">
       
<fo:inline font-style="italic">
         
<xsl:copy-of select="$title"/>
       
</fo:inline>
     
</xsl:when>
     
<xsl:otherwise>
       
<xsl:copy-of select="$title"/>
     
</xsl:otherwise>
   
</xsl:choose>
 
</xsl:template>
<!-- this is the standard template to output page citation from fo/xref.xml unchanged, but available for change -->
 
<xsl:template match="*" mode="page.citation">
   
<xsl:param name="id" select="'???'"/>
   
<fo:basic-link internal-destination="{$id}" xsl:use-attribute-sets="xref.properties">
     
<fo:inline keep-together.within-line="always">
       
<xsl:call-template name="substitute-markup">
         
<xsl:with-param name="template">
           
<xsl:call-template name="gentext.template">
             
<xsl:with-param name="name" select="'page.citation'"/>
             
<xsl:with-param name="context" select="'xref'"/>
           
</xsl:call-template>
         
</xsl:with-param>
       
</xsl:call-template>
     
</fo:inline>
   
</fo:basic-link>
 
</xsl:template>
</xsl:stylesheet>

Driver file (aa_JC.xml):
------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE book>
<book  xml:id="JC" xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="EN">
 
<info><title>Test Xref page number</title></info>
 
<chapter xml:id="C1">
   
<info><title>Title of first chapter</title></info>
   
<para>A paragraph in id=C1 try an Xref to Venn from here. <xref linkend="Venn" xrefstyle="page_ref"/></para>
   
<xi:include href="aa_template.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
 
</chapter>
 
<chapter xml:id="C2">
   
<info><title>Title of second chapter</title></info>
   
<para>A paragraph in id=C2 try an Xref to Date from here.  <xref linkend="Date" xrefstyle="page_ref"/></para>
 
</chapter>
 
<xi:include href="aa_venn.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
</book>
Xincluded file, sect1 thru 4 (aa_template.xml):
---------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sect1>
<sect1 xml:id="Template" xmlns="http://docbook.org/ns/docbook" version="5.0" xml:lang="EN">
 
<info><title> A Template</title></info>
 
<para> try an Xref to Venn from here id=Template.  <xref linkend="Venn" xrefstyle="page_ref"/></para>
 
<sect2 xml:id="Date"><title>The Manuscript</title>
   
<para>The date of the composition of the poems of the Nero A.x manuscript has usually been thought to be in the last decades of the fourteenth century, and although there has been at least one attempt to date the works to 1350-1360 this cannot be said to be generally accepted.  Try an Xref from here id=Date.  <xref linkend="Dialect" xrefstyle="page_ref"/></para>
 
</sect2>
 
<sect2 xml:id="Dialect"><info><title>The Dialect</title></info>
   
<para>The native dialect of the must have been that of the northwest. McIntosh locates the home region of the scribe who produced the Nero A.x manuscript near Holmes Chapel in eastern Cheshire, south of Manchester.  Try an Xref from here id=Dialect.  <xref linkend="Education" xrefstyle="page_ref"/></para>
    <sect3 xml:id="Education"><info><title>Education</title></info>
     
<para>In summary, he was obviously fluent in latin, very familiar with the Vulgate bible.  Try an Xref from here id=Education.  <xref linkend="Date" xrefstyle="page_ref"/></para>
     
<sect4 xml:id="Sect4"><info><title>Sect4</title></info>
       
<para>Sect4 text.  Try an Xref from here.  <xref linkend="Education" xrefstyle="page_ref"/></para>
     
</sect4>
   
</sect3>
 
</sect2>
</sect1>
Xincluded file, an appendix (aa_venn.xml):
-----------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE appendix>
<appendix xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="Venn" xml:lang="EN">
 
<info><title>A Set Theory Approach</title></info>
 
<para>In this appendix we outline a set theory description which illustrates the progressive approach and apply some simple probability theory to an estimate of ....</para>
 
<para>One approach to illustrating the progress of conformance to the requirements is simple set theory using Venn diagrams. Let us, for example, consider five requirements. Providing these requirements are statistically independent, the ordering of the points has no significance.</para>
 
<para>The selection of points for this example corresponds to points 3.3-3.7 in the template (<xref linkend="Template" xrefstyle="page_ref"/>)</para>
</appendix>








Thanks, Dr. Catterall, for the very quick response to my request for help
with the problem getting Docbook to include page numbers for my Xref
files.  Unfortunately, it still is not working.
I changed my docbook customization layer as indicated below.
Note, I included only the template for "section" in the xref-number-and-title
context. That is the only thing to which I am or will be linking.
Unfortunately, it still does not display the page number.

I also tried setting the parameter to true and that worked.  I could have
sworn I tried that before, but I don't remember it working.

I did also find a work-around, I simply changed the style sheet, xref.xsl,
to always put the page number by removing the if statement around
the check for insert.xref.page.number.  However, I don't see where to change
it to write the word "page" in addition to the number. 
In my situation, I can live with simply
hard coding the style sheet to always display Page nnn for an xref, but don't
see where to do this.

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href=""./titlepage.xsl"/> <xsl:import href=""/opt/docbook/DOCBOOK/docbook-xsl-1.65.1/fo/docbook.xsl"/>
<xsl:attribute-set name="formal.object.properties">
  <xsl:attribute name="keep-together.within-column">auto</xsl:attribute>
</xsl:attribute-set>
<xsl:param name="local.l10n.xml" select="document('')"/>
<l:i18n xmlns:l="http://docbook.sourceforge/xmlns/l10n/1.0">
<l:l10n language="en">
<l:context name="xref-number-and-title">
<l:template name="section" style="page_ref" text="Section &#x002E;%p"/>
</l:context>
<l:context name="xref">
<l:template name="formalpara" style="fp_page_ref" text="Paragraph&#x00A0;&#x201C;%t&#x201D;"/>
<l:template name="olink.page.citation" text="(page %p)"/>
<l:template name="page.citation" text="[%p]"/>
<l:template name="page" text="(page %p)"/>
<l:template name="docname" text="in %o"/>
<l:template name="docnamelong" text="in the document title %o"/>
<l:template name="pageabbrev" text="(p. %p)"/>
<l:template name="Page" text="Page %p"/>
</l:context>
</l:l10n>
</l:i18n>
</xsl:stylesheet>

I also did some testing by adding "xsl:message" to the xsl style sheets
themselves and I got the following. 

@toolman#/home/leffstudent/225 >LT Te.xml
Making portrait pages on USletter paper (8.5inx11in)
In Gentext Template
In Gentext Template
In Gentext Template
xref match

In relevant part, here is the instrumentation to xref.xsl:

<xsl:template match="xref" name="xref">
  <xsl:variable name="targets" select="key('id',@linkend)"/>
  <xsl:variable name="target" select="$targets[1]"/>
  <xsl:variable name="refelem" select="local-name($target)"/>
    <xsl:message><xsl:text>xref match</xsl:text></xsl:message>

  <xsl:call-template name="check.id.unique">
    <xsl:with-param name="linkend" select="@linkend"/>
  </xsl:call-template>


  <!-- Add standard page reference? -->
  <xsl:if test="not(starts-with(normalize-space(@xrefstyle), 'select:') != ''
                and (contains(@xrefstyle, 'page')
                     or contains(@xrefstyle, 'Page')))
                and ( $insert.xref.page.number = 'yes'
                  or $insert.xref.page.number = '1')
                or local-name($target) = 'para'">
    <xsl:message><xsl:text>IF PAGE</xsl:text></xsl:message>
    <fo:basic-link internal-destination="{@linkend}"
                   xsl:use-attribute-sets="xref.properties">
      <xsl:apply-templates select="$target" mode="page.citation">
        <xsl:with-param name="id" select="@linkend"/>
      </xsl:apply-templates>
    </fo:basic-link>
  </xsl:if>
</xsl:template>

So it appears the if to generate the page number was not being
executed.

The "In Gentext Template" comes from xsl:template name="gentext"

Thanks for any insight anyone can provide.

Dr. Laurence Leff  Western Illinois University, Macomb IL 61455 ||(309) 298-1315
Stipes 447 Assoc. Prof. of Computer Sci. Pager: 309-367-0787 FAX: 309-298-2302

---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org


-- 
Ron Catterall, Phd, DSc                         email: ron@catterall.net
Prolongacion de Hidalgo 140                             http://catterall.net/
San Felipe del Agua                                        tel: +52 951 520 1821
Oaxaca      68020  Mexico                          fax: +1 530 348 8309


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]