xsl-list
[Top] [All Lists]

Re: [xsl] Removing unwanted namespaces

2012-01-11 11:17:13
Hi Ram,

I didn't test it but I think you could try with <xsl:copy copy-namespaces="no"> in your copy template. (and maybe also add exclude-result-prefixes="#all" on the <xsl:stylesheet> element)

And just another thing, try :

<xsl:template match="*[local-name()='abcdHeader'] ">

instead of :

<xsl:template match="//*[local-name()='abcdHeader'] ">

You don't need to specify the whole path in every @match, particulary when you use functionnal templates with <xsl:apply-templates> within each template.

Hope this helps,

Matthieu

Le 11/01/2012 16:55, ram a écrit :
Hi,
    I have a soap request which contains header and body information. I want to 
remove the content inside the header and the namespaces for those which are 
inside the  header .
   Here is my example

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:con="http://abcd.com/abc/context"; 
xmlns:dat="http://test.com/test/testContracts"; xmlns:head="http://abcd.com/abc/header"; 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
        <soapenv:Header>
                <head:abcdHeader>
                        <head:Props>
                                
                        </head:Props>
                        <head:Routing>
                                
                        </head:Routing>
                </head:abcdHeader>
                <con:Context>
                        <con:CtxProps>
                                context info
                        </con:CtxProps>
                </con:Context>
        </soapenv:Header>
        <soapenv:Body>
                Body content
        </soapenv:Body>
</soapenv:Envelope>


The output i am expecting is like below
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:dat="http://test.com/test/testContracts";  
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
        <soapenv:Header>
                
        </soapenv:Header>
        <soapenv:Body>
                Body content
        </soapenv:Body>
</soapenv:Envelope>


    I tried the following xslt code which removes the Header Info, but it still 
keeping the namespaces which references the ones inside the  header.


        <xsl:template match="@*|node()">
                <xsl:copy>
                        <xsl:apply-templates select="@*|node()"/>
                </xsl:copy>
        </xsl:template>
        <xsl:template match="//*[local-name()='abcdHeader'] ">
                
                </xsl:template>
        <xsl:template match="//*[local-name()='Context'] "/>    


The output that i am getting

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:dat="http://test.com/test/testContracts";
xmlns:head="http://abcd.com/abc/header";
xmlns:con="http://abcd.com/abc/context";
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";>
        <soapenv:Header>
                
        </soapenv:Header>
        <soapenv:Body>
                Body content
        </soapenv:Body>
</soapenv:Envelope>

    i dont want to header and context namesspaces in the output. How to fix 
this issue.

--kk




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--
Matthieu Ricaud
05 45 37 08 90
NeoLibris


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--