xsl:if 記述例

ソースXML文書

<?xml version="1.0" encoding="Shift_JIS" ?>
<book>
  <title code="ab1123">XMLマスターとは</title>
  <title code="ab1125">XML概説</title>
  <title code="ab2834">Java&amp;XML</title>
</book>

XSLTスタイルシート
<?xml version="1.0" encoding="Shift_JIS" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <magazine>
    <xsl:apply-templates />
    </magazine>
  </xsl:template>
  <xsl:template match="title">
   <xsl:if test="@code='ab1125'">
     <title><xsl:value-of select="." /></title>
   </xsl:if>
  </xsl:template>
</xsl:stylesheet>

結果XML文書
<?xml version="1.0" encoding="UTF-8"?>
<magazine>
  <title>XML概説</title>
</magazine>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License