<!--
     complete "Basic Multilingual Plane" (BMP) table for browser display
     (xsltproc BMP.xsl BMP.xsl)
-->
<!DOCTYPE xsl:stylesheet [ 
  <!ENTITY enw "http://en.wiki"> 
  <!ENTITY orw ".org/wiki/"> 
  <!ENTITY ref "&enw;books&orw;Unicode/Character_reference/"> 
  <!ENTITY BMP "Basic_Multilingual_Plane"> 
  <!ENTITY bmp "&enw;pedia&orw;&BMP;#&BMP;"> 
  <!ENTITY xp2 "http://www.w3.org/TR/xpath-functions/">
  <!ENTITY cts "codepoints-to-string">
]>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
  <xsl:output method="xml"/>

  <xsl:variable name="hex0">
    <d>0</d><d>1</d><d>2</d><d>3</d><d>4</d><d>5</d><d>6</d><d>7</d>
    <d>8</d><d>9</d><d>A</d><d>B</d><d>C</d><d>D</d><d>E</d><d>F</d>
  </xsl:variable>
  <xsl:variable name="hex" select="document('')/*/xsl:variable[@name='hex0']"/>

  <xsl:template match="/">
    <html>
      <h1><a href="&bmp;">BMP</a></h1>
      (generated by "xsltproc <a href="BMP.xsl">BMP.xsl</a> BMP.xsl"
       because <a href="&xp2;#func-&cts;">fn:&cts;()</a> is not
       available in browser XSLT)

      <table border="1">
        <xsl:for-each select="$hex/*">
          <xsl:variable name="h" select="."/>

          <tr>
            <xsl:for-each select="$hex/*">
              <xsl:variable name="l" select="."/>

              <td align="center">
                <h2>
                  <a href="&ref;{$h}000-{$h}FFF">
                    <xsl:value-of select="concat($h,$l,'00 - ',$h,$l,'FF')"/>
                  </a>
                </h2>

                <table border="1">
                  <tr>
                    <th/>
                    <xsl:for-each select="$hex/*">
                      <th><xsl:value-of select="."/></th>
                    </xsl:for-each>
                  </tr>

                  <xsl:for-each select="$hex/*">
                    <xsl:variable name="r" select="."/>

                    <tr>
                      <th><xsl:value-of select="$r"/></th>
                      <xsl:for-each select="$hex/*">
                        <td>
                          <!-- single codepoint to string -->
                          <xsl:value-of disable-output-escaping="yes" 
                            select="concat('&amp;#x',$h,$l,$r,.,';')"/>
                        </td>
                      </xsl:for-each>
                    </tr>
                  </xsl:for-each>
                </table>
              </td>
            </xsl:for-each>
          </tr>
        </xsl:for-each>
      </table>
    </html>
  </xsl:template>

</xsl:stylesheet>