spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / authoring / languages / xml / insidexslt / chap2 / 2 To page 1current pageTo page 3To page 4To page 5
[previous] [next]

Inside XSLT

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

In practice, <?xsl:stylesheet?> is used mostly with browsers, because with standalone processors, you usually give the name of the stylesheet document directly, as when you use the Oracle XSLT processor this way:

C:\planets>java oracle.xml.parser.v2.oraxsl planets.xml planets.xsl planets.html

In fact, it may surprise you to learn that <?xsl:stylesheet?> is not part of the XSLT recommendation. This processing instruction has its own recommendation just for itself, which you can find at www.w3c.org/TR/xml-stylesheet. Among other things, this means that XSLT processors are not obliged to support this processing instruction, and most standalone processors do not.

Here's an example. In Chapter 1, you saw planets.xml, a well-formed XML document that holds data about three planets: Mercury, Venus, and the Earth. You can use the <?xml-stylesheet?> processing instruction in planets.xml to indicate what XSLT stylesheet to use, where you set the type attribute to "text/xml" (W3C also allows "application/xml", and the Internet Explorer requires "text/xsl") and the href attribute to the URI of the XSLT stylesheet, such as planets.xsl:

Listing 2.1: planets.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xml" href="planets.xsl"?>
<PLANETS>

 <PLANET>
    <NAME>Mercury</NAME>
    <MASS UNITS="(Earth = 1)">.0553</MASS>
    <DAY UNITS="days">58.65</DAY>
    <RADIUS UNITS="miles">1516</RADIUS>
    <DENSITY UNITS="(Earth = 1)">.983</DENSITY>
    <DISTANCE UNITS="million miles">43.4</DISTANCE><!--At perihelion-->
 </PLANET>

 <PLANET>
    <NAME>Venus</NAME>
    <MASS UNITS="(Earth = 1)">.815</MASS>
    <DAY UNITS="days">116.75</DAY>
    <RADIUS UNITS="miles">3716</RADIUS>
    <DENSITY UNITS="(Earth = 1)">.943</DENSITY>
    <DISTANCE UNITS="million miles">66.8</DISTANCE><!--At perihelion-->
 </PLANET>

 <PLANET>
    <NAME>Earth</NAME>
    <MASS UNITS="(Earth = 1)">1</MASS>
    <DAY UNITS="days">1</DAY>
    <RADIUS UNITS="miles">2107</RADIUS>
    <DENSITY UNITS="(Earth = 1)">1</DENSITY>
    <DISTANCE UNITS="million miles">128.4</DISTANCE><!--At perihelion-->
 </PLANET>

</PLANETS>

That's how to use the <?xml-stylesheet?> element; now it's time to start working on writing the stylesheet itself. I'll do that by creating planets.xsl.


home / authoring / languages / xml / insidexslt / chap2 / 2 To page 1current pageTo page 3To page 4To page 5
[previous] [next]

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint

Created: September 20, 2001
Revised: September 20, 2001


URL: http://webreference.com/authoring/languages/xml/insidexslt/chap2/2/2.html