Groups | Blog | Home
all groups > dotnet xml > july 2006 >

dotnet xml : XslTransform not excluding default namespace despite exclude-result-prefixes attribute?



Samuel R. Neff
7/20/2006 9:56:23 AM
I'm writing an xslt in vs.net 2003 and in order to get intellisense on
the html content I added the default namespace declaration
xmlns="http://schemas.microsoft.com/intellisense/ie5". However, even
though I also have exclude-result-prefixes="#default" declared the
default namespace is still outputted on the resulting document.

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://schemas.microsoft.com/intellisense/ie5"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="#default msxsl">

<xsl:output method="html" indent="yes" />

<xsl:template match="/">

<div>
</div>
</xsl:template>
</xsl:stylesheet>

And this still gives resulting html:

<div xmlns="http://schemas.microsoft.com/intellisense/ie5">
</div>

I tried adding the xsl:exclude-result-prefixes attribute to the <div>
element and it had no effect.

Am I doing something wrong? How can I get rid of the ns declaration
on the resulting document? The source document has no namespace
declarations.

Thanks,

Sam

Samuel R. Neff
7/20/2006 10:33:26 AM

So if exclude-result-prefixes won't strip out the ns what will?

Thanks,

Sam


On Thu, 20 Jul 2006 16:10:42 +0200, Martin Honnen <mahotrash@yahoo.de>
[quoted text, click to view]
Samuel R. Neff
7/20/2006 11:25:16 AM

Thanks.

On Thu, 20 Jul 2006 17:10:34 +0200, Martin Honnen <mahotrash@yahoo.de>
[quoted text, click to view]
Martin Honnen
7/20/2006 4:10:42 PM


[quoted text, click to view]

This means that div result element for instance is in that namespace
with URI http://schemas.microsoft.com/intellisense/ie5 and has to be output

[quoted text, click to view]

that way, whether you use exlucde-result-prefixes or not.

Exclude-result-prefixes does not strip any result elements or attributes
of their namespace, it only helps to avoid namespace declarations in the
output for namespaces not used with result elements or attributes (but
rather in XPath expressions or match patterns).



--

Martin Honnen --- MVP XML
Martin Honnen
7/20/2006 5:10:34 PM


[quoted text, click to view]

If you don't want an element to have a namespace then don't use one on it.
If you need it for your tool then with XSLT I only see a way if you run
a second transformation which strips that namespace from elements e.g.
<xsl:template
xmlns:ie="http://schemas.microsoft.com/intellisense/ie5"
match="ie:*">
<xsl:element name="{local-name()}" namespace="">
<xsl:apply-templates select="@* | node()" />
</xsl:element>
</xsl:template>

--

Martin Honnen --- MVP XML
AddThis Social Bookmark Button