[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

question?

  • From: "Michael O' Dell" <maod@h...>
  • To: xml-dev@x...
  • Date: Thu, 15 Jun 2000 10:19:25 GMT

xsl division
Hello all,

Apologies for this 'newbie' question, yet again.

The following, when parsed through XSL transformations, works, but I don't 
know why. To me, it appears, (if I were to draw this in a graphical form) 
that this shouldn't work, but it does... Why?

Your answers / help / suggestions are appreciated.

Cheers,

Michael

------

Here is the XML document:

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

<sales>
   <division id="North">
      <revenue>10</revenue>
      <growth>9</growth>
      <bonus>7</bonus>
      <description>This is a test <link url="localhost">link                 
       stuff</link> embedded.
      </description>
   </division>
   <division id="South">
      <revenue>4</revenue>
      <growth>3</growth><bonus>4</bonus>
      <description>...And in this test, the link is embedded really          
really deep in the text <link url="localhost">link 2
         stuff</link> embedded. No worries, it seems.
      </description>
   </division>
   <division id="West">
      <revenue>6</revenue>
      <growth>-1.5</growth>
      <bonus>2</bonus>
      <description><link url="localhost">How about starting with a          
link</link>, cool heh! </description>
   </division>
</sales>

------

Here is the XSL:

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

<xsl:template match="/">
<html xsl:version="1.0"    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
lang="en">
   <head>
      <title>Sales Results By Division</title>
   </head>
   <body>
      <table border="1">
         <tr>
            <th>Division</th>
            <th>Revenue</th>
            <th>Growth</th>
            <th>Bonus</th>
         </tr>

         <xsl:for-each select="sales/division">
         <!-- order the result by revenue -->
            <xsl:sort select="revenue" data-type="number"                 
order="descending"/>

               <tr>
                  <td>
                     <em><xsl:value-of select="@id"/></em>
                  </td>
                  <td>
                     <xsl:value-of select="revenue"/>
                 </td>
                 <td>

                    <!-- highlight negative growth in red -->
                    <xsl:if test="growth &lt; 0">
                       <xsl:attribute name="style"> 								                 
                                    <xsl:text>color:red</xsl:text>
                       </xsl:attribute>
                    </xsl:if>
                   <xsl:value-of select="growth"/>
                </td>
                <td>
                   <xsl:value-of select="bonus"/>
                </td>
                <td>
                   <xsl:apply-templates select="description"/>
                </td>
             </tr>
         </xsl:for-each>
	</table>
	</body>
</html>
</xsl:template>

<xsl:template match="description">
	<xsl:apply-templates />
</xsl:template>

<xsl:template match="link">
	<a href="{@url}">
		<xsl:value-of select="." />
	</a>
</xsl:template>

</xsl:stylesheet>
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


***************************************************************************
This is xml-dev, the mailing list for XML developers.
To unsubscribe, mailto:majordomo@x...&BODY=unsubscribe%20xml-dev
List archives are available at http://xml.org/archives/xml-dev/
***************************************************************************

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.