BizTalk Utilities CV ,   Jobs ,   Code library  
 
 
Page 5 of 15

 

Previous Page Table Of Contents Next Page

XSL Transformations, cont.

Getting the Value of Nodes with xsl:value-of

In this example, I'll extract the name of each planet and insert that name into the output document. To get the name of each planet, I'll use the <xsl:value-of> element in a template targeted at the <PLANET> element, and I'll select the <NAME> element with the select attribute like this:

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 

    <xsl:template match="PLANETS">

        <HTML>

            <xsl:apply-templates/>

        </HTML>

    </xsl:template>

 

    <xsl:template match="PLANET">

        <xsl:value-of select="NAME"/>

    </xsl:template>

 

</xsl:stylesheet>

Using select like this, you can select nodes. The select attribute is much like the match attribute of the <xsl:template> element, except that the select attribute is more powerful. With it, you can specify the node or nodes to select using the full XPath XML specification, as we'll see later in this chapter. The select attribute is an attribute of the <xsl:apply-templates>, <xsl:value-of>, <xsl:for-each>, and <xsl:sort> elements, all of which we'll also see in this chapter.

Applying the previous style sheet, the <xsl:value-of select="NAME"/> element directs the XSLT processor to insert the name of each planet into the output document, so that document looks like this:

<HTML>

 

  Mercury

 

  Venus

 

  Earth

 

</HTML>

 

Page 5 of 15

 

Previous Page Table Of Contents Next Page
 

Recent Jobs

Sr. Software Engineer - Analytics
Immediate Mainframe openings for Ch
Immediate TANDEM-TAL openings for C
Immediate ASP.NET/C# Openings for C
Sr. Software Engineer

View all Jobs (Add yours)
View all CV (Add yours)



teleconferencing service
water softener
Teleconference
Host Department NOLIMIT Web Hosting
MSN
sunglasses
fax.com


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP