Subject: Re: [xsl] Q: Stripping ns from source tree? From: Francis Norton <francis@xxxxxxxxxxx> Date: Sun, 26 Aug 2001 21:42:02 +0100 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Q: Stripping ns from source t, Niclas Olofsson | Thread | Re: [xsl] Q: Stripping ns from sour, Niclas Olofsson |
[xsl] Q: Stripping ns from source t, Niclas Olofsson | Date | Re: [xsl] Q: Stripping ns from sour, Niclas Olofsson |
Month |