|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Q: Stripping ns from source tree?
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








