xsl:value-of

only for RuBoard

xsl:value-of

xsl:value-of inserts the value of the selected node as text.

Attributes

Attribute Name

Enforced

Description

Values

select

Required

Expression to be evaluated against the current context. The results are converted to a string.

Expression

disable-output- escaping

Optional

Determines if the result element should no longer be escaped. The default is no .

yes or no

Example

Consider the following XML file, 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 can be applied to the XML file to generate brackets around each of the values specified:

 <?xml version="1.0" encoding="UTF-8" ?>  <xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">       <xsl:template match="/">            <table>                 <xsl:for-each select="links/link">                      <tr>                                   <td>                                        <xsl:value-of select="@name" />                                   </td>                      </tr>               </xsl:for-each>            </table>       </xsl:template>  </xsl:stylesheet> 

This yields the following result:

 <?xml version="1.0" encoding="UTF-16"?>  <table><tr><td>NewRiders.com</td></tr><tr><td>Xmlandasp.net</td></tr><tr><td>MSDN Online graphics/ccc.gif Library</td></tr></table> 

If the select attribute's value yields more than one node in the result tree, only the first result node is returned. If the node has substructure , the child structure is concatenated to the result with markup removed. For example, consider the following XML document:

 <?xml version="1.0" encoding="utf-8" ?>  <paragraph>       <sentence>Click <href URL="http://msdn.microsoft.com">here</href> for the MSDN graphics/ccc.gif library.</sentence>       <sentence>This is another sentence.</sentence>       <sentence>This is yet another sentence.</sentence>  </paragraph> 

A stylesheet can be applied to this document that selects all sentence nodes:

 <?xml version="1.0" encoding="utf-8" ?>  <xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">       <xsl:template match="/">            <xsl:value-of select="paragraph/sentence" />       </xsl:template>  </xsl:stylesheet> 

Because more than one sentence node is returned by the select attribute, only the first is included in the result tree. Because the selected node has substructure, its child structure is also included in the result tree with markup removed:

 <?xml version="1.0" encoding="UTF-16"?>Click here for the MSDN 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

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