xsl:copy、xsl:copy-of 記述例

xsl:copy記述例

ソースXML文書

<?xml version="1.0" encoding="Shift_JIS"?>
<pet>
    <name eng="dog"></name>
</pet>

XSLTスタイルシート
<?xml version="1.0" encoding="Shift_JIS"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <xsl:apply-templates select="//name"/>
  </xsl:template>
 
  <xsl:template match="name">
    <xsl:copy/>  
  </xsl:template>
</xsl:stylesheet>

結果XML文書
<?xml version="1.0" encoding="UTF-8"?>
<name/>

xsl:copy-of記述例

ソースXML文書

<?xml version="1.0" encoding="Shift_JIS"?>
<pet>
    <name eng="dog"></name>
</pet>

XSLTスタイルシート
<?xml version="1.0" encoding="Shift_JIS"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template match="/">
   <xsl:apply-templates select="//name"/>
 </xsl:template>
 
 <xsl:template match="name">
   <xsl:copy-of select="."/>
 </xsl:template>
</xsl:stylesheet>

結果XML文書
<?xml version="1.0" encoding="UTF-8"?>
<name eng="dog"></name>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License