xsl-list
[Top] [All Lists]

Re: [xsl] Aargh - wrong template applied

2006-04-20 01:36:51
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 sucks 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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--