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] <xsl:apply-templates select="." mode="class.attribute" />

Processing an element in that mode generates a class attribute for the element being processed.  It is applied by the stylesheet just after the opening tag of the output element.  In the template with match="programlisting" in html/verbatim.xsl, its application looks like this:
    <xsl:apply-templates select="." mode="class.attribute"/>
That template in turn applies templates in mode="class.value" to generate the attribute value string before it assembles the <xsl:attribute> element.  You can customize the mode="class.value" to generate a different string value, and it will be used in the class attribute.  Because it uses a mode, you can add templates for specific element selectors.  For example:
<xsl:template match="programlisting[@role]" mode="class.value">
  <xsl:value-of select="@role"/>
See this reference for more information:
Bob Stayton
Sagehill Enterprises
----- Original Message -----
From: Alan Ezust
Sent: Tuesday, August 05, 2008 8:34 AM
Subject: [docbook-apps] <xsl:apply-templates select="." mode="class.attribute" />

Could someone explain to me what this does:
 <xsl:apply-templates select="." mode="class.attribute"/>
 I'm confused about how it transforms <programlisting> elements from docbook to html.
 I wanted to add a role attribute to my programlisting, so I have an element like this:
 <programlisting role="solution">
   something that has a solution
 But it seems that when it is processed by the rule in html/verbatim.xsl, the element gets replaced by
  <pre class="programlisting">
And the "solution" attribute is lost.

I would like to modify the template for programlisting to check the role, and if it exists, set the class= attrib of the resultant <pre> element to be the same thing. But i'm not sure where the best place is to put it in my customization layer. Any suggestions?

Here is the template for programlisting from verbatim.xsl:
<xsl:template match="programlisting|screen|synopsis">
  <xsl:param name="suppress-numbers" select="'0'"/>
  <xsl:variable name="id">
    <xsl:call-template name="object.id"/>

  <xsl:call-template name="anchor"/>

  <xsl:if test="$shade.verbatim != 0">
      <xsl:text>The shade.verbatim parameter is deprecated. </xsl:text>
      <xsl:text>Use CSS instead,</xsl:text>
      <xsl:text>for example: pre.</xsl:text>
      <xsl:value-of select="local-name(.)"/>
      <xsl:text> { background-color: #E0E0E0; }</xsl:text>

    <xsl:when test="$suppress-numbers = '0'
            and @linenumbering = 'numbered'
            and $use.extensions != '0'
            and $linenumbering.extension != '0'">
      <xsl:variable name="rtf">
    <xsl:call-template name="apply-highlighting"/>
        <xsl:apply-templates select="." mode="class.attribute"/>
    <xsl:call-template name="number.rtf.lines">
      <xsl:with-param name="rtf" select="$rtf"/>
        <xsl:apply-templates select="." mode="class.attribute"/>
    <xsl:call-template name="apply-highlighting"/>

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