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

RE: Selecting First Letter

Subject: RE: Selecting First Letter
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Tue, 30 Sep 2003 23:09:27 +0100
xslt first letter
> In your case, assuming you want the character in bold to be 
> the initial 
> character inside the p, at any level,
> 
> <xsl:template match="text()[not(preceding::text()
>    [count(.|current()/ancestor::p//text()) =
>     count(current()/ancestor::p//text())])]">
> 
> would do it, but you can see how horrible that is!
> 
> Not foolproof, but
> 
> match="text()[starts-with(ancestor::p,.)]"
> 
> would usually work (and would most probably perform better).
> 
> So today's XSLT Challenge is to write a better match for this problem.

I think that

<xsl:variable name="n"><xsl:number level="any" from="p"/></xsl:variable>
<xsl:choose>
<xsl:when test="$n = 1">...

works reasonably, though it can't be done in the match pattern, except
(in XSLT 2.0) by invoking an xsl:function from the predicate.

Michael Kay


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


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.