How do you transform a XML SOAP Response using XSL
I am trying to transform a XML document using a XSL stylesheet. In XMLSpy the XSL Stylesheet transforms the XML correctly, but when I try to do it on the fly using the SOAP response it doesn't work. I am not familar with VBScript. I having been trying to do the transformation using Coldfusion MX7's Xmltranform() function. I get a "file cannot be displayed error".
Can someone please help by writing the code that will do this in vbscript?
Thank you in advance
Wil
Below is the Soap Message and the XSL Stylesheet that I am using.
SOAP Message
<?xml version="1.0" encoding="UTF-8" ?>
- <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
- <SOAP-ENV:Body>
- <barceloDS_responses ip="69.121.64.141">
- <response>
- <request id="1" type="valued availability list">
<session_id>aaa6SP8c6P5BAJ</session_id>
<language_code>ING</language_code>
- <agency>
<primary>888</primary>
<secondary>88</secondary>
<detail>888</detail>
<branch>1</branch>
</agency>
<contract />
<check_in_date>20061221</check_in_date>
<check_out_date>20061228</check_out_date>
- <location>
<destination_code>NYC</destination_code>
<zone_code />
</location>
- <establishment>
<code />
<category />
</establishment>
<board_type />
- <occupancy>
<adults>2</adults>
<children>0</children>
<rooms>1</rooms>
</occupancy>
</request>
- <valued_list>
<valuation_file_number>9042</valuation_file_number>
<total_pages>1</total_pages>
<current_page>1</current_page>
<total_hotels>7</total_hotels>
- <establishment>
<code>6467</code>
<description>Sheraton Manhattan</description>
<contract>3.3RDXML</contract>
<child_min_age>0</child_min_age>
<child_max_age>12</child_max_age>
- <location>
- <destination>
<code>NYC</code>
<description>New York City - NY</description>
</destination>
- <zone>
<code>15</code>
<description>Midtown West</description>
</zone>
</location>
- <category>
<code>4EST</code>
<description>4 STARS</description>
</category>
<incoming_contract>X60071769</incoming_contract>
<offer>YES</offer>
<classification>NOR</classification>
<currency>EUR</currency>
- <room>
<code>DBL.SU</code>
<description>DOUBLE/ TWIN SUPERIOR</description>
<availability>996</availability>
- <price>
- <occupancy>
<adults>2</adults>
<children>0</children>
<rooms>1</rooms>
</occupancy>
- <board_type>
<code>HD</code>
<description>BED AND BREAKFAST</description>
</board_type>
<amount>269.43</amount>
</price>
</room>
</establishment>
- <establishment>
<code>12998</code>
<description>Bentley</description>
<contract>3.3RDXML</contract>
<child_min_age>0</child_min_age>
<child_max_age>12</child_max_age>
- <location>
- <destination>
<code>NYC</code>
<description>New York City - NY</description>
</destination>
- <zone>
<code>17</code>
<description>Upper East Side</description>
</zone>
</location>
- <category>
<code>4EST</code>
<description>4 STARS</description>
</category>
<incoming_contract>X60071769</incoming_contract>
<offer>YES</offer>
<classification>NOR</classification>
<currency>EUR</currency>
- <room>
<code>DBL.SU</code>
<description>DOUBLE/ TWIN SUPERIOR</description>
<availability>995</availability>
- <price>
- <occupancy>
<adults>2</adults>
<children>0</children>
<rooms>1</rooms>
</occupancy>
- <board_type>
<code>HD</code>
<description>BED AND BREAKFAST</description>
</board_type>
<amount>386.54</amount>
</price>
</room>
- <room>
<code>DBL.ST</code>
<description>DOUBLE/ TWIN STANDARD</description>
<availability>997</availability>
- <price>
- <occupancy>
<adults>2</adults>
<children>0</children>
<rooms>1</rooms>
</occupancy>
- <board_type>
<code>HD</code>
<description>BED AND BREAKFAST</description>
</board_type>
<amount>544.74</amount>
</price>
</room>
</establishment>
</valued_list>
</response>
</barceloDS_responses>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Below is the XSL Stylesheet
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="node()|text()">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="node()|text()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="establishment[count(room) > 1]">
<xsl:for-each select="room">
<establishment>
<xsl:copy-of select="./@*"/>
<xsl:apply-templates select="preceding-sibling::*[not(name() = 'room')] | preceding-sibling::text()"/>
<xsl:copy-of select="."/>
<xsl:apply-templates select="following-sibling::*[not(name() = 'room')] | following-sibling::text()"/>
</establishment>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
|