Re: [xsl] self axis vs .

Subject: Re: [xsl] self axis vs .
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 06 Jun 2008 11:58:22 -0400
Hi,

At 08:59 AM 6/6/2008, Andrew wrote:
An interesting practice I've come across at a client's site is instead
of using . they use self:: instead...

So instead of:

<xsl:apply-templates select="." mode="other"/>

you have

<xsl:apply-templates select="self::elem" mode="other"/>

and instead of:

.//whatever

you have:

self::elem//whatever

While it seemed a little odd to start with, their argument of it helps
locate where you are (especially when . is far away from the match
pattern that's normally used to discover the current node) is
beginning to grow on me...

It also works to test whether the current node is actually an 'elem' when you process it or traverse from it.


Since when it isn't, it is silently filtered out, this could be regarded as either a feature or a bug. If this isn't desired as a feature, it may be a bug (or a bug waiting to happen), or perhaps at best gilding the lily.

But it might serve as a sideways incentive for maintenance programmers to learn their XPath. :-)

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread