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 August 25th, 2008, 09:54 AM
Authorized User
 
Join Date: May 2008
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anboss
Default SOAP envelope namespace not shown

Hello

For logging requirement, i am creating a log message of type SOAP that contains request to our application and response from theapplication. These request and response messages are of type SOAP. The request and response messages are enclosed in CDATA tags.

After the required log message is created as an outcome of a transform action, i am not able to see the namespace of the "soapenv" prefix in the request message that is contained in the log message. (prob because the prefix of "Envelope" in log message and that of request is the same) how to get the namespace in the request message also?

the log request is shown below:

<soapenv:Envelope xmlns:v002="http://www.company.com/schema/app/LoggingCommonTypes/V001" xmlns:v1="http://www.company.com/wsdl/app/EnterpriseLogging/V1_0" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dp="http://www.datapower.com/schemas/management">
<soapenv:Header/>
<soapenv:Body>
<v002:verbosityData>
<v002:request>
<soapenv:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<soapenv:Body>

</soapenv:Body>
</soapenv:Envelope>
</v002:request>
<v002:response>
<ns1:Envelope xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:osa="http://www.company.com/xmlschema/resource/metadata/osa/infrastructure/v001">
<ns1:Body>

</ns1:Body>
</ns1:Envelope>
</v002:response>
</v002:verbosityData>
</soapenv:Body>
</soapenv:Envelope>

 
Old August 25th, 2008, 12:18 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Oh dear, yet another person who thinks we can debug their code without seeing it.

If you want to know where your mistake is, you will have to show us your XSLT code.

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
 
Old August 25th, 2008, 01:21 PM
Authorized User
 
Join Date: May 2008
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anboss
Default

Kay

here is the xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
    <xsl:template match="/">
        <xsl:variable name="test">
            <soapenv:Envelope xmlns:dp="http://www.datapower.com/schemas/management" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v002="http://www.company.com/schema/app/LoggingCommonTypes/V001" xmlns:v1="http://www.company.com/wsdl/app/EnterpriseLogging/V1_0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
                <soapenv:Header/>
                <soapenv:Body>
                    <v002:verbosityData>
                        <v002:request>
                            <soapenv:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" 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/">
                                <soapenv:Body/>
                            </soapenv:Envelope>
                        </v002:request>
                        <v002:response>
                            <ns1:Envelope xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:osa="http://www.company.com/xmlschema/resource/metadata/osa/infrastructure/v001">
                                <ns1:Body/>
                            </ns1:Envelope>
                        </v002:response>
                    </v002:verbosityData>
                </soapenv:Body>
            </soapenv:Envelope>
        </xsl:variable>
        <xsl:copy-of select="$test"/>
    </xsl:template>
</xsl:stylesheet>

the ns definition for soapenv(of v002:request) is not present in the output.how to get this ns in the output?




 
Old August 25th, 2008, 04:18 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The namespace declaration is not included in the output because it is redundant. If a containing element has the declaration xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" then this is in scope for all descendant elements and there is no need to declare it again on inner elements. The XSLT serializer will never output redundant namespace declarations and there is no way to make it do so. Why do you need them?

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
 
Old August 25th, 2008, 04:31 PM
Authorized User
 
Join Date: May 2008
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anboss
Default

we will be logging the request and response message present in the log message in linux boxes. after creating the log message i will send this to a webservice. the webservice will extract the request and response soap message out of log message and will log them in linux server. the webservice blindly extracts the request SOAP message (enclosed within CDATA) out of <v002:request> tag and logs it in linux box. ultimately we end up loging a invalid log message. so this is the requirement. so what i think is the logging webservice should insert the namespace for us. correct?

 
Old August 25th, 2008, 04:43 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>the webservice blindly extracts the request SOAP message (enclosed within CDATA) out of <v002:request> tag and logs it in linux box

No-one should blindly extract anything from the middle of an XML message. Elements are meaningless without their namespace context, so any extraction of elements from the middle of a document must be done in a way that preserves the namespace context.

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Processing MS Dynamics XML Envelope Neal XSLT 2 May 22nd, 2008 05:57 AM
CMS Envelope problem chapter 9 luke.koziol BOOK: Beginning Cryptography with Java 1 May 6th, 2007 05:15 PM
how to write multiple namespaces in soap envelope monuindia2002 XML 0 March 1st, 2006 02:29 AM
Envelope-To: kg Pro PHP 4 November 10th, 2004 05:17 PM
Controlling Outgoing Custom XML Envelope Content RaminS Biztalk 1 June 12th, 2003 06:03 AM





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