sorry to come in late on this thread... busy time of year...
from the way Ive read it you want to perform an identity transform to
remove to namespace from all of the nodes, this requires just a slight
adaptation of the usual identity transform:
<xsl:transform
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:transform>
Using xsl:copy will copy the node and any any namespaces its in through
to the result tree, as namespace and node are bonded tightly. The only
way to 'remove' the namespace is to create a new node in the result tree
in the default namespace using the local-name() of the current node.
Attributes , ircc, belong in the default namespace unless there is a
namespace given directly to it - they dont belong in the namespace of
their element 'host'. So for example:
<foo:bar baz="bosh"/>
Here element foo is in a namespace prefixed by 'foo', but the @baz is
still in the default namespace. Its for this reason that:
<xsl:template match="@*">
<xsl:copy-of select="."/>
</xsl:template>
...is sufficient to copy through all of the attributes to the result
tree.
xsl:namespace-alias is used when you want the result of the transform to
be an XSLT stylesheet itself, and exclude-result-prefixes only applies
to literal result elements, not those copied from the source tree using
xsl:copy and xsl:copy-of (for the reasons mentioned above).
As for the serialisation to html, Xalan does indeed seem to correctly
output non-null namespaced nodes as xml (and omits the meta from the
<head> interestingly enough), whilst Saxon seems to output html
regardless. MSXML4 outputs <br></br>, which from my reading of the spec
should only happen when the local-name of the element isn't recognised
as part of the html spec...
The significance of this I cant quite figure out, but Im sure as the
xhtml output method of xslt 2.0 arrives issues like this will disappear.
cheers
andrew
> -----Original Message-----
> From: Christian Wolfgang Hujer [mailto:[EMAIL PROTECTED]
> Sent: 14 December 2002 23:16
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: xsl:output method="html" doesn't work with namespace in
> source tree (perhaps a bug)?
>
>
> Hello Scott,
>
> Am Samstag, 14. Dezember 2002 23:58 schrieb [EMAIL PROTECTED]:
> > My knee-jerk is that what you are seeing is not a bug. The
> spec says
> > something about if the node has a namespace on it, it
> should be output as
> > XML rather than as HTML. Since you are assigning the
> default namespace,
> > all the nodes are namespaced and thus must be in XML.
> >
> > -scott
>
> I've finally found it:
> "[...]; an element whose expanded-name has a non-null
> namespace URI should be
> output as XML."
> [ http://www.w3.org/TR/xslt#section-HTML-Output-Method ]
>
> Every time I read a spec,
> I tend to find a new aspect.
> Is that why it's called a spec? ;-)
>
> I've also found a way to get around this:
> <xsl:transform
> version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns=""
> xmlns:html="http://www.w3.org/1999/xhtml"
> >
>
> <xsl:namespace-alias stylesheet-prefix="html"
> result-prefix="#default" />
>
> <xsl:output
> method="html"
> />
>
> <xsl:template match="html:*">
> <xsl:element name="{local-name()}">
> <xsl:apply-templates select="@*|node()"/>
> </xsl:element>
> </xsl:template>
>
> <xsl:template match="@*|node()">
> <xsl:copy>
> <xsl:apply-templates select="@*|node()"/>
> </xsl:copy>
> </xsl:template>
>
> </xsl:transform>
>
> Is there an easier way than the way described to do that?
>
>
> Thanks
> --
> ITCQIS GmbH
> Christian Wolfgang Hujer
> Gesch�ftsf�hrender Gesellschafter
> Telefon: +49 (0)89 27 37 04 37
> Telefax: +49 (0)89 27 37 04 39
> E-Mail: [EMAIL PROTECTED]
> WWW: http://www.itcqis.com/
>
>
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002
>
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002