English | Français | Deutsch | >> Magyar << | 中文 | Polski ZVON > Tutorials > XSLT Tutorial
>> Oldal 24 << | Előző | Következő | Tartalom | Elem index

A copy és a copy-of instrukciók az elemek másolására szolgálnak. A copy elem csak az aktuális elemet másolja, annak gyerekei és attribútumai nélkül, míg a copy-of mindent másol.

XSLT stíluslap 1

XML forrás
<source>

<p id="a12"> Compare
     <B>these constructs</B>.
</p>

</source>

Kimenet
<DIV>
  <B>copy-of : </B>
  <p id="a12">
Compare <B>these constructs</B>.
</p>
</DIV>
<DIV>
  <B>copy : </B>
  <p/>
</DIV>
<DIV>
  <B>value-of : </B>
Compare these constructs.
</DIV>

HTML nézet
copy-of :

Compare these constructs.

copy :

value-of : Compare these constructs.
XSLT stíluslap
<xsl:stylesheet version = '1.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:template match="p">
     <DIV>
          <B>
               <xsl:text>copy-of : </xsl:text>
          </B>
          <xsl:copy-of select="."/>
     </DIV>
     <DIV>
          <B>
               <xsl:text>copy : </xsl:text>
          </B>
          <xsl:copy/>
     </DIV>
     <DIV>
          <B>
               <xsl:text>value-of : </xsl:text>
          </B>
          <xsl:value-of select="."/>
     </DIV>
</xsl:template>


</xsl:stylesheet>