Login   Register  
PHP Classes
elePHPant
Icontem

File: myEngine/sample.xsl

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Tereshchenko Andrey  >  myEngine  >  myEngine/sample.xsl  >  Download  
File: myEngine/sample.xsl
Role: Auxiliary data
Content type: text/plain
Description: XSL example
Class: myEngine
Illustration of use XML/XSLT technology with PHP.
Author: By
Last change: -
Date: 2004-05-23 03:54
Size: 1,822 bytes
 

Contents

Class file image Download
<?xml version="1.0" encoding="Windows-1251"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

  <xsl:template match="/">
    <html>
      <head>
	      <title>myEngine example</title>
	    </head>
	    <body style="margin: 10%; font-family: Courier New;">
	      <center><h1>myEngine example</h1></center>
        <p><center><?php return SAMPLE_TEXT; ?></center></p>
        <xsl:apply-templates />
	    </body>
	  </html>
  </xsl:template>
  
  <xsl:template match="books">
    <TABLE style="width: 100%">
      <THEAD>
        <TH>#</TH><TH>Title</TH><TH>Author</TH><TH>Price</TH>
      </THEAD>
      <xsl:for-each select="book">
        <TR>
		      <xsl:choose>
		        <xsl:when test="position() mod 3 = 0">
			        <xsl:attribute name="style">background-color: #FAF0E6</xsl:attribute>
			      </xsl:when>
			      <xsl:when test="position() mod 3 = 1">
			        <xsl:attribute name="style">background-color: #B0C4DE</xsl:attribute>
			      </xsl:when>
			      <xsl:otherwise>
			        <xsl:attribute name="style">background-color: #98FB98</xsl:attribute>
			      </xsl:otherwise>
		      </xsl:choose>
          <TD><xsl:value-of select="@id"/></TD>
          <xsl:apply-templates />
        </TR>
      </xsl:for-each>
    </TABLE>
  </xsl:template>
  
  <xsl:template match="title">
    <TD style="width: 40%">
      <xsl:apply-templates />
    </TD>
  </xsl:template>
  
  <xsl:template match="author">
    <TD style="width: 30%">
      <xsl:apply-templates />
    </TD>
  </xsl:template>
  
  <xsl:template match="price">
    <TD>
      <xsl:apply-templates />
    </TD>
  </xsl:template>
  
  <xsl:template match="node()">
    <xsl:copy>
      <xsl:apply-templates />
    </xsl:copy>
  </xsl:template>
  
</xsl:stylesheet>