Next in thread → Next in month →

Re: [docbook-apps] html output has class attributes

From
Tim Arnold <>
Date
2014-02-21T15:06:53+00:00
ID
CA+O6OTBVg1b_vHodjeOTrgnwYeSpvuvfgyd-g26t5r5jVG=
Thread
Re: [docbook-apps] html output has class attributes
hi Bob,
Thanks for that info. It is pretty interesting to see how the class attributes are handled. 

Your suggestion is working for me.

thanks,

--Tim

On Thu, Feb 20, 2014 at 12:29 PM, Bob Stayton <> wrote:

Hi Tim,

You can turn off many of the class attributes, but not all.  Many of the class attributes are generated by applying templates in mode="class.attribute" using this template from html/html.xsl:

<xsl:template match="*" mode="class.attribute">

  <xsl:param name="class" select="local-name(.)"/>

  <!-- permit customization of class attributes -->

  <!-- Use element name by default -->

  <xsl:variable name="class.value">

    <xsl:apply-templates select="." mode="class.value">

      <xsl:with-param name="class" select="$class"/>

    </xsl:apply-templates>

  </xsl:variable>

  <xsl:if test="string-length(normalize-space($class.value)) != 0">

    <xsl:attribute name="class">

      <xsl:value-of select="$class.value"/>

    </xsl:attribute>

  </xsl:if>

</xsl:template>

As you can see, if $class.value is empty, then no class attribute is generated.  So in your customization, you should be able to do this to turn them off:

<xsl:template match="*" mode="class.value"/>

and then add templates in that mode as needed for the elements you want to have class attributes.

Unfortunately, this will not control all the class attributes because many are still hardcoded in the stylesheet at this point.  You should be able to control most of the major elements, though.

Bob Stayton

Sagehill Enterprises



On 2/20/2014 6:55 AM, Tim Arnold wrote:

hi, I would like to completely control the class attributes in the

generated html output.

I'm using the DocBook 1.78.1 stylesheets.

Here is an example of what I'm doing. My document (name=listtest.xml):

<chapter xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="prcc">

   <info><title>The Title</title></info>

   <para>

     <itemizedlist>

       <listitem>

         <para>one item</para>

       </listitem>

     </itemizedlist>

   </para>

</chapter>

The command:

xsltproc --stringparam css.decoration 0 /path/xsl-1.78.1/html/docbook.xsl

listtest.xml

The output (snippet):

<ul class="itemizedlist" type="disc">

   <li class="listitem"><p>one item</p></li>

</ul>

I don't want any of the class attributes in the output because I will

generate my own with a set of templates like this:

<xsl:template match="d:listitem[@remap='stmt']" mode="class.value">

   <xsl:value-of select="'stmt'" />

</xsl:template>

I can't figure out what I'm doing wrong. Is there a way to turn off the

class attributes?

thanks,

--Tim Arnold
Next in thread → Next in month →