RE: [xsl] ANN: 'Testing XSLT' training course PDF available

Subject: RE: [xsl] ANN: 'Testing XSLT' training course PDF available
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 14 Dec 2007 13:36:28 -0000
>   Mmh, what do you think, in this context, about something 
> that looks like the following:
> 
>     <t:tests>
>       <t:title>Fibonacci</t:title>
>       <t:test>
> 	<t:assert expect="0" select="my:fibonacci(0)"/>
>       </t:test>
>       <t:test>


Clearly functions are ideal for unit testing because unlike templates they
have no context dependencies. But I think you can do it with templates too.
I often exploit the XSLT 2.0 feature that allows a stylesheet to be executed
starting at a named template; you can insert a named template that is there
solely for testing purposes, for example

<xsl:template name="test-table-rendition">
  <xsl:apply-templates select="(//table)[1]"/>
</xsl:template>

or if you prefer you can compare the output with expected results using
deep-equal().

Having said that, my main use for this technique is with a multi-phase
stylesheet, allowing each phase to be tested independently of the others.

Michael Kay
http://www.saxonica.com/

Current Thread