Subject: Re: Aargh - wrong template applied
From: "andrew welch" <andrew.j.welch@xxxxxxxxx>
Date: Thu, 20 Apr 2006 09:36:30 +0100
|
> > The fact that it's the same namespace as everything else is
> > irrelevant. If
> > it's in a namespace, then references to it in the stylesheet need
> > to be
> > prefixed.
> >
> > See http://www.dpawson.co.uk/xsl/sect2/N5536.html #13 and #23
>
> Ok, I get it. Binding the XHTML namespace to the html prefix lets me
> match with html:font. The document I'm processing now has the XHTML
> namespace as the default, whereas the other documents I've been
> working with had no namespace.
>
> It really [expletive deleted] that I can't assign a default namespace in my
> stylesheet.
If you have to match elements in both a namespace and no namespace,
then just have:
match="html:font|font"
where html is the prefix of the namespace, and "font" is the match for
the element in no namespace. I don't think you would want to assign a
default namespace in the stylesheet... unless of course you have lots
of match patterns and don't want to change each one...... in which
case do a two step transform to remove any namespaces, eg:
<xsl:variable name="firstPass">
<xsl:apply-templates mode="removeNamespaces"/>
...
<xsl:template match="*" mode="removeNamespaces">
<xsl:element name="{local-name()}">
<xsl:copy-of select="@*"/>
<xsl:apply-templates mode="removeNamespaces"/>
....
Then apply your usual transform on $firstPass.
cheers
andrew
|