SolvedPrivate

Need XSLT

Posted on 2013-12-20
1
25 Views
Last Modified: 2016-02-26
Hi,

I have the below response received from a SOAP request. I need to take a value and put it in a table with Header as "Error Message". Output needs to be in HTML format.

Below is the SOAP error response:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
      <s:Body>
            <s:Fault>
                  <faultcode>s:Server</faultcode>
                  <faultstring>SAMPLE TEXT</faultstring>
                  <detail>
                        <ProcessingFault xmlns="http:/abcd.com/Invoice/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                              <Code>1234</Code>
                              <Message>SAMPLE TEXT</Message>
                        </ProcessingFault>
                  </detail>
            </s:Fault>
      </s:Body>
</s:Envelope>

I want the value of tag Message and Code in a table with header as ERROR MESSAGE and ERROR CODE.

Please assist.

Regards
Pradeep
0
Comment
Question by:Pradeep0308
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 39731584
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:inv="http:/abcd.com/Invoice/"
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
    exclude-result-prefixes="xsd s inv"
    version="1.0">
    
    <xsl:template match="/">
        <html>
            <head></head>
            <body>
                <xsl:apply-templates select="//s:Body"/>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template match="s:Body">
        <table border="1">
            <tr>
                <th>Code</th>
                <th>Message</th>
            </tr>
            <xsl:apply-templates select="s:Fault"/>
        </table>
    </xsl:template>
    
    <xsl:template match="s:Fault">
        <tr>
            <td><xsl:value-of select="//inv:ProcessingFault/inv:Code"/></td>
            <td><xsl:value-of select="//inv:ProcessingFault/inv:Message"/></td>
        </tr>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now