スタイルシート変換言語 XSLT

<xsl:include>の解説です。  スタイルシート変換言語 XSLTリファレンス 

<xsl:include>

<xsl:include 
href="uri-reference" />
xsl:includeは、XSLTスタイルシート内に他のXSLTスタイルシートをインクルード(包括)します。 似たような機能を持つ要素に、xsl:importがありますが、 xsl:importが読み込む側(インポートしたファイルではない方)の内容を優先 するのに対し、xsl:includeではインクルードされた側のファイルの内容を優先します。
なお、xsl:includeはトップレベル要素の位置ならばどこにでも記述する事が可能です。、 (xsl:importはxsl:stylesheet要素の、子要素の先頭に記述する必要がありました。)
※同じファイルを複数回インクルードするとエラーになります。 、また循環参照する(自分自身を呼び出す)など、無限ループが発生するような記述をし ないように注意して下さい。
zipファイル 以下のサンプルをダウンロード(ZIP圧縮)
■ aaa.xml
<?xml version="1.0" encoding="Shift_JIS"?>
<?xml-stylesheet type="text/xsl" href="bbb.xsl"?>

<item>
<book>
<name>誰でも簡単XML</name>
<val>1800</val>
<stock>18</stock>
</book>

<book>
<name>XSLTを使いこなす</name>
<val>3200</val>
<stock>27</stock>
</book>

<book>
<name>楽々自動化「XML&XSLT」</name>
<val>2900</val>
<stock>10</stock>
</book>
</item>
■ bbb.xsl
<?xml version="1.0" encoding="Shift_JIS"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" href="ccc.css" />
</head>
<body>
 <table cellspacing="0">
  <tr>
   <th width="180">商品名</th>
   <th>価格</th>
   <th width="180">在庫数</th>
  </tr>
 
 <xsl:for-each select="item/book">
  <tr>
   <td>
   <xsl:value-of select="name" />
   </td>
   <td class="aka">
   <xsl:value-of select="val" />円
   </td>
   <td>
   <xsl:apply-templates select="." />
   </td>
  </tr>
 </xsl:for-each>
 </table>
</body>
</html>
</xsl:template>
<xsl:include href="ddd.xsl" />

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

<xsl:template match="book">
<xsl:value-of select="stock" />
<xsl:if test="stock &#60; 20"><span class="aka">(在庫数少)</span></xsl:if>
</xsl:template>

</xsl:stylesheet>
■ ccc.css
table {width:500px}
th {background-color:#99ff66;padding:3px}
td {padding:5px;line-height:150%;border-color:#333333;
border-width:1px;border-style:solid}
.aka {color:#990000}
サンプル
XSLT要素一覧
+ <xsl:apply-imports>
+ <xsl:apply-templates>
+ <xsl:attribute>
+ <xsl:attribute-set>
+ <xsl:call-template>
+ <xsl:comment>
+ <xsl:copy>
+ <xsl:copy-of>
+ <xsl:decimal-format>
+ <xsl:element>
+ <xsl:fallback>
+ <xsl:for-each>
+ <xsl:if>
+ <xsl:import>
+ <xsl:include>
+ <xsl:key>
+ <xsl:message>
+ <xsl:namespace-alias>
+ <xsl:number>
+ <xsl:otherwise>
+ <xsl:output>
+ <xsl:param>
+ <xsl:preserve-space>
+ <xsl:processing-instruction>
+ <xsl:sort>
+ <xsl:strip-space>
+ <xsl:stylesheet>
+ <xsl:template>
+ <xsl:text>
+ <xsl:value-of>
+ <xsl:variable>
+ <xsl:when>
+ <xsl:with-param>