XSLT - 外部ファイルの取り込み (xsl:import)Advertisement書式<xsl:import href="インポートするファイル"/> 例<xsl:import href="import.xsl"/>import.xsl の内容も参照する。 xsl:import 文より前に存在してよいのは xsl:import 文のみという制約があり、これが xsl:include との違いとなります。 サンプルコード
sample.xml
<?xml version="1.0" encoding="Shift_JIS"?>
<?xml-stylesheet type="text/xsl" href="./style.xsl"?>
<book>
<title>XML</title>
<price>1000</price>
</book>
style.xsl
<?xml version="1.0" encoding="Shift_JIS"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:import href="import.xsl"/> </xsl:stylesheet>import.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>
<title>XSLT</title>
</head>
<body>
<xsl:apply-templates select="book"/>
</body>
</html>
</xsl:template>
<xsl:template match="book">
<xsl:value-of select="title"/><br/>
<xsl:value-of select="price"/>
</xsl:template>
</xsl:stylesheet>
生成されるコード
<html> <head> <title>XSLT</title> </head> <body> XML<br /> 1000 </body> </html> Advertisement |
ショートカット・634・634ブログ ・このカテゴリのトップページに戻る ・Incubator(Pukiwiki) ・634ラボ UIコレクションギャラリー ZO-3ジェネレーター サイト検索Y!ログール |