Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 7 Transaction Pipeline Processing : Mapping Schemas

Mapping Schemas
Mapping Container
The input document to the XSLT file for XSLT transformations is described by the following schema(XSD):

 
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified"
attributeFormDefault="unqualified">
<xs:element name="transformation" type="transformationType"/>
<xs:complexType name="transformationType">
<xs:sequence>
<xs:element name="nbRequest" type="stageType" minOccurs="0"/>
<xs:element name="cnRequest" type="stageType" minOccurs="0"/>
<xs:element name="sbRequest" type="stageType" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="sbResponse" type="stageType" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="cnResponse" type="stageType" minOccurs="0"/>
<xs:element name="nbResponse" type="stageType" minOccurs="0"/>
<xs:element name="context" type="stageType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="stageType">
<xs:attribute name="href" type="xs:string"/>
</xs:complexType>
</xs:schema>

 
The request payloads and the request context is passed to the XSLT as a map, keyed using the values of the “href” attribute for each element. In order to access the actual payload, it is necessary to load it using the document() function.
The schemas contains the following elements:
At any stage during request processing, only the versions of the request payload created up to that point are available. Though the mapping container has the corresponding element present, an attempt to load the payload via document() causes the XSLT processor to throw an error.
For example, use the following XSLT snippet to map a value when the received request is SOAP :

 
<xsl:variable name="nbRequest">
<xsl:value-of select="/transformation/nbRequest/@href"/>
</xsl:variable>
<xsl:choose xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:when test="count(document($nbRequest)/soap:Envelope/soap:Body)=1">
This is a SOAP request
</xsl:when>
<xsl:otherwise>This is not a SOAP request</xsl:otherwise>
</xsl:choose>

 
Context Document
The contents of the context document are described by the following XSD:

 
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:c="http://www.tibco.com/schemas/asg/context"
targetNamespace="http://www.tibco.com/schemas/asg/context"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="context">
<xs:complexType>
<xs:sequence>
<xs:element ref="c:entry" minOccurs="0"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="entry">
<xs:complexType>
<xs:sequence>
<xs:any namespace="##any" processContents="lax"/>
</xs:sequence>
<xs:attribute name="key" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:simpleType name="key">
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:schema>

 
If the incoming request is received from Apache HTTP server, the context document contains an entry with key set to asg:httpRequest, which conforms to the following XSD:

 
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.tibco.com/asg/protocols/http"
targetNamespace="http://www.tibco.com/asg/protocols/http"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="request">
<xs:complexType>
<xs:sequence>
<xs:element name="server-ip" type="xs:string" minOccurs="0"/>
<xs:element name="server-port" type="xs:string"
minOccurs="0"/>
<xs:element name="client-ip" type="xs:string" minOccurs="0"/>
<xs:element name="client-port" type="xs:string"
minOccurs="0"/>
<xs:element name="scheme" type="xs:string" minOccurs="0"/>
<xs:element name="method" type="xs:string" minOccurs="0"/>
<xs:element name="request-uri" type="xs:string"
minOccurs="0"/>
<xs:element name="protocol-version" type="xs:string"
minOccurs="0"/>
<xs:element name="header" minOccurs="0"
maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name"
type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="body" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

 

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved