Re: how to assign a NULL to a variable?
String operations can also be performed on result tree fragments, which are implicitly cast to strings in such cases, so string($rtf) will return the empty string "" if there is "nothing" in the RTF.
(By "nothing" I mean "something signified by the English word 'nothing'", not the literal word or string "nothing". These are the hazards in talking about nulls. In point of fact string($rtf) will also be "" if it contains only empty elements, which can complicate things.)
I don't run across NULL much in my work; for me, Boolean false(), empty sequences or node-sets or strings generally suffice. So the question I have for the OP is "what do you mean by 'NULL'?" Something that tests as "null" (it has no stated value) and something that represents nullity in the output might be two different things, as you imply.
In any case, it's sometimes useful even in XSLT 1.0 to do something like:
<xsl:variable name="result"> <xsl:apply-templates/> </xsl:variable> <xsl:if test="normalize-space($result)">...</xsl:if>
though unfortunately (and perhaps counter-intuitively), $result by itself (that is, not cast explicitly by string() or coerced by normalize-space()) will be cast to Boolean true() even if there is no result from the apply-templates, by virtue of the RTF having a root.
At 11:50 AM 7/26/2007, you wrote:
>> In XSLT 1.0 you have 4 datatypes: number, boolean, string and nodeset. > >actually there is another, and that is the type that will be returned in >this case (with an xsl:variable with eleemnt content). >result tree fragment. >
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format