Thank you so much for the quick reply and helpful response!
It works like a charm. So nice that I don't have to copy and paste the
original template for <programlisting> also, but just add this extra
template match.

--Alan



On Tue, Aug 5, 2008 at 12:14 PM, Bob Stayton <[EMAIL PROTECTED]> wrote:

>  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:
>
>   <pre>
>     <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="[EMAIL PROTECTED]" mode="class.value">
>   <xsl:value-of select="@role"/>
> </xsl:template>
>
> See this reference for more information:
>
> http://www.sagehill.net/docbookxsl/HtmlCustomEx.html#CustomClassValues
>
> Bob Stayton
> Sagehill Enterprises
> [EMAIL PROTECTED]
>
>
>
> ----- Original Message -----
> *From:* Alan Ezust <[EMAIL PROTECTED]>
> *To:* apps docbook <[email protected]>
> *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
>  </programlisting>
>
>  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:variable>
>
>   <xsl:call-template name="anchor"/>
>
>   <xsl:if test="$shade.verbatim != 0">
>     <xsl:message>
>       <xsl:text>The shade.verbatim parameter is deprecated. </xsl:text>
>       <xsl:text>Use CSS instead,</xsl:text>
>     </xsl:message>
>     <xsl:message>
>       <xsl:text>for example: pre.</xsl:text>
>       <xsl:value-of select="local-name(.)"/>
>       <xsl:text> { background-color: #E0E0E0; }</xsl:text>
>     </xsl:message>
>   </xsl:if>
>
>   <xsl:choose>
>     <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:variable>
>       <pre>
>         <xsl:apply-templates select="." mode="class.attribute"/>
>     <xsl:call-template name="number.rtf.lines">
>       <xsl:with-param name="rtf" select="$rtf"/>
>     </xsl:call-template>
>       </pre>
>     </xsl:when>
>     <xsl:otherwise>
>       <pre>
>         <xsl:apply-templates select="." mode="class.attribute"/>
>     <xsl:call-template name="apply-highlighting"/>
>       </pre>
>     </xsl:otherwise>
>   </xsl:choose>
> </xsl:template>
>
>
>

Reply via email to