On Dec 14, 2007 7:06 PM, Michael Kay <mike(_at_)saxonica(_dot_)com> wrote:
Clearly functions are ideal for unit testing because unlike templates they
have no context dependencies.
Thanks Mike for reminding about this. I had a feeling, that unit
testing is better possible with XSLT 2.0 ...
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().
I would ideally like - Have the original stylesheet (which is
undergoing testing) *unmodified*.
Write a unit testing stylesheet (which is like 1 unit test), which can
test some aspect of the original stylesheet (like a function), or
possibly test the whole stylesheet as a unit (and use deep-equal()
function to compare the expected output with the received output - but
this seems not possible without inserting a named template in the main
stylesheet).
Your named template approach, will modify the main stylesheet, which
is unlike JUnit.
Ofcouse, we can live with some limitations :)
Please correct me if I am wrong ...
--
Regards,
Mukul Gandhi
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--