Mega Code Archive

 
Categories / XML Tutorial / XML Schema
 

Declaring an Element with a Simple Type

An element has a simple type  if it's only allowed to contain other elements or attributes.  There are many different built-in simple types. You can create your own, based on one of the built-in types. File: Schema.xsd <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"   targetNamespace="http://www.rntsoft.com"    xmlns="http://www.rntsoft.com"   elementFormDefault="qualified">   <xs:element name="weight" type="xs:string" /> </xs:schema> File: Data.xml  <?xml version="1.0"?> <weight>3 points</weight> File: Schema.xsd <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"   targetNamespace="http://www.rntsoft.com" xmlns="http://www.rntsoft.com"   elementFormDefault="qualified">   <xs:element name="population" type="xs:integer" /> </xs:schema> File: Data.xml <?xml version="1.0"?> <population>28</population>