<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
  <xsl:output method="html"/>
    
  <xsl:template match="/">
    <xsl:variable name="ids">
      <xsl:for-each select="//*[local-name()='b']">
        <xsl:value-of select="concat(@xml:id,' ')"/>
      </xsl:for-each>
    </xsl:variable>
xmlid.xsl<br/>
ids: <xsl:value-of select="$ids"/> (two lines of output to follow)<br/>
    <xsl:for-each select="id($ids)">
      <xsl:value-of select="concat(name(),' ',@xml:id)"/>
      <br/>
    </xsl:for-each>
  </xsl:template>
  
</xsl:stylesheet>
