Re: [xsl] RE: What did "template match" match?

Subject: Re: [xsl] RE: What did "template match" match?
From: "Jay Bryant" <jay@xxxxxxxxxxxx>
Date: Fri, 5 Aug 2005 11:20:37 -0500
> That's assuming the different patterns match different names. Doesn't work
> for, say
>
> match="chapter/title | section/title"
>
> Michael Kay
> http://www.saxonica.com/

Which is sometimes the case in my work.

<xsl:value-of select="concat(name(..), '/', name())/>

works for that.

Of course, if you need to walk up very far (or to an unknown number of
ancestors), you'll need a recursive template or function. When I was trying
to get cross-references to work in my document production system, Jeni
Tennison very kindly provided a function. Then, when my understanding grew
enough, I was able to write my own. However, I found that, most of the time,
it's better to just always specify the target for a cross-reference and not
try to write code that guesses. It turned out to not be worth the overhead.

All that aside, I'd use separate templates to better enable both reading and
maintaining the stylesheet. If that throws off alphabetization in your IDE
(if you use one), add a comment to remind yourself where to look.

Jay Bryant
Bryant Communication Services

Current Thread