Next in thread → Next in month →

Re: [docbook-apps] Adding custom attributes to body and table

From
Bob Stayton <>
Date
2012-06-26T17:28:41+00:00
ID
03a901cd53c1$1c882390$6600a8c0@pazu
Thread
Re: [docbook-apps] Adding custom attributes to body and table
Hi Robert,

The body element is easy, see:

 

http://www.sagehill.net/docbookxsl/BodyAtts.html

 

For tables, not so easy.  You would need to 
copy this template from xhtml/table.xsl to your customization 
layer:

 

<xsl:template match="d:tgroup" 
name="tgroup">

 

(remove the d: namespace if you are using DocBook 4 
instead of DocBook 5).  That is the template that generates the 
<table> element for CALS tables.  Unfortunately, it is a pretty big 
template because of all the other attributes it handles.  You would need to 
add something like this after the opening table tag:

 

<xsl:if test="@userlevel">

  <xsl:attribute 
name="userlevel">

    <xsl:value-of 
select="@userlevel"/>

  </xsl:attribute>

</xsl:if>

 

Bob Stayton
Sagehill Enterprises


 

 

  
----- Original Message ----- 

  
From: 
  robert 

  
To:  
  

  
Sent: Tuesday, June 26, 2012 5:16 
AM

  
Subject: [docbook-apps] Adding custom 
  attributes to body and table

  

  
Hi

  

  
I'm using DocBook XSL stylesheets to generate XHTML files. I would like 
  my output HTML files to contain some custom attributes, mainly for the body 
  and table elements.

  

  
For the body element, the value of the attribute is always the same so it 
  could be hardcoded into stylesheets. So the question is how could I add 
  xyz="abc" do the body element in output XHTML files?

  

  
For tables, I would like to pass the value of a custom parameter from the 
  source XML file. For example, I would like to pass the value of the userlevel 
  attribute specified for the informaltable element to the output, i.e.

  
from the source XML <informaltable userlevel="cba">

  
to the output html <table xyz="cba">

  
How could I do this?

  

  
Regards,

  
Robert
Next in thread → Next in month →