OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   question?

[ Lists Home | Date Index | Thread Index ]
  • From: "Michael O' Dell" <maod@hotmail.com>
  • To: xml-dev@xml.org
  • Date: Thu, 15 Jun 2000 10:19:25 GMT

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@xml.org&BODY=unsubscribe%20xml-dev
List archives are available at http://xml.org/archives/xml-dev/
***************************************************************************




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS