Re: XProc Best Practice: favor XProc primitive steps over XSLT and Schematron?

XProc can be used in conjunction with Schematron (XML-based rules ->
Schematron -> Validation Results -> Presentation). To my mind rules
should live in pure XML (not inside any language) - for example i
should note that adding new rules should not lead to "re-programming".
Just simple editor similar to conditional formatting window in Excell
or OpenOffice

The best solution is to have spreadsheet-based template with
named-cells and conditional formatting rules. So any smart guy from
bank can adjust rules according to current reality without programmer
(: we are so lazy to do routine job :). Since both formats is XML - we
can easily get any other (XSD, XForms with validation, Schematron and
so on)

With best wishes,
Slav

On Mon, Jun 15, 2009 at 4:05 PM, Costello, Roger L.<costello@mitre.org> wrote:
>
> Hi Folk,
>
> One way to implement an XProc pipeline is to simply call XSLT (using p:xslt) and have a stylesheet do the work. Or, call Schematron to do the work.
>
> Alternatively, the work could be done using the basic XProc steps.
>
> What's best practice? Should the basic XProc steps be favored over escaping to XSLT or Schematron?
>
> EXAMPLE
>
> When processing an auto loan application it is necessary to determine if the applicant is underage. A person is underage depends on which (U.S.) state he/she resides in - in Alaska someone is underage if they are under 16 years of age, whereas in Ohio a person is underage if they are under 18 years of age.
>
> Determining whether an applicant is underage could be implemented using XSLT. It could be implemented using Schematron. And it could be implemented using the basic XProc steps.
>
> Here is an XSLT implementation:
>
> http://www.xfront.com/xproc/automated-decision-support/Is-Applicant-Underage.xsl
>
> Below is an implementation using the XProc steps.
>
> Suppose Fred creates an XProc pipeline for processing the loan application. When it comes time to determine if the applicant is underage he uses p:xslt to invoke an XSLT stylesheet that implements the "is underage" functionality.
>
> Suppose Sally also creates an XProc pipeline for processing the loan application. When it comes time to determine if the applicant is underage she uses the below user-defined XProc step to implement the "is underage" functionality.
>
> Which pipeline implementation is better - Fred's or Sally's?
>
> Why?
>
> /Roger
>
>
> ***************************************************
>   User-Defined XProc Step to Determine
>      if a Loan Applicant is Underage
> ***************************************************
> <p:declare-step type="applicant:is-underage"
>                name="is-underage">
>
>    <p:input port="auto-loan-application" />
>    <p:output port="result"/>
>
>    <p:choose>
>        <p:variable name="state" select="Loan-Application/Applicant/Address/State" />
>        <p:variable name="age" select="Loan-Application/Applicant/Age" />
>
>        <p:when test="($state eq 'AK') and (number($age) le 16)">
>            <p:identity>
>                <p:input port="source">
>                    <p:inline><is-underage>true</is-underage></p:inline>
>                </p:input>
>                </p:identity>
>        </p:when>
>        <p:when test="($state eq 'AL') and (number($age) le 18)">
>            <p:identity>
>                <p:input port="source">
>                    <p:inline><is-underage>true</is-underage></p:inline>
>                </p:input>
>            </p:identity>
>        </p:when>
>        <p:when test="($state eq 'AZ') and (number($age) le 17)">
>            <p:identity>
>                <p:input port="source">
>                    <p:inline><is-underage>true</is-underage></p:inline>
>                </p:input>
>            </p:identity>
>        </p:when>
>        <!-- ... -->
>        <p:when test="($state eq 'OH') and (number($age) le 18)">
>            <p:identity>
>                <p:input port="source">
>                    <p:inline><is-underage>true</is-underage></p:inline>
>                </p:input>
>            </p:identity>
>        </p:when>
>        <!-- ... -->
>        <p:when test="($state eq 'WY') and (number($age) le 17)">
>            <p:identity>
>                <p:input port="source">
>                    <p:inline><is-underage>true</is-underage></p:inline>
>                </p:input>
>            </p:identity>
>        </p:when>
>        <p:otherwise>
>            <p:identity>
>                <p:input port="source">
>                    <p:inline><is-underage>false</is-underage></p:inline>
>                </p:input>
>            </p:identity>
>        </p:otherwise>
>    </p:choose>
>
> </p:declare-step>
>

Received on Monday, 15 June 2009 12:23:09 UTC