SolvedPrivate

Need XSLT

Posted on 2013-12-20
1
27 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert Oracle data into XML document 2 65
How do I bind the results to a grid 3 36
XML & .net 5 47
Formatting issues in XSL FO 3 37
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

770 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