Re: [xsl] unnecessary soap elements

Subject: Re: [xsl] unnecessary soap elements
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 28 Oct 2005 15:35:09 +0100
> did not work. To make it work, i changed it to
> <xsl:template
> match="soap:Element/soap:Body/urn:SubmitRequestResponse">.

that would make no difference.

As you posted it, if you made the changes I suggested you would get
<selectreply>
   <status code=""/>
   <selection/>
</selectreply>

with empty code and selection as you have 

<Response TypeOfResponse="ERROR">
<Response TypeOfResponse="DocumentInquiryRs"

ie one Response inside another, but your XPath was

urn:SubmitRequestResult/fi:fiAPI/fi:Response/fi:Status/fi:StatusCode

with just one Response level, change that to

urn:SubmitRequestResult/fi:fiAPI/fi:Response/fi:Response/fi:Status/fi:StatusCode
and you get

<selectreply>
   <status code="0"/>
   <selection>
      <image encoding="BASE64" format="TIFF" view="FBW">
         <data> note that the encoded (front) image data has
been truncated in this sample
0lGODlhiAbgAvcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD//////

VKcuQF1V1p8xnXkxWGcxnGcTyAwx3mcDAMCADsA</data>
      </image>
      <image encoding="BASE64" format="TIFF" view="BBW">
         <data> note that the encoded (back) image data has
been truncated in this sample
R0lGODlhiAbYAvcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/AP//AAAA//8A/wD/////
/</data>
      </image>
   </selection>
</selectreply>

David


<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
    
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
     xmlns:urn="urn:Fiserv.CWS" 
xmlns:fi="http://integration.fiapi.com";
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";
     exclude-result-prefixes="soap urn fi">

    <xsl:strip-space elements="*"/>
    <xsl:output method="xml" omit-xml-declaration="no"
indent="yes"/>

    <xsl:param name="appType" select="'IMAGE'"/>
    <xsl:param name="frontview" select="'F'"/>
    <xsl:param name="backview" select="'B'"/>

    <!-- Convert XML to XML -->
    <xsl:template match="/">
        <xsl:apply-templates select="soap:Envelope/soap:Body/*"/>
    </xsl:template>
    <xsl:template
match="urn:SubmitRequestResponse">
        <xsl:element name="selectreply">
	    <xsl:call-template name="status"/>
	    <xsl:element name="selection">
	        <xsl:call-template name="imageTags"/>
	    </xsl:element>
	</xsl:element>
     </xsl:template>

     <!-- Template for building status element -->
     <xsl:template name="status">
         <xsl:param name="code"
select="urn:SubmitRequestResult/fi:fiAPI/fi:Response/fi:Response//fi:Status/fi:StatusCode"/>
	 <xsl:element name="status">
	     <xsl:attribute name="code"><xsl:value-of
select="$code"/></xsl:attribute>
	 </xsl:element>
     </xsl:template>

      <!-- Template for building image element -->
     <xsl:template name="imageTags">
         <xsl:param name="encoding"
select="'BASE64'"/>
	 <xsl:param name="frontView" select="'FBW'"/>
	 <xsl:param name="backView" select="'BBW'"/>
	
         <xsl:for-each
select="urn:SubmitRequestResult/fi:fiAPI/fi:Response/fi:Response/fi:DocumentInquiryRs/fi:Document/fi:Page">
	     <xsl:if test="string-length(fi:Value) > 0 "> 
	         <xsl:element name="image">
		     <xsl:attribute name="encoding"><xsl:value-of
select="$encoding"/></xsl:attribute>
		     <xsl:attribute name="format"><xsl:value-of
select="@Format"/></xsl:attribute>
		     <xsl:if test="@View = $frontview">
		         <xsl:attribute name="view"><xsl:value-of
select="$frontView"/></xsl:attribute>
		     </xsl:if>
		     <xsl:if test="@View = $backview">
		         <xsl:attribute name="view"><xsl:value-of
select="$backView"/></xsl:attribute>
		     </xsl:if>
		     <xsl:element name="data"><xsl:value-of
select="fi:Value"/>
		     </xsl:element>
		 </xsl:element>         
	     </xsl:if> 
	 </xsl:for-each>
     </xsl:template>

    <!--
	 - Any tag not addressed by a more specific
	 - template match is copied unchanged. (This
	 - preserves the ph_dispatchmsg tags.)
	 -->
	<!-- Here we dump out the rest of the message tags-->

	<xsl:template match="node()|@*">
	    <xsl:for-each select=".">
	        <xsl:copy>
		    <xsl:apply-templates select="node()|@*"/>
		</xsl:copy>
	    </xsl:for-each>
	</xsl:template>
</xsl:stylesheet>

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread