Re: XSL and scripting

Subject: Re: XSL and scripting
From: info@xxxxxxxxxx (Flow Simulation)
Date: Thu, 24 Dec 1998 16:12:27 -0000
James,

you wrote: (jjc@xxxxxxxxxx)

>Extensibility (whether in the form of scripting or something else) will
>get into XSL if and when the XSL WG reaches consensus on a mechanism for
>providing extensibility.  Flaming the W3C process may be a lot of fun
>but it won't help get extensibility into XSL. The way to help get
>extensibility into XSL is to provide useful, constructive input to the
>XSL WG that assists it in coming up with a design that it can reach
>consensus on. At this stage, the kind of input I would find most useful
>would be a representative selection of transformation problems that
>can't be solved using the current XSL WD and that one might reasonably
>expect to be able to solve with an extensibility mechanism. (If anybody
>steps up to this, please supply actual source and result XML documents
>so that there's no doubt exactly what the problem is.)

Here are two I came up with so far:

Transformation sample problem one:

The XML data contains numerical values in one set of dimensional units, but
the requirement is to render the data using a different set of units.   The transformation
involves the multiplication of values by a factor (and possibly addition of an offset)
before output.   An example of this was given in the original Microsoft samples
where the energy value of Belgian Waffles was given in calories for one stylesheet
and additionally as a percentage of Recommended Daily Allowance in an alternative stylesheet.

Testing.xml:
<Section>
    The vessel has been tested, as required, to a pressure of 
    <Pressure>100000</Pressure>.
   .........snip
</Section>

Output using stylesheet SI.xsl:

    The vessel has been tested, as required, to a pressure of 10000 N/m.sq.

Output using stylesheet Brit.xsl:

    The vessel has been tested, as required, to a pressure of 14.5 p.s.i.

Output using stylesheet SIBrit.xsl:

    The vessel has been tested, as required, to a pressure of 10000 N/m.sq. (14.5 p.s.i.).

...where the stylesheets might contain script fragments for matching elements, for example:

<eval>text + "N/m.sq. ( " + formatNumber(text/6894.757, "1") + "p.s.i.)"</eval>



Transformation sample problem two:

Say I have an invoice SalesLedger.xml:

<SalesLedger>
  <Invoice>
    <Customer id=2569/>
    <Number>FS9812023</Number>
    <Date>24121998</Date>
    <Item>
      <Description>Supply of consultancy services</Description>
      <Amount>253.45</Amount>
      <VATRate>17.5</VATRate>
    </Item>
    <Item>
      <Description>Copy of book "Understanding XSL Scripting"</Description>
      <Amount>31.45</Amount>
      <VATRate>0</VATRate>
    </Item>
  </Invoice>
</SalesLedger>

If we forget about the customer id for a moment,
I don't think it is unreasonable to want to render this
either as an HTML page (for on-line reference) or as a printed invoice,
in a single step without having to invoke a second stage of processing somehow.
Apart from the layout, which is straightforward, you would need to "style"
the date appropriately for a printed invoice to send out, compute the tax and gross
amounts and provide a total.  

The result document might look like this, in printed form:

INVOICE No. FS9812023

Invoice Date: 24th December, 1998

                                                              
Supply of consultancy services                          £253.45

Copy of book "Understanding XSL Scripting"       £  31.45
                                                                      -------------
                                                        Subtotal   £284.90
                                                        VAT         £ 44.35
                                                                      -------------
                                                        Total        £329.25

...End of example document

Folding in the Customer details is a bit more ambitious, because it involves
looking up another file containing customer details.   I presume that brings us into
XQL territory, and if that could be worked into it as well.....

I look forward to your comments.

Bill Ayers (BillA@xxxxxxxxxx)


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread