W3C home > Mailing lists > Public > xproc-dev@w3.org > August 2010

Re: xslt + diff question

From: James Sulak <jsulak@gmail.com>
Date: Thu, 19 Aug 2010 16:46:06 -0500
Message-ID: <AANLkTikR53FZpxOTGB488fNWYhD7L571ymFPTFqJjpws@mail.gmail.com>
To: Jakob Fix <jakob.fix@gmail.com>
Cc: xproc-dev@w3.org
Hi Jakob,

Have you considered trying XSpec?  It's a testing framework for XSLT,
and it could be better suited to what you're trying to do.  You can
test individual templates and functions, and it can show an html-ized
diff output in the browser:

http://code.google.com/p/xspec/wiki/GettingStarted

However, you mention that your stylesheet generates multiple output
documents, which (I'm pretty sure) XSpec doesn't handle well or at
all, so your mileage may vary.

As far as XProc goes, any and all result documents from p:xslt are
accessible from the pipeline.  The primary result will be on its
"result" output port, and any remaining documents will be pushed out
as a sequence on the "secondary" port.

One possibility for rendering diff output is is to create a stylesheet
to compare the two documents using deep-equal().  Although I haven't
done it, you can pass in multiple input documents to p:xslt, which
will be available from the default collection.  Another hacky way to
do it that I have used before is to use p:pack to combine the two
documents into a single document, and pass that to an XSLT, like this:

<p:pack wrapper="wxp:wrapper">
      <p:input port="source">
        <p:pipe step="assert" port="source"/>
      </p:input>
      <p:input port="alternate">
        <p:pipe step="assert" port="alternate"/>
      </p:input>
</p:pack>


-James



On Thu, Aug 19, 2010 at 2:42 AM, Jakob Fix <jakob.fix@gmail.com> wrote:
> Hi,
>
> Having recognized the superiority of xproc ;) and wanting to wean
> myself off ant and friends, I have this first project in mind to apply
> my newly acquired knowledge:
>
> To check that modifications to our XSLT stylesheets have no side
> effects, I want to be able to run the modified stylesheets against a
> control set of input XML files and compare the outputs with previously
> generated reference outputs.
>
> Is this a valid use case for xproc?
>
> One other question is this: The stylesheet doesn't generate one output
> file but many via result-document (similar to the DocBook chunking
> mechanism). Will they be available directly via the xslt output port,
> or do I have to do a directory-list step?
>
> One final question: Although there is a compare step it seems to
> return only a Boolean. Are there steps that allow for more detailed
> results? Should I use exec with a traditional diff engine?
>
> thanks,
> Jakob.
>
>
>
Received on Thursday, 19 August 2010 21:46:58 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 19 August 2010 21:47:01 GMT