forcing strongly typed variables
Added by Anonymous about 14 years ago
Legacy ID: #8464672 Legacy Poster: Andriy Gerasika (andriy_gerasika)
Hello, Michael, Would it be reasonable to add something like saxon:force-type="yes" to xsl:stylesheet element? -- it would signal an error when "as" is missed on xsl:variable, xsl:param or xsl:function declarations inside the xsl:stylesheet. I am willing to enhance my XSLT code w/ strongly typed variables, hoping it will help to catch bugs more quickly. Thank You Kind Regards, Andriy Gerasika
Replies (2)
RE: forcing strongly typed variables
-
Added by Anonymous about 14 years ago
Legacy ID: #8464853 Legacy Poster: Andriy Gerasika (andriy_gerasika)
p.s. Can you please suggest me the the correct "as" value for: <xsl:variable name="var1"> <xsl:copy-of select="elm1" /> </xsl:variable> if I put as="element()*" it does not seem to work like it did before
RE: forcing strongly typed variables
-
Added by Anonymous about 14 years ago
Legacy ID: #8464920 Legacy Poster: Michael Kay (mhkay)
This is a case where as="" does not merely declare the expected type, it changes the behaviour from the XSLT 1.0 "result tree fragment" behaviour, which implicitly creates a document node. The expansion of this is: <xsl:variable name="x" as="document-node()"> xsl:document <xsl:copy-of .../> </xsl:document> </xsl:variable> However, are you sure you really need to copy the node? Won't working with the original node work just as well? In which case you can use <xsl:variable name="var1" select="elm1"/> Please note that this is an XSLT coding question, nothing specific to Saxon, so it would be best asked on a general XSLT forum such as the xsl-list at mulberrytech.com
Please register to reply