[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Extending Xhtml2fo.xsl to handle CLASS attributes

Subject: RE: Extending Xhtml2fo.xsl to handle CLASS attributes
From: Graham Hannington <Ghannington@xxxxxxx>
Date: Tue, 17 Dec 2002 13:43:50 -0000
xhtml2fo css
I've begun work on handling the CLASS attributes a *slightly* better way
than I described in my previous note:


<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:css="http://www.csl.com/css"
	exclude-result-prefixes="css">

<css:stylesheet>

	<rule selector="span.note">font-weight: bold;</rule>
	<rule selector="span.normal">font-weight: normal;</rule>

</css:stylesheet>

.
.
.

<xsl:template name="process-class">

	<xsl:param name="element"/>
	<xsl:param name="class"/>

	<xsl:variable name="selector">
		<xsl:choose>
			<xsl:when test="$class">
				<xsl:value-of select="concat($element, '.',
$class)" />
			</xsl:when>

			<xsl:otherwise>
				<xsl:value-of select="$element" />
			</xsl:otherwise>
		</xsl:choose>

	</xsl:variable>

	<xsl:variable name="rule"
select="document('')/xsl:stylesheet/css:stylesheet/rule[@selector =
$selector]" />

	<xsl:if test="$rule">
		<xsl:attribute name="style"><xsl:value-of select="$rule"
/></xsl:attribute>
	</xsl:if>

</xsl:template>



(The code above is in the XSL stylesheet that I use prior to Xhtml2fo.xsl.)

The process-class template replaces:

<p><span class="note">Programmers:</span> Do this.</p>

with

<p><span class="note" style="font-weight: bold;">Programmers:</span> Do
this.</p>


Some limitations:

- Only one selector per rule: I'd like to be able to specify something like
selector="span.note, span.object, span.name", so the same attributes can
apply to many classes, as they do in a CSS file.

- The rules don't cascade (I'm less upset about this).

- This syntax doesn't yet handle "behaviors" (although I'm thinking that I
could add a "template" attribute to the <rule> tag, that I could use in the
process-class template to call a named template that would do the necessary
processing).

I'd welcome advice on any of this.

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.