I'm currently working with XSLT, although rather simplistic. I'm struggling trying to remove the encodingstyle property from a SOAP XML envelope using XSLT scripts.
This is the XML I'm working with, a simple testing envelope:
Expand|Select|Wrap|Line Numbers
- <?xml version="1.0" encoding="ISO-8859-1"?>
- <soapenv:envelope xmlns:urn="schemas-microsoft-com:office:spreadsheet" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
- <soapenv:header/>
- <soapenv:body>
- <urn:helloworld soapenv:encodingstyle="http://schemas.xmlsoap.org/soap/encoding/">
- <clientdata xsi:type="urn:clientdata">
- <username xsi:type="xsd:string">test</username>
- <password xsi:type="xsd:string">test</password>
- </clientdata>
- </urn:helloworld>
- </soapenv:body>
- </soapenv:envelope>
Expand|Select|Wrap|Line Numbers
- <envelope>
- <body>
- <helloworld>
- <clientdata>
- <username>test</username>
- <password>test</password>
- </clientdata>
- </helloworld>
- </body>
- </envelope>
This is the current script Im working with:
Expand|Select|Wrap|Line Numbers
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="xsi">
- <xsl:output method="xml" omit-xml-declaration="yes" indent="no"/>
- <xsl:template match="/|comment()|processing-instruction()">
- <xsl:copy>
- <xsl:apply-templates/>
- </xsl:copy>
- </xsl:template>
- <xsl:template match="*">
- <xsl:element name="{local-name()}">
- <xsl:apply-templates select="@*|node()"/>
- </xsl:element>
- </xsl:template>
- <xsl:template match="@xsi:type"/>
- <xsl:template match="@encodingstyle"/>
- </xsl:stylesheet>
Expand|Select|Wrap|Line Numbers
- <envelope>
- <header />
- <body>
- <helloworld>http://schemas.xmlsoap.org/soap/encoding/
- <clientdata>
- <username>test</username>
- <password>test</password>
- </clientdata>
- </helloworld>
- </body>
- </envelope>
I'm thinking the quickest and easiest way to get rid of the header is by using something along the lines of copy-of select="soap:body/*" so the only remaining thing is infact the body (which is perfectly fine too). However, I just cannot figure out how to rid the encodingstyle property entirely. Something such as " <xsl:template match="@encodingstyle"/> " does not appear to have any effect whatsoever.
Does anyone have any hits/suggestions, or perhaps an alteration to my script?
Thanks in advance.