RE: Processing business rules using XSLT
> 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/
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format