XSLT - ツリーのコピー(xsl:copy-of)Advertisement書式<xsl:copy-of select="要素名" /> 例
<!-- title要素以下のツリーをコピーする -->
<xsl:copy-of select="$title" />
サンプルコード
sample.xml
<?xml version="1.0" encoding="Shift_JIS"?>
<?xml-stylesheet type="text/xsl" href="./style.xsl"?>
<document>
<book id="10">
<title>やさしいXML入門<sub>基礎編</sub></title>
<price>2000</price>
</book>
<book id="20">
<title>やさしいXML入門<sub>応用編</sub></title>
<price>2000</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="book">
<xsl:copy-of select="title" />
</xsl:template>
</xsl:stylesheet>
生成されるコード
<?xml version="1.0" encoding="UTF-8"?> <title>やさしいXML入門<sub>基礎編</sub></title> <title>やさしいXML入門<sub>応用編</sub></title> Advertisement |
ショートカット・634トップページ・このカテゴリのトップページに戻る ・634ラボ サイト検索Y!ログール |