[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Q: Stripping ns from source tree?

Subject: Re: Q: Stripping ns from source tree?
From: Niclas Olofsson <niclas.olofsson@xxxxxxxxxxxx>
Date: Mon, 27 Aug 2001 01:14:47 +0200
exclude namespace
Hi Francis,

Ok, looks interesting. Trying that next. Here is what I've got so far
(on my own).

I changed the namespacing in the original XML to only use default
namespaces where it did apply. I ended up with nested namspaces (mf in
html in mf .. etc) which only made it worse. So, applying a default
namespace to all elements (most of it by inheritence) made the
stylesheet work. In brief (this is not the actual stuff) it looks
something like:

<xsl:template match="html:*">
	<xsl:copy>
		<xsl:copy-of select="@*"/>
		<xsl:apply-templates select="*"/>
	</xsl:copy>
</xsl:template>

But it didn't really solve much of my original problem. So what I'll
have to do is apply your local-name() patch to it and I should be
homesafe.

Thanks,
/Niclas

Francis Norton wrote:
> 
> Hi Niclas,
> 
> Niclas Olofsson wrote:
> >
> > Basically my problem is that the source tree I'm using have 2 different
> > namespaces, one for html and one for my own format ("mf").
> >
> The problem is fairly simple once you understand what's going on.
> 
> First thing - exclude-result-prefixes and xsl:exclude-result-prefixes
> only exclude namespace declarations for namespaces which are *unused* in
> the output. You can't use them to strip namespaces from elements or
> attributes which would otherwise have them.
> 
> Your example uses namespaces in the output in two ways:
> 
> [1]     you've registered a default namespace for all your literal result
> HTML elements
> 
> [2]     you copy HTML-namespace elements in the source document
> 
> So first get rid of that default xmlns="http://www.w3.org/TR/REC-html40"
> in the stylesheet - you don't need it, after all, since you want your
> result elements to be simple HTML.
> 
> Next, let's match any HTML-namespace elements in the source documents
> and automatically create the equivalent element in the output, but not
> in any namespace. We'll use xsl:element for this, with the new element
> name coming from the local-name() of the original.
> 
> OK, here's the stylesheet that implements these two steps, it's tested
> and works with saxon and msxsl -
> 
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0"
>                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>                 xmlns:html="http://www.w3.org/TR/REC-html40"
>                 xmlns:mf="myformat"
>                 exclude-result-prefixes="html mf"
>                 >
> 
>         <xsl:output method="html" omit-xml-declaration="yes"/>
> 
>         <xsl:template match="/">
>                 <HTML
>                         >
>                         <BODY>
>                                 <xsl:apply-templates/>
>                         </BODY>
>                 </HTML>
>         </xsl:template>
> 
>         <xsl:template match="mf:*">
>         <!-- do nothing right now -->
>                 <xsl:apply-templates/>
>         </xsl:template>
> 
>         <xsl:template match="html:*">
>                 <xsl:element name="{local-name()}">
>                         <xsl:apply-templates/>
>                 </xsl:element>
>         </xsl:template>
> </xsl:stylesheet>
> 
> Hope this helps -
> 
> Francis.
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

-- 
Niclas Olofsson - http://www.ismobile.com
Product Development, isMobile, Aurorum 2, S-977 75 Luleå, Sweden
Phone: +46(0)920-75550
Mobile: +46(0)70-3726404

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.