Microsoft HomeproductssearchsupportshopWrite Us   Microsoft Home
Magazine
 |  Community
 |  Workshop
 |  Tools & Samples
 |  Training
 |  Site Info

Workshop  |  XML (Extensible Markup Language)

XSL Elements


XSL can be used to manipulate, sort, and filter XML data. Many transformations will target well-formed HTML. Well-formed means that any HTML tag can be used, subject to the stricter syntax rules of XML—all start tags are paired with end tags and are nested correctly. Well-formed HTML can be displayed by the browser, or further manipulated by XML tools. The W3C is currently working on making the next generation of HTML an XML application. The http://www.w3.org/MarkUp/Activity.html Non-MS link page describes some of the benefits of defining well-formed HTML. XSL is a valuable tool for generating well-formed HTML or other XML files.

XSL enables you to define templates for your output into which data from the XML source is delivered. Each template defines a pattern that identifies elements in the source tree and defines the resulting output subtree to be generated. The XSL transformation processor merges data from the XML source document with the template. Advanced users can also create complex combinations of multiple templates.

XSL templates are defined using a small set of XML elements, listed below and described in this reference documentation.

XSL Elements

xsl:apply-templates Directs the XSL processor to find the appropriate template to apply based on the results of the pattern.
xsl:attribute Creates an attribute node and attaches it to the output element.
xsl:cdata Generates a CDATA section in the output.
xsl:choose Provides multiple conditional testing; used with the xsl:otherwise and xsl:when elements.
xsl:comment Generates a comment in the output.
xsl:copy Copies the target node from the source to the output.
xsl:define-template-set Defines a set of templates at a particular level of scope.
xsl:element Creates an element with the specified name in the output.
xsl:entity-ref Generates an entity reference with the specified name in the output.
xsl:eval Computes a string of generated text.
xsl:for-each Allows application of the same template to multiple nodes.
xsl:if Allows conditional subpatterns within a template.
xsl:node-name Inserts the name of the current node as a text string.
xsl:otherwise Provides multiple conditional testing; used with the xsl:choose and xsl:when elements.
xsl:pi Generates a processing instruction in the output.
xsl:script Defines global variable declarations and functions.
xsl:stylesheet Defines the set of templates to be applied to the input source tree to generate the output source tree.
xsl:template Defines a template for the output of nodes of a specific pattern.
xsl:value-of Evaluates an XSL pattern in the select attribute and returns the value of the requested node as text, which is inserted into the template.
xsl:when Provides multiple conditional testing; used with the xsl:choose and xsl:otherwise elements.

Remarks

Most users will be interested in defining a single template for the output document. For example, an HTML output document starts with the <HTML> tag. You can also start directly with a single xsl:template element. Well-formed HTML can be mixed with elements from the xsl namespace to bind the XML data from the source document into the template.

In addition to the simple and straightforward use of templates, the Microsoft implementation supports combinations of templates that can support complex and sophisticated transformations. You can combine a set of xsl:template elements into an xsl:stylesheet element that defines different output templates. Processing begins with the "root template," indicated by the pattern "/".

XSL allows you to define script functions and perform calls to these functions within the XSL elements. XSL is scripting-language neutral, so an appropriate language can be used in each situation.

See Also

XML DOM Objects, Direct Browsing of XML Files


Does this content meet your programming needs? Write us!

Back to topBack to top

© 1998 Microsoft Corporation. All rights reserved. Terms of use.

 

Magazine Home
Ask Jane
DHTML Dude
Extreme XML
For Starters
More or Hess
Servin' It Up
Site Lights
Web Men Talking
Member Community Home
Benefits: Freebies & Discounts
Benefits: Promote Your Site
Benefits: Connect with Your Peers
Benefits at a Glance
Online Special-Interest Groups
Your Membership
SBN Stores
Join Now
Workshop Home
Essentials
Content & Component Delivery
Component Development
Data Access & Databases
Design
DHTML, HTML & CSS
Extensible Markup Language (XML)
Languages & Development Tools
Messaging & Collaboration
Networking, Protocols & Data Formats
Reusing Browser Technology
Security & Cryptography
Server Technologies
Streaming & Interactive Media
Web Content Management
Workshop Index
Tools & Samples Home
Tools
Samples, Headers, Libs
Images
Sounds
Style Sheets
Web Fonts
Training Home
SBN Live Seminars
SBN Live Chats
Courses
Peer Support
CD-ROM Training
Books & Training Kits
Certification
SBN Home
New to SBN?
What's New on SBN
Site Map
Site Search
Glossary
Write Us
About This Site