[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Blindstaring on descendent(-or-self), following(

Subject: Re: 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
Re:  Blindstaring on descendent(-or-self)
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.