xsl:copy

only for RuBoard

xsl:copy

xsl:copy copies the current node to the result.

Attributes

Attribute Name

Enforced

Description

Values

use-attribute-sets

Optional

A white space-separated list of attribute sets

QName

Example

Consider the XML instance document, links.xml :

 <?xml version="1.0" encoding="utf-8" ?>  <links>       <link name="NewRiders.com" URL="http://www.newriders.com" />       <link name="Xmlandasp.net" URL="http://www.xmlandasp.net" />       <link name="MSDN Online Library" URL="http://msdn.microsoft.com/library"  />  </links> 

The following stylesheet uses the xsl:copy element to copy all elements and attributes by matching each attribute ( @* ) or element ( node() ) in the second template rule, which creates an XML data island that's bound to a table and is usable in Internet Explorer:

 <?xml version="1.0" encoding="UTF-8" ?>  <xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">      <xsl:template match="/">          <xml>             <xsl:attribute name="id">dataisland</xsl:attribute>            <xsl:apply-templates />         </xml>         <table>             <xsl:attribute name="datasrc">&#035;dataisland</xsl:attribute>            <tr>                <td>                    <div>                        <xsl:attribute name="datafld">name</xsl:attribute>                   </div>                </td>                <td>                   <div>                      <xsl:attribute name="datafld">URL</xsl:attribute>                   </div>                </td>            </tr>         </table>      </xsl:template>      <xsl:template match="@*  node()">         <xsl:copy>            <xsl:apply-templates select="@*  node()" />         </xsl:copy>      </xsl:template>  </xsl:stylesheet> 

This results in the following output:

 <?xml version="1.0" encoding="UTF-16"?>      <xml id="dataisland">          <links>           <link name="NewRiders.com" URL="http://www.newriders.com" />           <link name="Xmlandasp.net" URL="http://www.xmlandasp.net" />           <link name="MSDN Online Library" URL="http://msdn.microsoft.com/library" />        </links>      </xml>      <table datasrc="#dataisland">         <tr>             <td>                 <div datafld="name" />             </td>             <td>                 <div datafld="URL" />             </td>         </tr>       </table> 

When this code is displayed in Internet Explorer, version 5.0 or 5.5, the following HTML table is visible to the user .

NewRiders.com

www.newriders.com

Xmlandasp.net

www.xmlandasp.net

MSDN Online Library

http://msdn.microsoft.com/library

Parent Elements

 xsl:attribute, xsl:comment, xsl:copy, xsl:element, xsl:for-each, xsl:if,  xsl:otherwise, xsl:param, xsl:processing-instruction, xsl:template,  xsl:variable, xsl:when, xsl:with-param, output elements 

Child Elements

 xsl:apply-templates, xsl:attribute, xsl:call-template, xsl:choose,  xsl:comment, xsl:copy, xsl:copy-of, xsl:element, xsl:for-each, xsl:if,  xsl:processing-instruction, xsl:text, xsl:value-of, xsl:variable, output  elements 
only for RuBoard


XML and ASP. NET
XML and ASP.NET
ISBN: B000H2MXOM
EAN: N/A
Year: 2005
Pages: 184

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net