Re: Some draft code for mobileOK Basic Tests RI

> Purely as a recreational exercise this is along similar lines:
>
> http://rabin.mobi/r/format?uri=http://t-mobile.mobi
Very cool!
Here the beginning of a small XSLT that checks the output.
The complete page size is checked and if all links has an accesskey  
with a keypad number.

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

   <xsl:output method="xml" indent="yes"/>

   <xsl:template match="/">
     <result>
       <!-- page checks -->
       <xsl:call-template name="testCompletePageSize"/>

       <!-- element checks -->
       <xsl:apply-templates select="//tidiedPayload"/>
     </result>
   </xsl:template>


   <!--
       link validation
   -->
   <xsl:template match="*[local-name() = 'a']">
     <check name="linkAccessKey" value="{@accesskey}">
       <xsl:attribute name="linkAccessKey" >
	<xsl:choose>
	  <xsl:when test="number(@accesskey) &gt;= 0 and number(@accesskey)  
&lt;= 9">passed</xsl:when>
	  <xsl:otherwise>failed</xsl:otherwise>
	</xsl:choose>
       </xsl:attribute>
     </check>
     <xsl:apply-templates/>
   </xsl:template>

   <xsl:template match="node()">
     <xsl:apply-templates/>
   </xsl:template>


   <!--
       page size check
   -->
   <xsl:template name="testCompletePageSize">
     <xsl:variable name="completePageSize" select="sum(//payload/ 
@size)"/>
     <check name="completePageSize" value="{$completePageSize}">
       <xsl:attribute name="result">
	<xsl:choose>
	  <xsl:when test="$completePageSize &gt; 10000">failed</xsl:when>
	  <xsl:otherwise>passed</xsl:otherwise>
	</xsl:choose>
       </xsl:attribute>
     </check>
   </xsl:template>
</xsl:stylesheet>

Received on Thursday, 8 February 2007 13:57:57 UTC