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, it might have been causing a problem without throwing an error.


On Wed, Feb 26, 2014 at 4:21 AM, Ihe Onwuka <ihe.onwuka@gmail.com> wrote:
Code working on 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


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

    <xsl:variable name="scores" as="element(scores)">
          <xsl:when test="$rating[1] and $rating[2]">
            <xsl:attribute name="score" select="$rating[1]"/>
            <xsl:attribute name="outOf" select="$rating[2]"/>
          <xsl:when test="$title5 = $letterGrades">
            <xsl:attribute name="score"
            <xsl:attribute name="outOf" select="100"/>
          <xsl:when test="matches($title5,'\d*[.]*\d*') and
            <xsl:attribute name="score" select="$title5"/>

In 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

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.
saxon-help mailing list archived at http://saxon.markmail.org/


"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.