xsl-list
[Top] [All Lists]

RE: [xsl] Processing business rules using XSLT

2008-02-02 09:30:21
I have a requirement to modify an XML document based on 
certain business rules for the purposes of processing batch 
orders.  I need to inspect several elements and take 
action(s) based on whether an element or elements (or 
possibly an element's child or parent) meets certain 
conditions.  My question is: can I define all the business 
rules in templates and process the XML document once or is it 
possible I could need to run multiple transformations against the XML?

You really haven't given enough information to answer the question!

Trying to read between the lines, perhaps the reason you think you might
need multiple transformations is that there will be elements that match more
than one condition (and therefore more than one rule)? You seem to be
planning to run this in an environment that only supports XSLT 1.0, which
rules out use of <xsl:next-match/>, so I can see the difficulty -
<xsl:apply-imports/> would be pretty impractical because of the need for
multiple modules.

Generally though I'm not sure it's a good idea to hard-code the business
rules in an XSLT stylesheet. When I've tackled this kind of problem I've
represented the rules as XPath expressions in a separate XML rules document,
and interpreted them from the stylesheet logic using saxon:evaluate() -
which you can probably emulate in your environment. This approach allows you
to make changes to business rules with far less risk of causing the whole
system to fail, and it puts a boundary round the business rules which stops
them becoming arbitrarily complex and thus making the whole structure
unmaintainable.

You might also look at schematron. Although it's usually presented as a
technology for document validation, you can also think of it as a vehicle
for defining rules and assessing documents against them.

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>