The company that I work for uses a combination of XML and XSL to render website content. Obviously when we start to get into the trickier XSL we need to include some additional XML Namespaces. We do this by adding the namespace and a schema link to the xsl:stylesheet element of the XSL template, as seen below.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:objDotNet="urn:my-scripts">
Although this gives you additional functionality in what you can do with the template, it will append the namespace to each element that is produced as part of the transform.
<div id="test" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:objDotNet="urn:my-scripts"> Content </div>
After some intense digging on Google I finally found a solution to this problem. All you simply need to do is add another tag to the xsl:stylesheet element.
In the value, add the name of each namespace you want to exclude and separate by a space.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:objDotNet="urn:my-scripts" exclude-result-prefixes="msxsl objDotNet">
The outputted XHTML will now not contain the xml namespaces the elements.
Great!
This worked for me without any issue.
[Nice post, you saved me a lot of time. Thanks
Comment Published: 10/12/2008 at 7:19 AM