xBus

XBUS_Stylets for particular Transformation Tasks

 Transformation Steps

One design principle of the xBus is to use standards whenever possible. For this reason XSLT is widely used for transforming messages. Unfortunately some particular transformation tasks are nor appropriately done with pure XSLT processing. One example for this is the value mapping between certain keys of different connected systems. XSL is simply not capable of reading and applying external mapping tables.

To enrich the XSLT possibilities the usual transformation in the xBus is performed in two steps:

  1. Processing of a XSLT style sheet. The result is a DOM tree.
  2. DOM tree traversing to execute so-called XBUS_Stylets.
The general purpose of a XBUS_Stylet is to insert data into the transformation result DOM tree.

 XBUS_Stylets Syntax
A XBUS_stylet is a particular XML node in a DOM tree. Its tag name is "XBUS_Stylet". In the named second transformation step such nodes are replaced by others containing the data specified in the XBUS_Stylet. How a XBUS_Stylet behaves is determined by its attributes:
Name:
The name defines what data is inserted. There is a defined set of names which will be explained in the following section.
Tag:
The name of the tag under which the data is inserted.
If the tag name begins with '@', the new node is a attribute node, otherwise an element node. The tag attribute may be omitted. In this case only a text node for the value is inserted and replaces the stylet node.
Section:
Optional, only used with the name Value and AddressMapping. Specifies the name of the mapping to get a value from.
toSection:
Optional, only used with the name AddressMapping. Specifies the value type to map to.
Key:
Optional, only used with the names Value, CDATA and FormatDate. Values come from two different sources depending on the section attribute.
If no section is specified: A key/value pair can be stored before the transformation. The value for the given key is inserted.
For a given section: The value is read from a mapping table.
SourceFormat:
Optional, only used with the name FormatDate. Describes the actual format of the date given in Key.
DestinationFormat:
Optional, only used with the name FormatDate. Describes the format to apply to the date given in Key.
CompareDate:
Optional, only used with the name DateComparison. This date is compared against the reference time interval or single reference date.
CompareFormat:
Optional, only used with the name DateComparison. The format of CompareDate.
BeginDate:
Optional, only used with the name DateComparison. Begin of the reference time interval or just the single reference date.
BeginFormat:
Optional, only used with the name DateComparison. The format of BeginDate.
EndDate:
Optional, only used with the name DateComparison. End of the reference time interval.
EndFormat:
Optional, only used with the name DateComparison. The format of EndDate.
BeforeValue:
Optional, only used with the name DateComparison. Result if the compared date lies before the reference time interval or single reference date.
StrikeValue:
Optional, only used with the name DateComparison. Result if the compared date lies in the reference time interval or is equal to the single reference date.
AfterValue:
Optional, only used with the name DateComparison. Result if the compared date lies after the reference time interval or single reference date.
 XBUS_Stylets Possibilities

The values for the attribute Name are defined as follows:

Id:
The identifier of the new Message is inserted.
Source:
The logical name of the source of the Message is inserted.
RequestTimestamp:
The request timestamp is inserted.
Value:
The value for the given Key is inserted. (see above)
AddressMapping:
The value from the Additional Address for the Key mapped from Section to toSection is inserted. (see above)
CDATA:
The value for the given Key is inserted as a CDATA section.
FormatDate:
The format for the given date in key is changed. SourceFormat describes the original and DestinationFormat the new format.
If no key and SourceFormat are specified, a timestamp in the specified DestinationFormat is created.
(see above) for value insertion
DateComparison:
This stylets compares a given or the actual date against an time interval or a single date.
If CompareDate is specified, it is the date to compare, otherwise it is the current date.
If EndDate is specified, the comparison is against the inteval made of BeginDate and EndDate, otherwise it is against the BeginDate.
Depending on the date comparison a value is inserted:
BeforeValue - if the compared date lies before the reference time interval or single reference date,
StrikeValue - if the compared date lies in the reference time interval or is equal to the single reference date,
AfterValue - if the compared date lies after the reference time interval or single reference date
(see above) for value insertion

Thus, everything to do is to create a new element node with the suitable attributes.

 XBUS_Stylets in XSLT Style Sheets

To use XBUS_Stylets the first transformation step must integrate XBUS_Stylet nodes into the DOM tree. The XSLT code to achieve this looks like:

    <xsl:element name="XBUS_Stylet">
        <xsl:attribute name="Name">Value</xsl:attribute>
        <xsl:attribute name="Section">DispatchModeAL2IMPHDL</xsl:attribute>
        <xsl:attribute name="Key">
            <xsl:value-of select="DispatchMode" />
        </xsl:attribute>
    </xsl:element>
This example describes a value mapping. The name of the mapping is "DispatchModeAL2IMPHDL" and the mapped value is retrieved from a DispatchMode node.

Thus, everything to do is to create a new element node with the suitable attributes.

 Cascading XBUS_Stylets

XBUS_Stylets may be used in a cascading manner. The XSLT code to achieve this looks like:

    <xsl:element name="XBUS_Stylet">
        <xsl:attribute name="Name">DateComparison</xsl:attribute>
        <xsl:attribute name="BeginDate">
            <xsl:value-of select="ValidUntil" />
        </xsl:attribute>
        <xsl:attribute name="BeginFormat">yyyyMMdd</xsl:attribute>
		<xsl:element name="XBUS_Stylet">
			<xsl:attribute name="Name">AddressMapping</xsl:attribute>
			<xsl:attribute name="Section">$DEALERSHORTNUMBER$</xsl:attribute>
			<xsl:attribute name="toSection">$DEALERHSTPARTSNUMBER$</xsl:attribute>
			<xsl:attribute name="Tag">@BeforeValue</xsl:attribute>
			<xsl:attribute name="Key">
				<xsl:value-of select="DealerNo" />
			</xsl:attribute>
		</xsl:element>
        <xsl:attribute name="StrikeValue"></xsl:attribute>
        <xsl:attribute name="AfterValue"></xsl:attribute>
    </xsl:element>
This example compares the current date against the specified one. If the reference date is still in the future, a mapped dealer number is inserted, otherwise blank.