Subject: Conditional text using attributes
From: Beth Fischi <bfischi@xxxxxxxxxxxxx>
Date: Thu, 28 Dec 2000 10:42:14 -0600
|
I'm trying to figure out how to exclude text and graphics from an output
file (HTML or FO, for example) by testing for attributes in my XSL
stylesheet. For instance, I have an XML file with instructions
appropriate for both Macintosh users and Windows users. In one output
file, I want to exclude the instructions for Mac users, and in another,
I want to exclude the instructions for Windows users so I end up with a
set appropriate to each type of user.
I'm using the DocBook DTD and Norm Walsh's DocBook XSL stylesheets
(http://nwalsh.com/docbook/xsl/index.html). I've created an XSL file
called "bj.xsl" that extends his HTML XSL stylesheet. In it, I have a
test case that (hopefully?) excludes all elements, attributes, comments
and text with the attribute "Mac":
*****************************************
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0'
xmlns="http://www.w3.org/TR/xhtml1/transitional"
exclude-result-prefixes="#default">
<xsl:include href="docbook.xsl"/>
<xsl:template match="*|@*|comment()|text()">
<xsl:if test="not(@os='Mac')">
<xsl:copy>
<xsl:apply-templates select="*|@*|comment()|text()" />
</xsl:copy>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
*****************************************
This doesn't work, but I'm not sure what I'm doing wrong. Any
suggestions would be greatly appreciated.
--Beth Fischi
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|