Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


A Simple XSLT Stylesheet - Page 4

October 26, 2001

An XSLT transformation is specified by a well-formed XML document called a stylesheet. The key elements in a stylesheet are the specialized elements from the XSLT namespace. (A namespace is a unique name for a given set of element and attribute names. Their use is usually declared in an XML document’s document element with a short nickname that the document uses as a prefix for names from that namespace.) When an XSLT processor reads one of these stylesheets, it recognizes these specialized elements and executes their instructions.

XSLT stylesheets usually assign “xsl” as the prefix for the XSLT namespace (ironically, XSL stylesheets usually use the prefix “fo” to identify their “formatting objects”), and XSLT discussions usually refer to these element types using the “xsl” prefix. This way, when something refers to the xsl:text or xsl:message elements you can assume that they mean the text and message element types from the XSLT namespace and not from somewhere else.

An XSLT stylesheet doesn’t have to use “xsl” as the namespace prefix. For example, if the stylesheet below began with the namespace declaration

xmlns:harpo="http://www.w3.org/1999/XSL/Transform"

the stylesheet’s XSLT elements would need names like harpo:text and harpo: message for an XSLT processor to recognize them and perform their instructions.

The following stylesheet demonstrates many common features of an XSLT stylesheet. It’s a well-formed XML document with a root element of xsl:stylesheet. (You can also use name xsl:transform for your stylesheet’s root element, which means the same thing to the XSLT processor.):

<!-- xq15.xsl: converts xq16.xml into xq17.xml -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="year">
<vintage>
<xsl:apply-templates/>
</vintage>
</xsl:template>
<xsl:template match="price">
</xsl:template>
<!-- Copy all the other elements and attributes, and text nodes -->
<xsl:template match="*|@*|text()">
<xsl:copy>
<xsl:apply-emplates select="*|@*|text()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

XSLT and Alternatives (Con't) - Page 3
XSLT Quickly
Template Rules - Page 5


Up to => Home / Authoring / Languages / XSL / Quickly




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers