Implementation in XSLT

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

<!-- Generate DocBook instance with correct DOCTYPE -->
<xsl:output method="xml" 
            doctype-public="-//OASIS//DTD DocBook XML V4.1.2//EN"
            doctype-system="http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd"/>

<!-- 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:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

<!-- 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:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>