diff html.xsl @ 5:b3644dff344c

Way too much changes. :/
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 22 Aug 2011 20:30:51 +0200
parents f82309a9465e
children 79dfd9765a67
line wrap: on
line diff
--- a/html.xsl
+++ b/html.xsl
@@ -1,36 +1,37 @@
 <?xml version="1.0" encoding="utf-8"?>
 <x:stylesheet version="1.0"
+	exclude-result-prefixes="o h"
 	xmlns:x="http://www.w3.org/1999/XSL/Transform"
 	xmlns:o="urn:opcodes:description"
+	xmlns:h="http://www.w3.org/1999/xhtml"
 	xmlns="http://www.w3.org/1999/xhtml">
 
 	<x:output encoding="utf-8" indent="yes" method="xml" />
 
 	<x:template match="/o:opcodes">
-		<x:processing-instruction name="xml-stylesheet">type="text/css" href="../style.css"</x:processing-instruction>
 		<html>
 			<head>
 				<title><x:value-of select="o:title"/></title>
 			</head>
 			<body>
 				<h1><x:value-of select="o:title"/></h1>
-				<x:apply-templates select="o:text"/>
+
+				<x:for-each select="o:text/h:div/*">
+					<x:call-template name="xhtml"/>
+				</x:for-each>
+
 				<x:apply-templates select="o:op"/>
 			</body>
 		</html>
 	</x:template>
 
-	<x:template match="o:text">
-		<div><x:apply-templates/></div>
-	</x:template>
-
 	<x:template match="o:op">
-		<h2 id="i{o:num}">
+		<h3 id="i{o:num}">
 			<x:value-of select="o:num"/>
 			<x:if test="o:name != ''">
-				- <small><x:value-of select="o:name"/></small>
+				<x:text> - </x:text><small><x:value-of select="o:name"/></small>
 			</x:if>
-		</h2>
+		</h3>
 		
 		<x:choose>
 			<x:when test="o:params">
@@ -41,16 +42,18 @@
 			</x:otherwise>
 		</x:choose>
 
-		<p><x:apply-templates select="o:desc"/></p>
+		<x:apply-templates select="o:desc"/>
 	</x:template>
 
 	<x:template match="o:params">
 		<table>
 			<tr>
 				<th>Type</th>
-				<th>Description</th>
+				<x:if test="o:param/@name"><th>Name</th></x:if>
+				<x:if test="o:param/@unit"><th>Unit</th></x:if>
+				<x:if test="o:param/@var"><th>Variable</th></x:if>
+				<x:if test="o:param != ''"><th>Notes</th></x:if>
 				<x:if test="o:param/@values"><th>Values</th></x:if>
-				<x:if test="o:param/@min and o:param/@max"><th>Range</th></x:if>
 			</tr>
 			<x:apply-templates select="o:param"/>
 		</table>
@@ -59,14 +62,20 @@
 	<x:template match="o:param">
 		<tr>
 			<td><x:apply-templates select="@type"/></td>
-			<td><x:value-of select="."/></td>
-			<x:if test="@values">
+			<x:if test="../o:param/@name">
+				<td><x:value-of select="@name"/></td>
+			</x:if>
+			<x:if test="../o:param/@unit">
+				<td><x:value-of select="@unit"/></td>
+			</x:if>
+			<x:if test="../o:param/@var">
+				<td><x:value-of select="@var"/></td>
+			</x:if>
+			<x:if test="../o:param != ''">
+				<td><x:value-of select="."/></td>
+			</x:if>
+			<x:if test="../o:param/@values">
 				<td><x:value-of select="@values"/></td>
-				<x:if test="../o:param/@min and ../o:param/@max"><td/></x:if>
-			</x:if>
-			<x:if test="@min and @max">
-				<x:if test="../o:param/@values"><td/></x:if>
-				<td><x:value-of select="@min"/> to <x:value-of select="@max"/></td>
 			</x:if>
 		</tr>
 	</x:template>
@@ -98,16 +107,14 @@
 		</x:choose>
 	</x:template>
 
-	<x:template match="o:p">
-		<p><x:apply-templates/></p>
+	<x:template name="xhtml" match="node() | @*">
+		<x:copy>
+			<x:apply-templates select="node() | @*" />
+		</x:copy>
 	</x:template>
 
-	<x:template match="o:strong">
-		<strong><x:value-of select="."/></strong>
-	</x:template>
-
-	<x:template match="o:i">
-		<i><x:value-of select="."/></i>
+	<x:template match="o:p">
+		<p><x:apply-templates/></p>
 	</x:template>
 
 	<x:template match="o:br">
@@ -123,10 +130,20 @@
 	</x:template>
 
 	<x:template match="o:stage">
-		stage <x:value-of select="."/>
+		<x:text>stage </x:text><x:value-of select="."/>
 	</x:template>
 
 	<x:template match="o:ref">
-		<a href="#i{.}">instruction <x:value-of select="."/></a>
+		<x:variable name="ref" select="."/>
+		<a href="#i{$ref}">
+			<x:choose>
+				<x:when test="/o:opcodes/o:op[o:num = $ref]/o:name = ''">
+					<x:text>instruction </x:text><x:value-of select="$ref"/>
+				</x:when>
+				<x:otherwise>
+					<x:value-of select="/o:opcodes/o:op[o:num = $ref]/o:name"/>
+				</x:otherwise>
+			</x:choose>
+		</a>
 	</x:template>
 </x:stylesheet>