110 likes | 438 Views
Overview of XML Schema. Greg Alvord Senior Data Architect, RealEC Chairman Architecture Committee. Agenda. Motivation W3C Schema. Motivation For Schema. Why Did MISMO switch from DTD to Schema? W3C Schema did not exist when 2.X Started First goal of V3 was to use schema
E N D
Overview of XML Schema Greg Alvord Senior Data Architect, RealEC Chairman Architecture Committee
Agenda • Motivation • W3C Schema
Motivation For Schema • Why Did MISMO switch from DTD to Schema? • W3C Schema did not exist when 2.X Started • First goal of V3 was to use schema • DTD does not have data typing • Most Development tools use schema
DTD does not have data typing • V2 Approach. • Date is a string • Implementation Guide states format • Many developers never saw the IG Poorly formed date data huge drain on productivity. • V3 Approach • Xsd:date data type format same as V2 recommendation. (ISO 8601) • Test by schema validation
Motivation For Schema • Why Should Developers Understand Schema? • Schema is your specifications • Structure • Data Types • Documentation • If your code produces XML • Test your output with schema • If your code accepts XML • Require schema valid input. • Schema validate input • Development • Testing
A Few Best Practices • NEVER make or consume XML as string. • Better to use an XML object in whatever library you are using. • XML Objects usually have a serialized string property. • Best to use data model object and serialize or de-serialize to XML. • Use .NET XSD.exe to read schema write object model. • Use other similar tools in other platforms.
MISMO use of Schema • XSD Extension on published Schema files • xsd: prefix in schema files. • Most data in xsd:element • Security attributes • Connecting attributes • Other attributes. • XML Encryption • XML Signature
MISMO use of Schema • Namespace used • Root file MISMO_3.2.0_B290.xsd <xsd:schemaxmlns="http://www.mismo.org/residential/2009/schemas" targetNamespace=http://www.mismo.org/residential/2009/schemas • Chameleon – xsd:include files • No target namespace • No declared namespace
Namespace • Why does it look like a URL? • URL is kind of URI • http: Means we could, but have not yet, make a page available. • Why does it contain 2009? • Change Namespace with release • Fixed Namespace (X)
MISMO use of Schema • Some data in xsd:attributes • //LOANS/LOAN/@SequenceNumber • //LOANS/LOAN/@LoanRoleType • SubjectLoan – The loan that is the object of the transaction, upon which the receiving business partner will take some action. • RelatedLoan – A loan linked to the subject loan by virtue of being collateralized by the same property. Examples include the loan being refinanced, or a HELOC or other subordinate lien collateralized by the same property as the subject loan.
Sequence And Choice Group • xsd:sequence • Defines order of element children • Order counts • Lexicographically ordered list • Lexicographical order is called “Dictionary order” Capitalizations and white space is ignored. “_” is treated like a space. • xsd:choice • Defines exclusive choice • Comes before other elements