This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Testing for certain combinations
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] Testing for certain combinations
- From: Oleg Tkachenko <olegt at multiconn dot com>
- Date: Thu, 08 Nov 2001 15:19:42 +0200
- Organization: Multiconn International
- References: <004201c16853$19ecad00$0164a8c0@wsnet>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Neil Abraham wrote:
> I need a way of testing whether or not I have 3 or more <a> links separated
> only by <br/> tags within a <p>. This is hard to explain so here are some
> examples:
>
>
> This should test positive:
>
> <p>
> <a href="urlwhatever">Labelwhatever</a><br/>
> <a href="urlwhatever">Labelwhatever</a><br/>
> <a href="urlwhatever">Labelwhatever</a><br/>
> </p>
>
>
> This should test negative since there are only 2 links:
>
> <p>
> <a href="urlwhatever">Labelwhatever</a><br/>
> <a href="urlwhatever">Labelwhatever</a><br/>
> </p>
>
>
> This should also test negative since it contains text outside of <a>:
>
> <p>
> See our great <a href="urlwhatever">products</a> or read
> <a href="urlwhatever">about us</a>. Feel free to
> <a href="urlwhatever">contact us</a> any time.
> </p>
>
>
Stupid solution I only see is
<xsl:choose>
<xsl:when test="name(child::*[1]) = 'a' and name(child::*[2]) = 'br' and
name(child::*[3]) = 'a' and name(child::*[4]) = 'br' and name(child::*[5]) = 'a' and
name(child::*[6]) = 'br' and
and count(*) = 6">Ok</xsl:when>
<xsl:otherwise>Error</xsl:otherwise>
</xsl:choose>
--
Oleg Tkachenko
Multiconn International, Israel
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list