Mega Code Archive

 
Categories / XML Tutorial / XML Schema
 

Value of an attribute is the same as the value we prescribe in the schema, whether or not the attribute is present

File: Schema.xsd <?xml version = "1.0" ?> <schema xmlns= "http://www.w3.org/2001/XMLSchema"> <element name = "CreditAccount">    <complexType>       <sequence>          <element name = "AccountName" type = "string" />          <element name = "AccountNumber" type = "integer" />          <element name = "Amount" type = "string" />       </sequence>       <attribute name = "currency" fixed = "US$" />    </complexType> </element> </schema> File: Data.xml <?xml version = "1.0" ?> <CreditAccount currency = "AUS$">    <AccountName>Joe</AccountName>    <AccountNumber>2701 2202</AccountNumber>    <Amount>200.00</Amount> </CreditAccount>