[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Testing implicit XHTML hierarchy


Subject: Re: [xsl] Testing implicit XHTML hierarchy
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 5 Jul 2007 01:13:23 +0100

me> I may have mistyped, but you shouldn't need the [1]'s

two true statements

me>   in for example $h[.+1][1]
me> as $h[.+1] is %h[position()=.+1] so can return at most 1 item,

a statement that's not quite as true as one might wish...

I don't want to index with . (the value on the sequence) but with
current() the index value coming from the for-each, if I use current()
my statement that you only get one item is true and the code  works (I
claim)

even ran it past saxon this time:-0

sorry about that.

David


<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
  
<xsl:variable name="h"
select="//xhtml:*[matches(local-name(),'^h[1-6]')]/number(substring(local-name(),2))"/>

<xsl:template match="/">
<xsl:if test="not($h[1]=1 and count($h[.=1])=1)">h1 not right</xsl:if>
<xsl:for-each select="1 to count($h)-1">
  <xsl:if test="$h[current()+1]-$h[current()] gt 1">
     section head jumped by more than one level
  </xsl:if>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>


________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________


Current Thread