Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 4th, 2008, 07:52 PM
Registered User
 
Join Date: Jan 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSL for transforming SOAP response

Hi,

I am new to xsl transformation and looking for some help in solving my problem. I have to parse a soap response into a formatted xml structure.

Soap Response
==============
<soap-env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
  <soap-env:Body>
    <ns0:getResponse>
      <ns0:result>
        <ns1:Attribute1>Value1</ns1:Attribute1>
        <ns1:Attribute2>Value2</ns1:Attribute2>
      </ns0:result>
      <ns0:result>
        <ns1:Attribute1>Value3</ns1:Attribute1>
        <ns1:Attribute2>Value4</ns1:Attribute2>
      </ns0:result>
      ...
    </ns0:getResponse>
  </soap-env:Body>
</soap-env:Envelope>

Expected Result
===============
<rowset>
  <row>
     <attribute1>value1</attribute1>
     <attribute2>value2</attribute2>
  </row>
  <row>
     <attribute1>Value3</attribute1>
     <attribute2>Value4</attribute2>
  </row>
  ...
</rowset>

My xsl: I tried this xsl, but it does not work:
=======
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://xmlns.myorg.com/apps/myDirectory/model/types" xmlns:ns1="http://xmlns.myorg.com/apps/myDirectory/model/" version="1.0">
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="/soap-env:Envelope/soap-env:Body/ns0:getResponse"/>
<rowset>
 <xsl:for-each select="ns0:result">
  <row>
   <attribute1><xsl:value-of select="./ns1:Attribute1"/></attribute1>
   <attribute2><xsl:value-of select="./ns1:Attribute2"/></attribute2>
  </row>
 </xsl:for-each>
</rowset>
</xsl:stylesheet>

Any help is highly appreciated.
Thanks
 
Old January 5th, 2008, 05:57 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You haven't shown the namespace declarations in the SOAP response (for ns0 and ns1). If they really are absent, then you can't process this response using XSLT. If they are present but you left them out, then you may well have left out the very thing we need to check your code is correct.

Also, saying something "didn't work" isn't helpful. To diagnose a problem, one starts from the symptoms - how did it fail?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help needed transforming plist to XML by XSL Vartan XSLT 4 September 28th, 2007 03:11 PM
Trouble Transforming an XML SOAP Response with XSL wsessoms XSLT 1 December 20th, 2006 01:47 PM
How do you transform a XML SOAP Response using XSL wsessoms VB How-To 0 December 20th, 2006 08:21 AM
XSL transforming to TEXT suri_1811 XSLT 8 October 30th, 2006 05:02 AM
Transforming JSP to WML using XSL crispycasper XML 0 May 15th, 2004 12:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.