XML Tutorial/XSLT stylesheet/character map

Материал из Web эксперт
Перейти к: навигация, поиск

character-map

File: Transform.xslt
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" use-character-maps="sample"/>
  <xsl:character-map name="sample" use-character-maps="circles">
    <xsl:output-character character="&#x9;" string="  "/>
  </xsl:character-map>
  <xsl:character-map name="circles">
    <xsl:output-character character="&#x2780;" string="&lt;img src="images/circle1.gif" width="28" height="28"/&gt;"/>
    <xsl:output-character character="&#x2781;" string="&lt;img src="images/circle2.gif" width="28" height="28"/&gt;"/>
  </xsl:character-map>
  <xsl:template match="char-test">
    <html>
      <head>
        <title>title</title>
      </head>
      <body>
        <xsl:apply-templates select="*"/>
      </body>
    </html>
  </xsl:template>
  <xsl:template match="tabs">
    <pre>
      <xsl:value-of select="."/>
    </pre>
  </xsl:template>
  <xsl:template match="special-char">
    <p style="font-size: 200%;">
      <xsl:text>Here"s a special character: </xsl:text>
      <xsl:value-of select="."/>
    </p>
  </xsl:template>
</xsl:stylesheet>