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

<xsl:output method="xml"/>

<xsl:param name="refs"/>

<!-- Former version used :
<xsl:template match="/bibliography/*">
  and
<xsl:template match="/bibliography/*[contains($refs, @id)]">
but it no longer works, libxslt have been fixed:
http://bugs.debian.org/329678
-->
<xsl:template match="/bibliography/*">
  <xsl:if test="contains($refs, @id)">
    <xsl:copy> 
       <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
    <xsl:text>&#10;</xsl:text>
  </xsl:if>
  <!-- Otherwise, drop it -->
</xsl:template>

<xsl:template match="@*|comment()|processing-instruction()">
  <xsl:copy/>
</xsl:template>
   
<xsl:template match="*">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>                           
  <xsl:text>
  </xsl:text>
</xsl:template>

<xsl:template match="/">
  <bibliography>
    <xsl:apply-templates select="bibliography/*"/>
  </bibliography>
</xsl:template>

</xsl:stylesheet>
