Unless you specify, an attribute is always optional. You can predefine an attribute's content with a fixed value or a default value. File: Schema.xsd <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.java2s.com" xmlns="http://www.java2s.com" elementFormDefault="qualified"> <xsd:element name="source"> <xsd:complexType> <xsd:complexContent> <xsd:extension base="xsd:anyType"> <xsd:attribute name="sectionid" type="xsd:string" use="required" /> <xsd:attribute name="newspaperid" type="xsd:string" /> </xsd:extension> </xsd:complexContent> </xsd:complexType> </xsd:element> </xsd:schema> File: Data.xml <?xml version="1.0"?> <source xmlns="http://www.java2s.com" sectionid="101" newspaperid="21"/>