getting SOAPBody elements with xsl

Discussion in 'XML' started by wsdeveloper, Sep 22, 2005.

  1. wsdeveloper

    wsdeveloper Guest

    I have a SOAP Message like the following:
    <?xml version="1.0" encoding="utf-8"?>
    <?xml-stylesheet type="text/xsl" href="CreateCoordinationContext.xsl"?>
    <soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
    <wsa:Action soapenv:mustUnderstand="0"
    xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">

    http://schemas.xmlsoap.org/ws/2004/10/wscoor/CreateCoordinationContext
    </wsa:Action>
    <wsa:To soapenv:mustUnderstand="0"
    xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">

    http://dutige.st.ewi.tudelft.nl/wstf-coordinator/services/Activation
    </wsa:To>
    <wsa:ReplyTo soapenv:mustUnderstand="0"
    xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
    <wsa:Address>urn:Initiator</wsa:Address>
    </wsa:ReplyTo>
    <wsa:MessageID
    soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
    soapenv:mustUnderstand="0"
    xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
    uuid:92f447576866786d:40a96d8e:10631b4fd84:-7fff
    </wsa:MessageID>
    </soapenv:Header>
    <soapenv:Body>
    <CreateCoordinationContext
    xmlns="http://schemas.xmlsoap.org/ws/2004/10/wscoor">
    <Expires>0</Expires>
    <CoordinationType>http://schemas.xmlsoap.org/ws/2004/10/wsat</CoordinationType>
    </CreateCoordinationContext>
    </soapenv:Body>
    </soapenv:Envelope>

    what i would like to extract is the value of Expires and
    CreateCoordinationContext elements but nothing seems to work
    i tried the following:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:a="http://schemas.xmlsoap.org/ws/2004/10/wscoor"
    exclude-result-prefixes="soapenv" version="1.0">
    <xsl:template match="/">
    <html>
    <body>
    <h2>SOAP BODY</h2>
    <table border="1">
    <tr bgcolor="#9acd32">
    <th align="left">Expires</th>
    <th align="left">CoordinationType</th>
    </tr>
    <tr>
    <td>
    <xsl:value-of
    select="/soapenv:Envelope/soapenv:Body/a:CreateCoordinationContext/a:Expires"/>
    </td>
    <td>
    <xsl:value-of
    select="/soapenv:Envelope/soapenv:Body/node()[1]/node()[2]"/>
    </td>
    </tr>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>
    but i don't get any answer i don't see where is the problem.
    Thanks in advance fo any suggestion.
     
    wsdeveloper, Sep 22, 2005
    #1
    1. Advertising

  2. wsdeveloper

    wsdeveloper Guest

    i have found the error so for anyone intersted i post it here.
    first the SOAP should not have any ref to the xsl:
    <?xml version="1.0" encoding="utf-8"?>
    <soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header>
    <wsa:Action
    soapenv:mustUnderstand="0"xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">

    http://schemas.xmlsoap.org/ws/2004/10/wscoor/CreateCoordinationContext
    </wsa:Action>
    <wsa:To soapenv:mustUnderstand="0"
    xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">

    http://dutige.st.ewi.tudelft.nl/wstf-coordinator/services/Activation
    </wsa:To>
    <wsa:ReplyTo soapenv:mustUnderstand="0"
    xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
    <wsa:Address>urn:Initiator</wsa:Address>
    </wsa:ReplyTo>
    <wsa:MessageID
    soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
    soapenv:mustUnderstand="0"
    xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
    uuid:92f447576866786d:40a96d8e:10631b4fd84:-7fff
    </wsa:MessageID>
    </soapenv:Header>
    <soapenv:Body>
    <CreateCoordinationContext
    xmlns="http://schemas.xmlsoap.org/ws/2004/10/wscoor">
    <Expires>0</Expires>

    <CoordinationType>http://schemas.xmlsoap.org/ws/2004/10/wsat</CoordinationType>
    </CreateCoordinationContext>
    </soapenv:Body>
    </soapenv:Envelope>

    then the xsl should look like this
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:wscoor="http://schemas.xmlsoap.org/ws/2004/10/wscoor"
    exclude-result-prefixes="soapenv" version="1.0">
    <xsl:template match="/">
    <html>
    <body>
    <h2>SOAP BODY</h2>
    <table border="1">
    <tr bgcolor="#9acd32">
    <th align="left">Expires</th>
    <th align="left">CoordinationType</th>
    </tr>
    <tr>
    <td>
    <xsl:value-of
    select="/soapenv:Envelope/soapenv:Body/wscoor:CreateCoordinationContext/wscoor:Expires"/>
    </td>
    <td>
    <xsl:value-of
    select="/soapenv:Envelope/soapenv:Body/wscoor:CreateCoordinationContext/wscoor:CoordinationType"/>
    </td>
    </tr>
    </table>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>

    so the different namespaces have to be imported in the xsl.
     
    wsdeveloper, Sep 22, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Flood
    Replies:
    0
    Views:
    1,023
    Kevin Flood
    Sep 8, 2004
  2. Replies:
    0
    Views:
    386
  3. Sonna Nach
    Replies:
    0
    Views:
    805
    Sonna Nach
    Mar 8, 2005
  4. Replies:
    1
    Views:
    3,613
    A. Bolmarcich
    May 27, 2005
  5. Rob Smegma
    Replies:
    1
    Views:
    1,818
    shaun
    Sep 26, 2005
Loading...

Share This Page