Subject: RE: [xsl] Selecting First Letter From: "Jeffrey Winter" <JeffreyWinter@xxxxxxx> Date: Thu, 2 Oct 2003 16:10:43 -0400 |
.. If you did <xsl:number level="any" from="content" .. count="text()[normalize-space()]"/> and only handled number .. 1, you'd work .. around the whitespace problem Dimitre cited without having to strip .. whitespace-only nodes (always a dangerous thing in running .. prose). that works too. Thanks for this info. Just to close this thread, and for the edification of those who come after, here is the final snip of the stylesheet that <xsl:template match="entry"> <!-- other stuff --> <xsl:apply-templates select="content/node()"/> <!-- other stuff --> </xsl:template> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <!-- finds the first non-whitespace text() node within the content element and creates a <b class="firstletter"> element around it --> <xsl:template match="text()"> <xsl:variable name="depth"> <xsl:number level="any" from="content" count="text()[normalize-space()]"/> </xsl:variable> <xsl:choose> <xsl:when test="$depth = 1"> <xsl:variable name="initial" select="substring(.,1,1)"/> <b class="firstletter"><xsl:value-of select="$initial"/></b> <xsl:value-of select="substring-after(.,$initial)"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:template> BTW, the reason I was doing this at all is so that I could supply specific styling to the first letter of some text. I realize that there is the :firstletter psuedo class in CSS, but browser support is very inconsistent even in those browsers that support it at all. Anyway, thanks again. .. Ain't this list amazing? It sure is. - Jeff XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSL java extension newbie, sivaram g | Thread | [xsl] ANN: Visual XSLT 2.0 Beta 1 i, Eric Promislow |
RE: [xsl] A way to use Single quote, David Carlisle | Date | RE: [xsl] how to insert/include the, Robert Koberg |
Month |