Re: [xsl] Testing implicit XHTML hierarchy

Subject: Re: [xsl] Testing implicit XHTML hierarchy
From: "bryan rasmussen" <rasmussen.bryan@xxxxxxxxx>
Date: Thu, 5 Jul 2007 02:13:51 +0200
oh, damn, I see it never mind.

sorry, have a pretty bad headache, and would like to avoid what I
should be doing.

cheers,
Bryan Rasmussen

On 7/5/07, bryan rasmussen <rasmussen.bryan@xxxxxxxxx> 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@xxxxxxxxx> 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.
> ________________________________________________________________________

Current Thread