Introduction to DirXML Stylesheet Programming
Important You must understand how to interpret NDS.DTD for all of the projects in this section. If you feel weak on that topic, now would be a good time to review Analyzing NDS.DTD to Construct XDS Trees. The purpose of this section is to enable a person who already understands NDS, basic DirXML configuration, and XML to write a simple stylesheet. Any discussion about DirXML must, at some point, refer to an external system or directory that is to be hooked up to NDS with a DirXML driver. For the purposes of this discussion, this section makes references to a fictitious application called PBXSimulator that could use a DirXML driver to synchronize the phone numbers maintained in a PBX with User phone numbers in NDS. You don't really have to know much about PBXs or PBXSimulator to understand the section. Just understand that it is a simple example of an external system for DirXML. Introducing Business Rules Most real world environments will have unique requirements in how data and/or events are transferred between their external systems and NDS. These exceptions are called "business rules." Let's use a couple of environmental considerations for PBXSimulator as an example of simple business rules. You may have noticed that PBXSimulator allows only the '-' character to delimit groups of digits in its phone numbers. For managing phone account information inside of a PBX, this might be fine. But when that value is sent to NDS where it could be forwarded to many other special purpose directories, it is conceivable that one or two of them might require that different characters delimit their phone numbers. For the purposes of this discussion, let's assume that the most common delimiter needed in a particular installation is the '.' character (dot). To solve this incompatibility, a simple business rule could be implemented stating that all phone numbers in the core directory must be delimited by dots. To accommodate this business rule in PBXSimulator's DirXML driver, the hyphens in PBXSimulator's phone numbers must be converted to dots as they are sent to NDS. We don't have to worry about the phone number coming back through PBXSimulator's Subscriber channel because the phone number isn't listed in the Subscriber's filter, so changes to the phone number won't even be seen by the engine on the Subscriber side. This was a conscious design decision to prevent the phone number from being changed by anyone but the PBX administrator. (This is an example of yet another business rule that was implemented by simple filter configuration.) So the question is, how do we implement this hyphen/dot phone number business rule on the Publisher side. "Easy", you say, "just program the translation from hyphens to dots into the driver's Publisher shim?" Well, that would work. However, if PBXSimulator were a real product, we might want to distribute its driver into other business environments, some of which might require a different delimiter than either dots or hyphens. Coding the business rule into a shim (a compiled executable) implements the rule for every installation. What we really need is a flexible way to implement the business rule, allowing the use of whatever delimiter may be required at a given installation if and when implementation is necessary. DirXML Stylesheets Implement Business Rules and Perform XDS Data Format Conversions The flexible solution for implementing business rules is usually a stylesheet. Stylesheet programming is different from the code in shims in that stylesheet code is not compiled. Instead, stylesheet programs are composed using a language called the Extensible Stylesheet Language Transformation Language (XSLT) that is interpreted by XSLT processors to manipulate/construct XML documents. Since XSLT is interpreted, this means that the administrator can modify stylesheets as needed for each installation without having to rebuild/recompile the driver. Stylesheets provide programmatic access to XDS (DirXML's XML vocabulary for communicating directory information) documents as they travel along from the Publisher shim to the DirXML engine or from the engine to the Subscriber shim. Stylesheets implement the unique business rules for the environment by adding, deleting, or modifying nodes in these documents.
Figure 1: The flow of XDS on the Publisher and Subscriber sides. There are four usages of stylesheets shown in Figure 1 (stylesheets may also be used to replace any rule).
|
|||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||