[xsl] Extracting CSS Class from STYLE element

Subject: [xsl] Extracting CSS Class from STYLE element
From: David Carver <d_a_carver@xxxxxxxxx>
Date: Tue, 16 Mar 2004 14:23:49 -0800 (PST)
For those that are using Antenna House's XHTML2FO transformation, one
item it doesn't support is the ability to extract Style information
from a class attribute.  The following bit of XSLT will allow you to
get this information and use it for formatting the XSLFO output.  Just
add an xsl:if test after the @style test to call this template.

<xsl:template name="process-class">
<xsl:param name="class"/>
<!-- e.g., class="C7"
  	  convert to text-align: center; color: red"
  	  pass to process-style for additional processing -->
<xsl:variable name="styleClasses"
<xsl:variable name="elementName" select="translate(name(.),
'abcdefghijklmnopqrstuvwxyz',  'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
<xsl:variable name="findClass" select="concat($elementName, '.',
<xsl:variable name="temp1" select="substring-after($styleClasses,
<xsl:variable name="temp2" select="substring-after($temp1, '{')"/>
<xsl:variable name="styleList" select="substring-before($temp2, '}')"/>
<xsl:call-template name="process-style">
	<xsl:with-param name="style" select="$styleList"/>

"A good listener is a good talker with a sore throat." - Katharine Whitehorn

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread