This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Determining if the first child is a para element
Ken,
At 02:41 PM 11/9/00 +0000, I wrote:
><xsl:if test="child::node()[not(.=normalize-space(.))][1][self::para]">
> ...
></xsl:if>
But of course after seeing Mike Kay's nice test in another thread, I
realized a slightly more elegant and efficient version would be
<xsl:if test="child::node()[normalize-space(.)][1][self::para]">
...
</xsl:if>
...which reveals further complications (funny how these things are). We
have to make sure it's skipped only if it's a whitespace-only _text_ node
(not, say, an empty element node). So....
<xsl:if test="child::node()[not(self::text()) or
normalize-space(.)][1][self::para]">
...
</xsl:if>
The first predicate evaluates to true if the child node is not a text node
or if it has a non-whitespace string value. The second chooses the first of
these. The third checks to see whether it's a para element.
For evident reasons, that <xsl:strip-space .../> at the top level will be
preferable, if you can use it.
Cheers,
Wendell
======================================================================
Wendell Piez mailto:wapiez@mulberrytech.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