[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Finding the ancestor that declared a namespace?


Subject: RE: [xsl] Finding the ancestor that declared a namespace?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Tue, 6 Aug 2002 09:39:36 +0100

> I would like to see if someone has an elegant solution to 
> this problem:
> 
> Suppose that my stylesheet template is situated at an element 
> with a namespace qualifier, e.g.,
> 
>    <bk:Book>
> 
> I would like to find the element which declared the bk: 
> namespace qualifier.

You are looking for the outermost ancestor that has a namespace node for
this namespace.

Let's assume you want the namespace URI to match, regardless of prefix.

ancestor::*[namespace::*[.=namespace-uri(current())]][last()]


Untested.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread