Sample XSLT transformation and XSD schema

XSLT transformation

An XSLT transformation is required for the Interact connector service workflow to retrieve Interact data from a custom XML format.

Example


		<!-- XSLT transformation to transform step element into entities -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" encoding="UTF-8" indent="yes"/>

  <!-- <xsl:template match="/">
     <xsl:apply-templates select="."/>
  </xsl:template> -->

  <xsl:template match="/">
    <xsl:if test="dialogue">
    <Interact_Out>
      <xsl:attribute name="Reference_Number">
        <xsl:value-of select="dialogue/reference" />
      </xsl:attribute>
      <Entities>
        <xsl:apply-templates select="dialogue/step[@id = 'WZ_ODATA']/group[@id != 'RecordTemplate']"/>
      </Entities>
      <RecordTemplate>
        <xsl:apply-templates select="dialogue/step[@id = 'WZ_ODATA']/group[@id = 'RecordTemplate']"/>        
      </RecordTemplate>
      <AdditionalData/>
    </Interact_Out>
    </xsl:if>
  </xsl:template>

  
  <xsl:template match="group[@id != 'RecordTemplate']">
    <xsl:if test="@id != 'RecordTemplate'">
      <xsl:if test=". != ''">
     <Entity>
          <xsl:attribute name="EntitySet">
            <xsl:value-of select="@label" />
           </xsl:attribute>       
           <xsl:attribute name="Id">
            <xsl:value-of select="@id" />
           </xsl:attribute>
           <xsl:apply-templates select="element"/>
        </Entity>
    </xsl:if>
      </xsl:if>
  </xsl:template>
  
  <xsl:template match="group[@id = 'RecordTemplate']">
    <xsl:if test="@id = 'RecordTemplate'">
      <xsl:apply-templates select="element"/>
    </xsl:if>
  </xsl:template>
  
  <xsl:template match="element">
    <xsl:if test=". != ''">
      <Property>
       <xsl:attribute name="Name">
         <xsl:value-of select="@label" />
       </xsl:attribute>       
       <xsl:value-of select="."/>
      </Property>
    </xsl:if>
  </xsl:template>
 
  <xsl:template match="element[@label='File']|element[@label='Name']|element[@label='Records']">    
    <xsl:if test=". != ''">
      <EntityRef>
      <xsl:attribute name="Name">
        <xsl:value-of select="@label" />
      </xsl:attribute>
      <xsl:attribute name="IdRef">
        <xsl:value-of select="."/>
      </xsl:attribute>
    </EntityRef >
      </xsl:if>
  </xsl:template>
  
</xsl:stylesheet>
				

The copy image is missing

XSD schema

You can use an XSD schema to validate the retrieved custom XML format and improve the readability possible error messages.

Example


		<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="dialogue">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="name" type="xs:string" />
        <xs:element name="id" type="xs:unsignedInt" />
        <xs:element name="reference" type="xs:unsignedInt" />
        <xs:element maxOccurs="unbounded" name="step">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="group">
                <xs:complexType>
                  <xs:sequence minOccurs="0">
                    <xs:element maxOccurs="unbounded" name="element">
                      <xs:complexType mixed="true">
                        <xs:sequence minOccurs="0">
                          <xs:element minOccurs="0" maxOccurs="unbounded" name="element">
                            <xs:complexType>
                              <xs:simpleContent>
                                <xs:extension base="xs:string">
                                  <xs:attribute name="id" type="xs:string" use="required" />
                                  <xs:attribute name="type" type="xs:string" use="required" />
                                </xs:extension>
                              </xs:simpleContent>
                            </xs:complexType>
                          </xs:element>
                          <xs:element minOccurs="0" maxOccurs="unbounded" name="item">
                            <xs:complexType>
                              <xs:simpleContent>
                                <xs:extension base="xs:string">
                                  <xs:attribute name="value" type="xs:string" use="required" />
                                  <xs:attribute name="type" type="xs:string" use="required" />
                                </xs:extension>
                              </xs:simpleContent>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                        <xs:attribute name="id" type="xs:string" use="required" />
                        <xs:attribute name="label" type="xs:string" use="optional" />
                        <xs:attribute name="type" type="xs:string" use="optional" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="id" type="xs:string" use="required" />
                  <xs:attribute name="label" type="xs:string" use="optional" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="id" type="xs:string" use="required" />
            <xs:attribute name="label" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
				

The copy image is missing