docbook-apps

  • 1.  html output has class attributes

    Posted 02-20-2014 14:55
    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></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):

    • one item




    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



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

    Posted 02-20-2014 17:29
    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(.)"/>


    <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
    bobs@sagehill.net

    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></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):
    >

      >
    • one item


    • >

    >
    > 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
    >



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

    Posted 02-21-2014 15:07
    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 <bobs@sagehill.net> 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(.)"/>
    >
    >
    > <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
    > bobs@sagehill.net
    >
    >
    > 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></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):
    >>

      >>
    • one item


    • >>

    >>
    >> 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
    >>
    >>