Subject: Re: [xsl] Specification of a transform.|
From: davep <davep@xxxxxxxxxxxxx>
Date: Mon, 09 Sep 2013 16:35:14 +0100
At 2013-09-09 14:01 +0200, Geert Bormans wrote:The way I interpreted your question is not "how to do the transform" but "how to specify",
Why not both?
Because many of us here can write a transform... I've not heard many (any?) talking about specifying a required transform.
and regardless of the complexity, answer that question in general. If that really is what the question was asking... I would definitely be interested to see the answers
In July 2003 I published an environment named LiterateXSLT that is still being used today by some people other than myself (in particular a B2B solution from Italy that uses it to quickly implement A-to-B translation XSLT transformations in a semi-automated fashion). I followed that up in 2004 with another environment, ResultXSLT, that doesn't replace LiterateXSLT but is complementary, building on the first environment with modularization features. I use that in my UBL stylesheet work, synthesizing XSLT stylesheets that produce HTML and XSL-FO results without having to hand-code the entire transformation.
I have not yet figured out a good standardized way myself. I have often come to a conclusion that writing the spec was as hard as just doing the transform,
But what if the *act* of writing the specification was expressive enough that the XSLT transformation could be synthesized. And, that specification was testable as a standalone document.
so "spec it out using XSLT" should not be regarded as funny as it sounds at first
Indeed, the germ of the idea is as follows: annotate a prototypical result instance of "B" with signals that convey information about the source tree "A", press a button, and out the other end is an XSLT stylesheet that transforms instances of "A" into instances of "B". So that Italy B2B company is given an example prototypical target invoice XML document by a client, he annotates it with information about the source invoice XML document, presses the button and out comes an XSLT stylesheet that transforms instances of the source into instances of the target. He then does the opposite, annotating a prototypical instance of his existing invoice XML with information about the client's XML, presses the button, and out comes an XSLT stylesheet for the other direction.
What made me think about this approach was the knowledge that foreign-namespace annotations in XSL-FO are ignored, thus giving me license to annotate an XSL-FO prototypical result instance. I can visually validate the XSL-FO prototypical result has the required formatting objects and properties before creating the XSLT stylesheet, then annotate it with the information needed to synthesize the XSLT transformation.
Take a schema B instance. Annotate each element with a source xpath, perhaps schematron 'rules', any math etc for modified values, Something else if the input units needed changing etc. Something else if I needed to map input to output values......
Then I realized I could do the same with HTML or any arbitrary XML ... I've included some housekeeping stylesheets for those vocabularies that are not tolerant of foreign namespaces.
Since an XSLT stylesheet is a collection of result tree templates in template rules and other instructions, and the XSLT processor assembles the result from the templates found in the stylesheet, then just break up the prototypical result tree into templates and template rules of an XSLT stylesheet.
There's a posh name for it, but isn't this basically a pull format? with bells on?
-- Dave Pawson XSLT XSL-FO FAQ. http://www.dpawson.co.uk