XSLTノードのコピー (xsl:copy)Advertisement書式
<xsl:copy>
コピーするノードを指定
<xsl:/copy>
例
<xsl:copy>
<xsl:apply-templates select="test"/>
<xsl:/copy>
test というノードをコピーする
サンプルコード
sample.xml
<?xml version="1.0" encoding="Shift_JIS"?>
<?xml-stylesheet type="text/xsl" href="./style.xsl"?>
<document>
<book>
<title>AAA</title>
<price>4000</price>
</book>
<book>
<title>BBB</title>
<price>1000</price>
</book>
<book>
<title>CCC</title>
<price>2000</price>
</book>
<book>
<title>DDD</title>
<price>1500</price>
</book>
<book>
<title>EEE</title>
<price>500</price>
</book>
</document>
style.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="/">
<pricelist>
<xsl:apply-templates select="document/book"/>
</pricelist>
</xsl:template>
<xsl:template match="book">
<xsl:copy>
<xsl:apply-templates select="price"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
生成されるコード
<pricelist>
<price>4000</price>
<price>1000</price>
<price>2000</price>
<price>1500</price>
<price>500</price>
</pricelist>
Advertisement |
ショートカット・634・634ブログ ・このカテゴリのトップページに戻る ・Incubator(Pukiwiki) ・634ラボ UIコレクションギャラリー ZO-3ジェネレーター サイト検索Y!ログール |