Re: [xsl] how to avoid hardcoding xpath-default-namespace in xsl:stylesheet?

Subject: Re: [xsl] how to avoid hardcoding xpath-default-namespace in xsl:stylesheet?
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Sat, 12 Apr 2014 10:54:09 +0100
On 11 Apr 2014, at 23:35, Larry Evans <cppljevans@xxxxxxxxxxxxxx> wrote:

> Hopefully the compilation at the bottom of this
> message  should make clear what I'm after.
> But to be explicit, what do I put after
>
>   xpath-default-namespace=
>
> in the <xsl:stylesheet ... /> to retrieve the namespace used
> in source document.
>

If you're writing a stylesheet and you don't know in advance what names are
going to be used in the source document (whether it's the namespace part or
the local part that you don't know), there are two solutions:

(a) use run-time name matching, e.g. match="*[local-name()=$X and
namespace-uri()=$Y]"

(b) modify the stylesheet as soon as you do know the names, and then
compile/execute the modified stylesheet.

Michael Kay
Saxonica

Current Thread