actually theres more than one item in your sequence that way.
maybe (preliminary guess)
<xsl:template match="/">
<output>
<xsl:variable name="h"
select="//xhtml:*[matches(local-name(),'^h[1-6]')]/number(substring(local-name(),2))"/>
<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[.+1][1])-($h[.][1]) > 1) or
(($h[.+1][2])-($h[.][2]) > 1)">
section head jumped by more than one level
</xsl:if>
</xsl:for-each>
</output>
</xsl:template>
would do it.
on testing; nope that produces too many "section head jumped by more
than one level"
Actually thinking about it the solution is still pretty simple in XSLT
1.0 also, as per:
<xsl:template
match="xhtml:*[starts-with(local-name(),'h')][string-length(substring-after(local-name(),'h'))=1]">
<xsl:variable name="headingtype"
select="number(substring-after(local-name(),'h'))"/>
<xsl:choose>
<xsl:when
test="number(substring-after(local-name(following::xhtml:*[starts-with(local-name(),'h')][string-length(substring-after(local-name(),'h'))=1][1]),'h'))=$headingtype"/>
<xsl:when
test="number(substring-after(local-name(following::xhtml:*[starts-with(local-name(),'h')][string-length(substring-after(local-name(),'h'))=1][1]),'h'))=($headingtype
+ 1)"/><xsl:when
test="number(substring-after(local-name(following::xhtml:*[starts-with(local-name(),'h')][string-length(substring-after(local-name(),'h'))=1][1]),'h'))<
$headingtype "/>
<xsl:when
test="not(following::xhtml:*[starts-with(local-name(),'h')][string-length(substring-after(local-name(),'h'))=1])"/>
<xsl:otherwise><error>the <xsl:value-of
select="number(substring-after(local-name(following::xhtml:*[starts-with(local-name(),'h')][string-length(substring-after(local-name(),'h'))=1][1]),'h'))"/>
following <xsl:value-of select="local-name()"/> does not follow the
rules <xsl:value-of select="."/></error></xsl:otherwise></xsl:choose>
</xsl:template>
<xsl:template match="xhtml:h1" priority="1">
<xsl:if test="following::xhtml:h1"><error>There may be only one
h1</error></xsl:if>
<xsl:if
test="following::xhtml:*[starts-with(local-name(),'h')][string-length(substring-after(local-name(),'h'))=1]">
<xsl:if
test="number(substring-after(local-name(following::xhtml:*[starts-with(local-name(),'h')][string-length(substring-after(local-name(),'h'))=1][1]),'h'))
!= 2"><error>The first heading after h1 must be an
h2</error></xsl:if></xsl:if>
</xsl:template>
that could be cleaned up a bit of course. But I think it is relatively concise.
also have a redundant xsl;if in the xhtml:h1 template, caused by paranoia. :)
okay enough fun, on with the self-torture of tonights coding session.
Cheers,
Bryan Rasmussen
On 7/5/07, David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:
I think you can just do something like
<xsl:variable name="h"
select="//xhtml:*[matches(local-name(),'^h[1-6])]/number(substring(local-name(),2))"/>
<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[.+1]-$h[.] gt 1">
section head jumped by more than one level
</xsl:if>
David
________________________________________________________________________
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.
________________________________________________________________________
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--