By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,781 Members | 1,364 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,781 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Jul 20 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a


Samuel R. Neff wrote:
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
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>
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
<div xmlns="http://schemas.microsoft.com/intellisense/ie5">
</div>
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
http://JavaScript.FAQTs.com/
Jul 20 '06 #2

P: n/a

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 <ma*******@yahoo.de>
wrote:
>
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).
Jul 20 '06 #3

P: n/a


Samuel R. Neff wrote:
So if exclude-result-prefixes won't strip out the ns what will?
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
http://JavaScript.FAQTs.com/
Jul 20 '06 #4

P: n/a

Thanks.

On Thu, 20 Jul 2006 17:10:34 +0200, Martin Honnen <ma*******@yahoo.de>
wrote:
>

Samuel R. Neff wrote:
>So if exclude-result-prefixes won't strip out the ns what will?

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>
Jul 20 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.