Hi Martin,
In order to avoid the monster match pattern, I'd probably relent from
my usual habits and put part of the testing here into an explicit conditional:
<xsl:template match="div0//text()[normalize-space()]">
<xsl:choose>
<xsl:when test="not(ancestor-or-self::node()[ancestor::div0]/
preceding-sibling::node()[normalize-space()]">
<!-- basically Ken's test, only broken up -->
<wrapper>
<xsl:value-of select="substring(.,1,1)"/>
</wrapper>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring(.,1,1)"/>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="substring(.,2)"/>
</xsl:template>
Ordinarily, I'm inclined to think that choose/when/otherwise is less
elegant than doing the selection entirely in the match pattern. This
is an exception, since I think that (for maintenance purposes) this
is easier both to understand, and to comment with whatever
explanation is called for to understand it fully.
Note that I've also varied slightly from Ken's solution in not
requiring the text node to be in a paragraph. (I missed whether that
was part of the original requirement.)
It's not a radical improvement but depending on your feelings about
such things you may like the balance it strikes a bit better.
Cheers,
Wendell
======================================================================
Wendell Piez
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--