Subject: Re: [xsl] Calculate the average line length within variable name="lines" as="element()*" not including the last line From: Alex Muir <alex.g.muir@xxxxxxxxx> Date: Mon, 12 Apr 2010 10:00:20 +0000 |
Sorry I had shortened the variable name for the post but clearly not in the error message which should have read Description: An empty sequence is not allowed as the value of variable $averageLineLength On Mon, Apr 12, 2010 at 9:57 AM, Martin Honnen <Martin.Honnen@xxxxxx> wrote: > Alex Muir wrote: > >> B <xsl:variable name="lines" as="element()*"> >> B B B <xsl:analyze-string select="text()" regex="`8"> >> B B B B <xsl:non-matching-substring> >> B B B B B <xsl:element name="line"> >> B B B B B B <xsl:attribute name="length" >> select="string-length(normalize-space(.))"/> >> B B B B B B <xsl:attribute name="text" select="."/> >> B B B B B </xsl:element> >> B B B B </xsl:non-matching-substring> >> B B B </xsl:analyze-string> >> B B </xsl:variable> >> >> I can get the average like so including the last line >> >> <xsl:variable name="averageLineLength" >> B B B B B select="round(avg($lines/@length))" as="xs:double"/> >> >> I can get the last line length without error >> >> <xsl:variable name="averageLineLength" >> B B B B B select="round(avg($lines[last()]/@length))" as="xs:double"/> >> >> >> However in the case where my number lines is greater than 2 <xsl:when >> test="$numberLines ge 2"> I don't want to include the last line as >> part of my count and was trying the following >> >> <xsl:variable name="averageLineLength" >> >> B select="round(avg($lines[last()]/preceding-sibling::node()/@length))" >> as="xs:double"/> >> >> >> Which gives me the error: >> >> Description: An empty sequence is not allowed as the value of variable >> $averageSpaceNormalizedLineLength > > I don't see any code with a variable named > "averageSpaceNormalizedLineLength" in your snippets above so it seems as if > you have not posted the relevant code. > > -- > > B B B B Martin Honnen > B B B B http://msmvps.com/blogs/martin_honnen/ > > -- Alex https://sites.google.com/a/utg.edu.gm/alex Some Good Music http://sites.google.com/site/greigconteh/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Calculate the average lin, Martin Honnen | Thread | Re: [xsl] Calculate the average lin, David Carlisle |
Re: [xsl] mixed content grouping by, David Carlisle | Date | Re: [xsl] Calculate the average lin, David Carlisle |
Month |