- From: Philip Fennell <Philip.Fennell@marklogic.com>
- Date: Thu, 19 Aug 2010 23:24:12 -0700
- To: James Sulak <jsulak@gmail.com>, Jakob Fix <jakob.fix@gmail.com>
- CC: "xproc-dev@w3.org" <xproc-dev@w3.org>
Jakob, Another alternative is to use the XMLUnit extension step that has been included as part of XML Calabash. This differs from the standard 'p:compare' step in that you can control things like the significance of whitespace characters. <p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions" type="cxu:compare"> <p:input port="source" primary="true"/> <p:input port="alternate"/> <p:output port="result" primary="true" /> <p:option name="compare-unmatched" select="'false'" /> <p:option name="expand-entity-references" select="'false'" /> <p:option name="ignore-attribute-order" select="'false'" /> <p:option name="ignore-comments" select="'false'" /> <p:option name="ignore-diff-between-text-and-cdata" select="'false'" /> <p:option name="ignore-whitespace" select="'false'" /> <p:option name="normalize" select="'false'" /> <p:option name="normalize-whitespace" select="'false'" /> <p:option name="fail-if-not-equal" select="'false'" /> </p:declare-step> Charles Foster did the work to add this to Calabash and then Norm Walsh made it part of the build. I've used it where I provide an additional input port for an 'in-line' expected result document and then take the result of the last step of the pipeline and run them both through 'alternate' and 'source' ports, respectively, of the cxu:compare step. This works well, but you have to take into account whitespace differences which is why I mentioned that earlier. Regards Philip Fennell Consultant MarkLogic Corporation Mobile +44 (0) 7824 830 866 email Philip.Fennell@marklogic.com web www.marklogic.com This e-mail and any accompanying attachments are confidential. The information is intended solely for the use of the individual to whom it is addressed. Any review, disclosure, copying, distribution, or use of this e-mail communication by others is strictly prohibited. If you are not the intended recipient, please notify us immediately by returning this message to the sender and delete all copies. Thank you for your cooperation. ________________________________________ From: xproc-dev-request@w3.org [xproc-dev-request@w3.org] On Behalf Of James Sulak [jsulak@gmail.com] Sent: 19 August 2010 22:46 To: Jakob Fix Cc: xproc-dev@w3.org Subject: Re: xslt + diff question 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 Friday, 20 August 2010 06:24:42 UTC