Re: [xsl] Blindstaring on descendent(-or-self), following(-sibling) and the like, from inside an xsl:function

Subject: Re: [xsl] Blindstaring on descendent(-or-self), following(-sibling) and the like, from inside an xsl:function
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Tue, 26 Sep 2006 19:55:26 +0200
Wendell Piez wrote:
<xsl:when test="$current-node/node()[1][self::text()]">
     <xsl:text>NO TAG, JUST TEXT, WRITE FONT_DECL</xsl:text>
</xsl:when>

Just tested it, it works (!), and I also found my mental error, I tried with:


$current-node/node()[1]/text() --- returns all text nodes inside descendants
$current-node/node()/self::text() --- returns all text nodes that are direct children


just didn't think of the third and correct combination you just gave me. Thanks!
... but given your case, don't you want the font_decl *any* time you have a text node child (even in the middle or at the end)? So "$current-node/text()" would be the test?

No, not in the current situation, but I am indeed looking for a better design.
If it passes the test, I think you probably want to shift into a special mode:

<xsl:template match="*" mode="font-wrapper">
<xsl:template match="text()" mode="font-wrapper">

This is what I had, indeed. But because of the irregular winding up/down of the styles for my target format, it got quite messy and I thought of using functions. But perhaps I should reconsider and use more modes (I have some already ;-) )
In any case I suspect that even if this doesn't do the trick, a special mode offers you a much nicer and more general solution to your problem.

Agreed.


Similarly, I wonder if you really want or need a function to do this. In XSLT we can "micro-pipeline", using templates to process the results of using templates; the function looks to me like it's only adding extra overhead.

Please forgive me if I've understood the problem incorrectly.

I think you understood it perfectly. Even though I sometimes think I am grasping it all, XSLT hits me again around the corner, but that makes it one of the most joyful and surprising languages I have ever worked with. Thanks again!


Cheers,
-- Abel

Current Thread