XSLT <xsl:import>要素
完全なXSLT要素リファレンス
定義と使い方
<xsl:import> 要素はトップレベル要素であり、あるスタイルシートの内容を別のスタイルシートにインポートするために使用されます。
注意:インポートされたスタイルシートの優先度は、インポートするスタイルシートよりも低くなります。
注意:この要素は、<xsl:stylesheet> または <xsl:transform> の最初の子ノードである必要があります。
構文
<xsl:import href="URI.html"/>
属性
| 属性 | 值 | 説明 |
|---|---|---|
| href | URI | 必須。インポートするスタイルシートの URI を指定します。 |
例 1
あなたが "cdcatalog_ex3.xsl" という名前のスタイルシートを持っていると仮定します:
<?xml version="1.0" encoding="ISO-8859-1"?>
<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>
<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>
2番目の "cdcatalog_import.xsl" という名前のスタイルシートは、"cdcatalog_ex3.xsl" をインポートします:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="cdcatalog_ex3.xsl.html"/>
<xsl:template match="/">
<xsl:apply-imports/>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="cdcatalog_ex3.xsl.html"/>
<xsl:template match="/">
<xsl:apply-imports/>
</xsl:template>
</xsl:stylesheet>
、 、 。
注意:この例は Netscape 6 では実行できません。Netscape 6 が <xsl:apply-imports> 要素をサポートしていないためです。
完全なXSLT要素リファレンス その他の拡張機能