Subject: Re: [xsl] Removing unwanted namespaces From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Wed, 11 Jan 2012 12:35:30 -0500 |
<xsl:template match="*"> <xsl:copy copy-namespaces="no"> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template>
<xsl:template match="/*"> <xsl:copy copy-namespaces="no"> <xsl:copy-of select="@*"/> <xsl:for-each-group select="//*" group-by="namespace-uri(.)"> <xsl:namespace name="{prefix-from-QName(node-name(.))}"> <xsl:value-of select="current-grouping-key()"/> </xsl:namespace> </xsl:for-each-group> <xsl:apply-templates/> </xsl:copy> </xsl:template>
I hope this helps, Wendell
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
-- ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Removing unwanted namespa, Matthieu Ricaud-Duss | Thread | Re: [xsl] Removing unwanted namespa, ram |
Re: [xsl] Selecting all specific ch, Matthieu Ricaud-Duss | Date | Re: [xsl] Selecting all specific ch, Mark |
Month |