Subject: RE: [xsl] XSLT 2.0 empty string From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Mon, 28 Feb 2005 16:48:34 -0000 |
> 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/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSLT 2.0 empty string, David Carlisle | Thread | RE: [xsl] XSLT 2.0 empty string, Andrew Welch |
[xsl] SVG Line Graph from XML?, Barrett | Date | RE: [xsl] XSLT 2.0 empty string, Andrew Welch |
Month |