Implementation in XSLT

<xsl:stylesheet xmlns:xsl=""

<!-- Generate DocBook instance with correct DOCTYPE -->
<xsl:output method="xml" 
            doctype-public="-//OASIS//DTD DocBook XML V4.1.2//EN"

<!-- Which OSes to select -->
<xsl:param name="os"/>

<!-- Which UserLevels to select -->
<xsl:param name="ul"/>

<!-- By default, copy all nodes in document -->
<xsl:template match="@*|*|text()|comment()|processing-instruction()">
    <xsl:apply-templates select="@*|node()"/>

<!-- Elements which have os or userlevel attribute set must be treated separately -->
<xsl:template match="*[@os or @userlevel]">
  <xsl:variable name="os.ok" select="not(@os) or
                contains(concat(';', @os, ';'), concat(';', $os, ';')) or
                @os = ''"/>
  <xsl:variable name="ul.ok" select="not(@userlevel) or
                contains(concat(';', @userlevel, ';'), concat(';', $ul, ';')) or
                @userlevel = ''"/>
  <xsl:if test="$os.ok and $ul.ok">
      <xsl:apply-templates select="@*|node()"/>