XSLT <xsl:import>
❮完全なXSLT要素リファレンス
定義と使用法
<xsl:import>要素は、あるスタイルシートのコンテンツを別のスタイルシートにインポートするために使用される最上位の要素です。
注:インポートされたスタイルシートは、インポートされたスタイルシートよりも優先順位が低くなります。
注:この要素は、<xsl:stylesheet>または<xsl:transform>の最初の子ノードとして表示される必要があります。
構文
<xsl:import href="URI"/>
属性
Attribute | Value | Description |
---|---|---|
href | URI | Required. Specifies the URI of the style sheet to import |
例1
「cdcatalog_ex3.xsl」というスタイルシートがあるとします。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<tr>
<td><xsl:value-of select="catalog/cd/title"/></td>
<td><xsl:value-of select="catalog/cd/artist"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
「cdcatalog_import.xsl」と呼ばれる2番目のスタイルシートは「cdcatalog_ex3.xsl」をインポートします。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="cdcatalog_ex3.xsl"/>
<xsl:template match="/">
<xsl:apply-imports/>
</xsl:template>
</xsl:stylesheet>
❮完全なXSLT要素リファレンス