This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
RE: Using profile.xsl to filter conditionalized documents
- From: "Bradford, Denis" <denisb at rational dot com>
- To: docbook-apps at lists dot oasis-open dot org
- Cc: "Harrison, Nancy" <NancyH at rational dot com>
- Date: Fri, 07 Dec 2001 15:05:11 -0500
- Subject: RE: DOCBOOK-APPS: Using profile.xsl to filter conditionalized documents
From: David Cramer
> Something like this (untested)?
>
> <xsl:variable name="os.ok" select="
> not(@os) or
> not($os) or
> contains(concat($sep, @os, $sep),
> concat($sep, $os, $sep)) or
>
> (contains(concat($sep, @os, $sep),
> concat($sep, 'mac', $sep)) or
> contains(concat($sep, @os, $sep),
> concat($sep, 'unix', $sep)) and
> $os = 'MacOrUnix') or
>
> @os = ''"/>
>
> Just keep adding ors and ands until you've taken care of every combination
;-)
That works like a champ, many thanks David! I did test it: used the
following command to generate multiple conditions:
saxon -o xsample.xml sample.xml profile.xsl "arch=WinorUNIX"
FWIW, here's the essential part of the customization style sheet that I
tested:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="../docbookxsl/tools/profile/profile.xsl"/> <!--
Standard stylesheets -->
<xsl:output method="xml"
doctype-public="-//Rational//DTD DocBook Customization for
Rational//EN"
doctype-system="ratl.dtd"/>
<!-- Profile elements based on input parameters -->
<xsl:template match="*">
<xsl:variable name="os.ok" select="not(@os) or not($os) or
contains(concat($sep, @os, $sep), concat($sep, $os, $sep))
or
@os = ''"/>
<xsl:variable name="ul.ok" select="not(@userlevel) or not($ul) or
contains(concat($sep, @userlevel, $sep), concat($sep, $ul,
$sep)) or
@userlevel = ''"/>
<!-- test WinorUNIX input -->
<xsl:variable name="arch.ok" select="not(@arch) or not($arch) or
contains(concat($sep, @arch, $sep), concat($sep, $arch,
$sep)) or
contains(concat($sep, @arch, $sep), concat($sep, $arch,
$sep)) or
(contains(concat($sep, @arch, $sep), concat($sep, 'Windows',
$sep)) or
contains(concat($sep, @arch, $sep), concat($sep, 'UNIX',
$sep)) and
$arch = 'WinorUNIX') or
@arch = ''"/>
<xsl:variable name="attr.ok" select="not(@*[local-name()=$attr]) or
not($val) or
contains(concat($sep, @*[local-name()=$attr], $sep),
concat($sep, $val, $sep)) or
@*[local-name()=$attr] = '' or not($attr)"/>
<xsl:if test="$os.ok and $ul.ok and $arch.ok and $attr.ok">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
- Denis