xsl-list
[Top] [All Lists]

RE: [xsl] xslt test automation

2010-11-30 06:57:55
As an XProc implementer, I have found the XProc Test Suite format 
(http://tests.xproc.org) very useful for XSLT testing. By writing a simple 
XProc pipeline (consisting of a single p:xslt step) you can easily create tests 
that apply your stylesheet with different input data, different parameters, or 
different initial mode/template. Stylesheets that produce multiple output 
documents (via xsl:document) are also supported.

The test format allows you to compare the result of the pipeline with the 
expected output. Obviously, you can also further inspect/manipulate the XSLT 
input/output with XProc if you want.

The main limitation of this approach is that it only works with XML data. If 
your stylesheet produces results that are not well-formed XML, processing those 
may be quite challenging in XProc.

The example test below should give you an idea of how this looks like (you can 
see more examples at http://tests.xproc.org/testsuite/):

<t:test xmlns:t="http://xproc.org/ns/testsuite"; 
xmlns:p="http://www.w3.org/ns/xproc";>
  <t:title>Test xslt-001</t:title>

  <t:input port="source">
    <document>
      <title>Some Title</title>
      <para>Some paragraph.</para>
    </document>
  </t:input>

  <t:input port="style">
    <t:document href="style.xsl"/>
  </t:input>

  <t:pipeline>
    <p:pipeline version="1.0" name="pipeline">
      <p:input port="style"/>
      <p:xslt>
        <p:input port="stylesheet">
          <p:pipe step="pipeline" port="style"/>
        </p:input>
      </p:xslt>
    </p:pipeline>
  </t:pipeline>

  <t:output port="result">
    <html xmlns="http://www.w3.org/1999/xhtml";>
      <head>
        <title>Some Title</title>
      </head>
      <body>
        <h1>Some Title</h1>
        <p>Some paragraph.</p>
      </body>
    </html>
  </t:output>
</t:test>

Regards,
Vojtech

--
Vojtech Toman
Consultant Software Engineer
EMC | Information Intelligence Group
vojtech(_dot_)toman(_at_)emc(_dot_)com
http://developer.emc.com/xmltech

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>