<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="books">
	<html><head><title>Test</title></head>
	<body bgcolor="tan">

	<xsl:apply-templates/>

	</body></html>
</xsl:template>

<xsl:template match="book">
	<xsl:for-each select="name">
		<p>
			[Current node] <xsl:value-of select="."/>
			<xsl:text>  (</xsl:text>
				<xsl:value-of select="@language"/>
			<xsl:text>)  </xsl:text>

			<xsl:if test="@language = 'eng'">
				<i>The English version is available.</i>
			</xsl:if>

			<blockquote><hr />
				<xsl:text>Test of using XPath expressions. 
					Here is the child . operator: </xsl:text>
				<font face="Verdana"><xsl:value-of select="."/></font>
			</blockquote>
			<blockquote><hr />
				<xsl:text>Here is the parent .. operator: </xsl:text>
				<font face="Verdana"><xsl:value-of select=".."/></font>
			</blockquote>

			<blockquote><hr />
				<xsl:text>Here is the /sibling operator applied to isbn: </xsl:text><br/>
				<xsl:text>../nodeName  - here ../isbn</xsl:text><br/>
				<font face="Verdana"><xsl:value-of select="../isbn"/></font>
			</blockquote>

			<blockquote><hr />
				<xsl:text>Here is the wildcard operator * : </xsl:text><br/>
				<xsl:text>Recall the .. means select the node's parent and * means then show whatever you got there!</xsl:text>
				<xsl:text>../*</xsl:text><br/>
				<font face="Verdana"><xsl:value-of select="../*"/></font>
			</blockquote>


			<blockquote><hr />
				<xsl:text>The double slash // selects all of the descendants of the root node.: </xsl:text><br/>
				<xsl:text>//book</xsl:text><br/>
				<font face="Verdana"><xsl:value-of select="//book"/></font>
			</blockquote>


			<blockquote><hr />
				<xsl:text>Skip the current note to go from root to element: </xsl:text><br/>
				<xsl:text>/root/[elements], e.g., /books/book/editors/editor</xsl:text><br/>
				<font face="Verdana"><xsl:value-of select="/books/book/editors/editor"/></font>
			</blockquote>

			<blockquote><hr />
				<xsl:text>To test whether an element even has an attribute: </xsl:text><br/>
				<xsl:text>use [ then the expression and then ]  e.g., [@language="eng"]</xsl:text><br/>
				<xsl:text>Or even to test the node location, e.g., [position() = last()]</xsl:text><br/>
				<font face="Verdana">
					<xsl:value-of select="name[@language='eng']"/>
					<xsl:value-of select="."/>
				</font>

				<font face="Verdana" size="-2">Position test (last) 
					<xsl:value-of select="name[@language='eng'] [position()=last()]"/>
					<xsl:value-of select="."/>Test of being last English node
				</font>
			</blockquote>

		</p>

		<hr />
			This is a test.  The cost for the book is $<xsl:value-of select="../cost" />.<br/>
			<font size="-2">
			<xsl:text>Note! Because we're in a for-each test only for the node "name", to 
			see the price (in the cost node) we have to go up to the grandparent and then 
			come back down the node tree 'til we find cost</xsl:text></font>

			<xsl:value-of select="."/>
				<xsl:choose>
					<xsl:when test=". &gt; 0 and . &lt; 33">
						<font color="green"> Great Price!  Buy it</font>
					</xsl:when>
					<xsl:otherwise>
						<font color="red">Kind of expensive; get the paperback.</font>
					</xsl:otherwise>
				</xsl:choose>
			<br/><br/>
			<xsl:text>Notice that if you read the .xsl file, you'll see the value-of statement here.
			Notice how the select points to .  [that's the current node] in otherwords we see the words
 			"welcome" - odd isn't it?!</xsl:text>
			
			<p align="center">END OF THE FOR-EACH</p>
	</xsl:for-each>
<p align="center">END OF THE TRANSFORMATIONS</p>
</xsl:template>



</xsl:stylesheet>