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 November 9th, 2010, 01:37 PM
Registered User
 
Join Date: Nov 2010
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Need help to handle namespace tags in xml file

Hi , I am new learner of XSLT. From last couple of days I am trying to transform the following XML file. But facing issue while handling namespaces in that XML file.

This is the input XML file I have

Code:
<tcpTraceLog tcpTraceVersion='0.8.1.717' xmlns='http://www.pocketsoap.com/tcptrace/xmlformat/01' xmlns:xsd='http://www.w3.org/1999/XMLSchema' xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'>
<logStarted xsi:type='xsd:timeInstant'>2010-10-26T19:09:26-04:00</logStarted>
<connection>
	<loggedAt xsi:type='xsd:timeInstant'>2010-10-26T19:11:41-04:00</loggedAt>
	<source>3.152.82.191</source>
	<clientData>POST /wss/services/OnAirService HTTP/1.1
			Content-Length: 345
		<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 						                     xmlns:urn="urn:login.onair.sintecmedia.com">
   		<soapenv:Header/>
   			<soapenv:Body>
      			<urn:login>
         				<urn:in0>DHAWKS</urn:in0>
         			</urn:login>
   			</soapenv:Body>
		</soapenv:Envelope></clientData>
<serverData>HTTP/1.1 500 Internal Server Error
 	<?xml version="1.0" encoding="UTF-8"?>
	<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
			xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 
			xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
			xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
			xmlns:ns2="urn:stub.onair.sintecmedia.com" 
			xmlns:ns1="urn:login.onair.sintecmedia.com">
		<SOAP-ENV:Header></SOAP-ENV:Header>
		<SOAP-ENV:Body>
			<SOAP-ENV:Fault>	
				<ns2:message_>
				<ns2:code>Client.InvalidCredentials
</ns2:code>
				</ns2:message_>	
			</SOAP-ENV:Fault>
		</SOAP-ENV:Body>
	</SOAP-ENV:Envelope>
	</serverData>
</connection>
</tcpTraceLog>

In this XML file I am just trying to display two elements(mentioned in red colour) in html file.
For the above requirement I wrote a some ugly XSLT code its not working fine

XSLT CODE :

Code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:abc="http://www.pocket.com/tcptrace/xmlformat/01" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:login.onair.sintecmedia.com"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns2="urn:stub.onair.sintecmedia.com" xmlns:ns1="urn:login.onair.sintecmedia.com"
xmlns:int="http://SintecMedia.com/OnAir/interfaces" version="1.0">
<xsl:output method="html"/>

  <xsl:template match="abc:tcpTraceLog/*/urn:in0 ">
        <html>
            <body>
                <xsl:value-of select="."/>
            </body>
        </html>
    </xsl:template>

    </xsl:stylesheet>

Expected output :

DHAWKS





Thanks in Advance for any one great help...
 
Old November 9th, 2010, 01:45 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

If you change
match="abc:tcpTraceLog/*/urn:in0"
to
match="abc:tcpTraceLog//urn:in0"
and then insert
Code:
<xsl:template match="text()"/>
you might get what you want although I would use a different approach.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old November 9th, 2010, 01:48 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

I only now noticed that you have a "<?xml version="1.0" encoding="UTF-8"?>" in the middle of the XML, that is not allowed.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
The Following User Says Thank You to Martin Honnen For This Useful Post:
gkrishna.tibco (November 10th, 2010)





Similar Threads
Thread Thread Starter Forum Replies Last Post
[XSLT] Group tags to prioritize the xml file sacha74 Other Programming Languages 0 September 21st, 2009 05:10 AM
error CS0234: The type or namespace name 'Xml' does not exist in the namespace 'Syste shailesh_kumar C# 2008 aka C# 3.0 8 August 20th, 2009 03:11 AM
Need to convert an existing namespace and add new namespace to the SOAP xml Prabeen XSLT 10 April 28th, 2009 10:18 AM
convert XML to XMl - Another Namespace question bonekrusher XSLT 2 July 10th, 2007 07:32 AM
How to handle default namespace declaration? moltenlava XSLT 1 January 4th, 2006 06:49 PM





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