xsl:copy-of

only for RuBoard

xsl:copy-of

xsl:copy-of inserts subtrees into the result document without converting the result into a string.

It's similar to xsl:copy , but provides an explicit select attribute to specify the fragment to be included.

Attributes

Attribute Name

Enforced

Description

Values

Select

Required

The name of the template rule to call

QName

Example

Given the XML instance document, links.xml .

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

The preceding stylesheet used for the xsl:copy example is modified so that only a single template rule is needed to match the root node. The character entity reference &#035; is used to display the pound ( # ) symbol because the # symbol has meaning in XSLT.

 <?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:copy-of select="@*  node()" />            </xml>            <table border="1" datasrc="&#035;dataisland">                 <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:stylesheet> 

This results in the following output, which is the same output yielded in the xsl:copy example.

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

When this document is viewed in Internet Explorer 5.0 or higher as an HTML document, the following HTML table is visible in the browser.

NewRiders.com

www.newriders.com

Xmlandasp.net

www.xmlandasp.net

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

None.

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