Re: Some questions on specifying empty XML elements

/ Gino Basso <GBasso@ware2.com> was heard to say:
| I'm trying to duplicate the following DTD in an XML schema:
| 
|     <!ELEMENT nothing EMPTY>

I think the way to do this is:

<xsd:complexType name='EmptyType'>
  <xsd:complexContent>
    <xsd:restriction base='xsd:anyType'/>
  </xsd:complexContent>
</xsd:complexType>

| What about XML instances? While XML itself provides two mechanisms for
| indicating that an element does not have any content, <nothing></nothing>
| and <nothing/>, it is a violation of the specification to use the former if
| the associated DTD declares the element to be EMPTY (as with the DTD above).

That's not the case. <nothing/> and <nothing></nothing> are equivalent
and both are legal if the element nothing is declared EMPTY in an XML DTD.

| What about when validating an instance against either of the above schemas?
| Does the schema specification distinguish between the two mechanisms for
| indicating empty content?

No. There is no distinction.

                                        Be seeing you,
                                          norm

-- 
Norman Walsh <ndw@nwalsh.com> | We dance around in a ring and suppose,
http://nwalsh.com/            | but the Secret sits in the middle and
                              | knows.--Robert Frost

Received on Wednesday, 29 November 2000 06:28:15 UTC