XSL

G. Ken Holman gkholman at CraneSoftwrights.com
Wed Jan 13 18:36:47 GMT 1999


At 99/01/13 12:00 -0500, Dante Lee wrote:
>Can anyone give me a working example of an XSL document that IE 5.0 will
>support?
>
>
>	          Dante M. Lee    Code 588
>        	NASA/GSFC Greenbelt MD 20771
> 	Voice = 301-521-1077   Bldg = 23  Rm = W415 
> 	  Email = dante at mstirling.gsfc.nasa.gov
>                  dante4 at hotmail.com
   

This would have been better posted to:

   http://www.mulberrytech.com/xsl/xsl-list

Here is an example XSL script ... save it in a directory and name the file
"card.msxsl":

==============================8<--------------------------------
<?xml version='1.0'?>
<xsl:stylesheet
       xmlns:xsl="http://www.w3.org/TR/WD-xsl"
       xmlns="http://www.w3.org/TR/REC-html40"
       result-ns="">

<!--
PUBLIC "+//ISBN 1-894049::CSL::Demo::Card//DOCUMENT Card Stylesheet//EN"

http://www.CraneSoftwrights.com

CAVEAT - The XSL syntax used in this file follows only a working draft of
         the XSL Specification and is not necessarily representative of 
         any finalized or authorized specification.
-->

<!-- default behaviour - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<xsl:template><xsl:apply-templates/></xsl:template>
<xsl:template match="textnode()"><xsl:value-of/></xsl:template>

<!-- selective behaviour - - - - - - - - - - - - - - - - - - - - - - - - -->

<xsl:template match="/">                    <!-- root rule -->
    <html>
      <head>
        <title><xsl:value-of select="/card/name"/></title>
      </head>
      <body>
        <xsl:apply-templates/>
      </body>
    </html>
</xsl:template>

<xsl:template match='name'><!--process all children-->
    <h1>
      <xsl:apply-templates/> (<xsl:value-of select="/card/code"/>)</h1>
</xsl:template>

<xsl:template match="code"/><!--not processed by default-->

<xsl:template match="voice">
    <p><i><xsl:apply-templates/></i></p>
</xsl:template>

<xsl:template match="email"><!--build proper link to mail subsystem-->
    <p><a><xsl:attribute name="href">mailto:<xsl:value-of select="."
                                   /></xsl:attribute>
          <xsl:value-of select="."/></a></p>
</xsl:template>

<xsl:template match="location"><!--create a table with the info-->
    <table border="1">
      <tr><td align="center" colspan="2">
            <xsl:apply-templates select="office"/></td></tr>
      <tr>
        <td width="50%">Building: <xsl:apply-templates select="bldg"/></td>
        <td width="50%">Room: <xsl:apply-templates select="room"/></td>
      </tr>
    </table>
</xsl:template>

</xsl:stylesheet>
==============================8<--------------------------------

Here is an example XML file, save it in the same directory:

==============================8<--------------------------------
<?xml version="1.0"?>
<?xml:stylesheet type="text/xsl" href="card.msxsl"?>
<card>
<name>Dante M. Lee</name>
<code>588</code>
<voice>301-521-1077</voice>
<location>
<office>NASA/GSFC Greenbelt MD 20771</office>
<bldg>23</bldg>
<room>W415</room>
</location>
<email>dante at mstirling.gsfc.nasa.gov</email>
<email>dante4 at hotmail.com</email>
</card>

==============================8<--------------------------------

If you use IE5b2, then directly viewing the XML file will style it for
rendering.

I hope this helps.

...... Ken


--
G. Ken Holman         mailto:gkholman at CraneSoftwrights.com
Crane Softwrights Ltd.  http://www.CraneSoftwrights.com/x/
Training:   http://www.CraneSoftwrights.com/x/schedule.htm
Resources: http://www.CraneSoftwrights.com/x/resources.htm
Shareware: http://www.CraneSoftwrights.com/x/shareware.htm
Next XSL Training (see training link):   WWW8 - 1999-05-11

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list