Mega Code Archive

 
Categories / XML Tutorial / XML Schema
 

Defining Empty Elements

Elements that can contain attributes but that have no content between the opening and closing tags are considered empty. File: Schema.xsd  <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"   targetNamespace="http://www.rntsoft.com" xmlns="http://www.rntsoft.com"   elementFormDefault="qualified">   <xsd:complexType name="sourceType">     <xsd:complexContent>       <xsd:extension base="xsd:anyType">         <xsd:attribute name="sectionid" type="xsd:integer" />         <xsd:attribute name="newspaperid" type="xsd:integer" />       </xsd:extension>     </xsd:complexContent>   </xsd:complexType>      <xsd:element name="source" type="sourceType" /> </xsd:schema>   File: Data.xml <?xml version="1.0"?> <source xmlns="http://www.rntsoft.com" sectionid="101" newspaperid="21"/>