xsl-list
[Top] [All Lists]

Re: [xsl] Testing implicit XHTML hierarchy

2007-07-04 17:18:40
obviously that should not be a following-sibling in there but just a following.


Cheers,
Bryan Rasmussen

On 7/5/07, bryan rasmussen <rasmussen(_dot_)bryan(_at_)gmail(_dot_)com> wrote:
actually though, if it were me, I would probably prefer something
along the lines of

<xsl:template match="/">
<output>
<xsl:variable name="h"
select="//xhtml:*[matches(local-name(),'^h[1-6]')]"/>

<xsl:for-each select="$h">
<xsl:if 
test="number(substring-after(local-name(following-sibling::xhtml:*[1]),'h'))
&gt; (number(substring-after(local-name(),'h')) + 1)">
    section head jumped by more than one level
 </xsl:if>
</xsl:for-each>

</output>
</xsl:template>

which is probably not 100% correct, have not tested. (need to add in
the appropriate xhtml:h1 test anyway)

Cheers,
Bryan Rasmussen

On 7/5/07, bryan rasmussen <rasmussen(_dot_)bryan(_at_)gmail(_dot_)com> wrote:
> well i agree there is redundancy (damn I should really do this stuff
> instead of messing around )
>
> but
>
> <xsl:variable name="h"
> 
select="//xhtml:*[matches(local-name(),'^h[1-6]')]/number(substring(local-name(),2))"/>
>
> <xsl:for-each select="1 to count($h)-1">
> <result select="$h[.+1][1]">
>
> <xsl:value-of select="$h[.+1][1]"/>
> </result>
> <result select="$h[.][1]">
>
> <xsl:value-of select="$h[.][1]"/>
> </result>
> <result select="$h[.+1][2]">
> <xsl:value-of select="$h[.+1][2]"/>
> </result>
> <result select="$h[.][2]"><xsl:value-of select="$h[.][2]"/>
> </result>
> </xsl:for-each>
> </output>
> </xsl:template>
>
> produces
>
> <?xml version="1.0" encoding="UTF-8"?>
> <output>
>    <result select="$h[.+1][1]">2</result>
>    <result select="$h[.][1]">1</result>
>    <result select="$h[.+1][2]">5</result>
>    <result select="$h[.][2]">2</result>
>    <result select="$h[.+1][1]">2</result>
>    <result select="$h[.][1]">1</result>
>    <result select="$h[.+1][2]">5</result>
>    <result select="$h[.][2]">2</result>
>    <result select="$h[.+1][1]">2</result>
>    <result select="$h[.][1]">1</result>
>    <result select="$h[.+1][2]">5</result>
>    <result select="$h[.][2]">2</result>
>    <result select="$h[.+1][1]">2</result>
>    <result select="$h[.][1]">1</result>
>    <result select="$h[.+1][2]">5</result>
>    <result select="$h[.][2]">2</result>
>    <result select="$h[.+1][1]">2</result>
>    <result select="$h[.][1]">1</result>
>    <result select="$h[.+1][2]">5</result>
>    <result select="$h[.][2]">2</result>
>    <result select="$h[.+1][1]">2</result>
>    <result select="$h[.][1]">1</result>
>    <result select="$h[.+1][2]">5</result>
>    <result select="$h[.][2]">2</result>
>    <result select="$h[.+1][1]">2</result>
>    <result select="$h[.][1]">1</result>
>    <result select="$h[.+1][2]">5</result>
>    <result select="$h[.][2]">2</result>
>    <result select="$h[.+1][1]">2</result>
>    <result select="$h[.][1]">1</result>
>    <result select="$h[.+1][2]">5</result>
>    <result select="$h[.][2]">2</result>
> </output>
>
> which I'm not following how $h[.+1][2] will always be empty?
>
> Since there are two items in the sequence I mean. Sorry if I'm not
> very clear right now, but I am not thinking especially sharpish.
>
> Cheers,
> Bryan Rasmussen
>
> On 7/5/07, David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:
> >
> > > actually  theres more than one item in your sequence that way.
> > I may have mistyped, but you shouldn't need the [1]'s  in for example
> > $h[.+1][1]
> > as $h[.+1] is %h[position()=.+1] so can return at most 1 item, so [1] is
> > redundant.
> > similarly $h[.+1][2] will always be empty.
> >
> > 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>
--~--