[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: XSLT 2.0 empty string
> The confusion comes from this: > > <abc/> > > And a variable that selects <abc>: > > <xsl:variable name="abc" select="abc" as="xs:string?"/> > > And then use the test: > > $abc = '' > > The result is true. However, if <abc/> is not present, the result is > false. > > So, what is the difference between the atomization process > when the node > <abc/> is present but empty, and when it's not there? A world of difference. The typed value (i.e. the atomized value) of an empty element <abc/> actually depends on how it's described in the schema. If there's no schema, the typed value is a zero-length untypedAtomic, which compares equal to the string "". If there's a schema that describes <abc/> as having a simple type of string, then the typed value is a single zero-length string. However, if the schema says that the type is xs:NMTOKENS, then the typed value is an empty sequence. The empty sequence contains no value that's equal to "", so abc="" returns false. If abc is defined in the schema as a complex type that doesn't allow mixed content, then atomizing <abc/> is an error. These rules might seem arbitrary but the reflect the fact that the meaning of an empty element actually depends on what might have been there if it weren't empty. Michael Kay http://www.saxonica.com/
|
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
|