Re: [xsl] XSLT use cases; data-centric to document-centric transformations

Subject: Re: [xsl] XSLT use cases; data-centric to document-centric transformations
From: Peter Gerstbach <peter@xxxxxxxxxxxx>
Date: Mon, 07 Feb 2005 19:39:50 +0100
David Carlisle wrote:
- Does anybody agree/disagree to my classification?

Oh, I expect so:-)

It isn't always clear whether a particular XML file is data or document
centric for a start. In particular many basically "document" oriented
formats that support mixed data have "data centric" subsections (eg
lists of bibligraphies or metadata sections) I think XSLt was
intentionally designed to handle both these cases.

but the programming style is more imperative (for-each) than template based (apply-template).

I know what you mean here but the distinction between imperative and
declarative programming styles doesn't really coincide with using or not
using apply-templates. xsl:for-each is (always) equivalent to  using
apply-templates with a unique mode, and a single template in that mode,
so for-each is just a syntactic shorthand for one restricted usage of
apply-templates, not a completely different paradigm that one can make
hard and fast rules about.

Ok, I agree with you upon this.
I wanted to say, when I look at the code which is produced by WYSIWYG editors, they are mostly imperative.

- How can I handle use case 3)? To my mind it would be best to convert a data-centric XML into a well structured documen-centric XML and then apply a XSLT stylesheet.

I don't understand this question. Or at least, I don't understand the
proposed answer. How would you do the conversion that you mention?
If you use XSLT then you would presumably need a stylesheet of your type
3, so this solution appears to be circular?

Well, the thing I have in mind is maybe a little more complex.
I have a data-centric XML, for example an XML representing some ordered products:

    <name>product A</name>
    <name>product B</name>

Now I want to transform this XML into an FO-document which represents an invoice. The WYSIWYG-tools I know, create one big template containing all the static text someone inputs (the logo and the name of the company, the address, the text before and after the product-list) and of course the instruction which converts the product-xml into a table.

So these tools are more about generating XSL-FO than about creating XSLT. My proposed answer to this is, that it might be better to store all this static text in a separate document:

  <header>the logo, the company name</header>
    <p>Some text what this is about</p>
    <table>...</table> <!-- here comes the table with the products -->
    <p>And maybe some text again.</p>

.. and then apply a XSLT which transforms the document- and the orderedProducts-XML into an FO-document.

Sorry, that this example turns out to be a very domain specific problem. I tried - unsuccessful - to generalize it. ;)


Current Thread