Ihe, it is not "hocus pocus" it is a very important convention for variable creation.

When you declare a variable using a sequence constructor, it is understood to be a temporary document variable unless you explicitly use @as in the instruction.

With as="element(scores)", you are declaring $scores to be a parentless element node.

Without the as="element(scores)", you are declaring $scores to be a document node.

As to why this causes an error, that probably relates to something you do elsewhere calling $scores when you needed to call $scores/scores (probably) to reference the <scores> element inside the document $scores.

As to why this didn't cause a problem in Saxon 9.3.0.5, it might have been causing a problem without throwing an error.

-David




On Wed, Feb 26, 2014 at 4:21 AM, Ihe Onwuka <ihe.onwuka@gmail.com> wrote:
Code working on 9.3.0.5 started giving

Error on line 231 of review.xsl:
  XPTY0020: Required item type of the context item for the child axis
is node(); supplied
  value has item type xs:string

in 9.5.1.4

Offending? code snippet..... well rather than post that I will post
what fixed it.

    <xsl:variable name="scores" as="element(scores)">
      <scores>
        <xsl:choose>
          <xsl:when test="$rating[1] and $rating[2]">
            <xsl:attribute name="score" select="$rating[1]"/>
            <xsl:attribute name="outOf" select="$rating[2]"/>
          </xsl:when>
          <xsl:when test="$title5 = $letterGrades">
            <xsl:attribute name="score"
select="(100,100,91,83,75,67,58,50,42,33,25,16,16,16,16,8,0,0)[index-of($letterGrades,$title5)]"/>
            <xsl:attribute name="outOf" select="100"/>
          </xsl:when>
          <xsl:when test="matches($title5,'\d*[.]*\d*') and
matches($title5,'\d+')">
            <xsl:attribute name="score" select="$title5"/>
          </xsl:when>
          <xsl:otherwise/>
        </xsl:choose>
      </scores>
    </xsl:variable>

In 9.3.0.5 the above variable did not have a type declaration and the
code worked. In 9.5 it was giving me the reported error until I
declared the variable type.

OK so I have my fix and am happy and evidently some hocus pocus goes
on when you declare a type for a variable that has a sequence
constructor.

You might want to check that the error message is a consequence of a
fix between the versions rather than a regression.

------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help



--

"A false conclusion, once arrived at and widely accepted is not dislodged easily, and the less it is understood, the more tenaciously it is held." - Cantor's Law of Preservation of Ignorance.