0

I have to format the table of contents of a docbook using xsl so that the entries for "top level" sections are bold and have a certain font and font size, but the entries for sect2 and sect3 aren't bold and have different fonts and font sizes. How do I do this?

E: I keep trying to change it in

<xsl:template name="toc.line">

in autotoc.xsl but every time I try a variation of

<xsl:if test="self::sect1"> 

it never accepts it.

mzjn
  • 48,958
  • 13
  • 128
  • 248
R Zol
  • 55
  • 5
  • 1
    Welcome to Stack Overflow. Please show your latest non-working attempt at solving this problem. It is usually more instructive to see fixes to your code than to read someone else's solution. See https://stackoverflow.com/help/how-to-ask – Spangen Feb 13 '18 at 17:38
  • And what is the target format (e.g. HTML or PDF) you currently transform docbook to? – Martin Honnen Feb 13 '18 at 18:00
  • transforming from docbook to fo through xsl and then from fo to pdf. – R Zol Feb 13 '18 at 18:31
  • I did that Spangen – R Zol Feb 13 '18 at 20:13
  • Testing the element name in xsl:if is usually a sign of poor coding practice: switching on element name should usually be done by means of template rules. – Michael Kay Feb 13 '18 at 21:21
  • I'm not sure what you mean by that. – R Zol Feb 13 '18 at 21:53
  • 1
    What does "it never accepts it" mean exactly? Do you get an error message? If so, which one exactly? Which version of Docbook do you use, which version of the stylesheets, which version of XSLT? It could be simply a namespace problem e.g. the input elements might be in the docbook namespace and of course in XSLT you then need to make sure you select or match based on the namespace so if you have e.g. `...` then in XSLT 1 you need e.g. `...`. – Martin Honnen Feb 14 '18 at 14:57
  • Or in XSLT 2 you need to declare `xpath-default-namespace="http://docbook.org/ns/docbook"` to be able to use `` to select a `sect1` element in that DocBook namespace. – Martin Honnen Feb 14 '18 at 14:58
  • sect1 is not a an element in the docbook they all just say section, sect1 should refer to the top level sections as opposed to sections within sections. I'm using xsl 1.78.1 – R Zol Feb 15 '18 at 18:41
  • I've gotten it to have different section headings based on the 'level' of the section. I'm docbook v 4.3 – R Zol Feb 15 '18 at 18:47

0 Answers0