Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / July 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Samuel R. Neff - 20 Jul 2006 14:56 GMT
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
Martin Honnen - 20 Jul 2006 15:10 GMT
> 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
[quoted text clipped - 4 lines]
> <?xml version="1.0" encoding="UTF-8" ?>
> <xsl:stylesheet

>     xmlns="http://schemas.microsoft.com/intellisense/ie5"
>     xmlns:msxsl="urn:schemas-microsoft-com:xslt"
[quoted text clipped - 5 lines]
>        
>         <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).

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

Samuel R. Neff - 20 Jul 2006 15:33 GMT
So if exclude-result-prefixes won't strip out the ns what will?

Thanks,

Sam

>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 - 20 Jul 2006 16:10 GMT
> 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>

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

Samuel R. Neff - 20 Jul 2006 16:25 GMT
Thanks.

>> So if exclude-result-prefixes won't strip out the ns what will?
>
[quoted text clipped - 8 lines]
>     </xsl:element>
>   </xsl:template>

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.