360 likes | 425 Views
Document Content Description for XML, Version 1.0. By Tim Bray, Charles Frankston and Ashok Malhotra. EECS 684 Presentation by Calvin Ang. Introduction. Presentation Scope Design Principles DCD Framework DCD Vocabulary Datatypes Examples Conclusion. Document Abstract.
E N D
Document Content Description for XML, Version 1.0 By Tim Bray, Charles Frankston and Ashok Malhotra EECS 684 Presentation by Calvin Ang
Introduction • Presentation Scope • Design Principles • DCD Framework • DCD Vocabulary • Datatypes • Examples • Conclusion
Document Abstract • Submission to World Wide Web Consortium • proposes structural schema facility, Document Content Description (DCD) • rules covering structure & content of XML documents • consistent with ongoing W3C Resource Description Framework (RDF) effort • DCD is in many respects similar to an XML DTD, although it hopes to achieve more
Sample DCD Code: Airline Booking • DCD code provides constraints for an airline booking <DCD> <ElementDef Type="Booking" Model="Elements” Content="Closed"> <Description>Describes an airline reservation</Description> <Group RDF:Order="Seq"> <Element>LastName</Element> <Element>FirstInitial</Element> <Element>SeatRow</Element> <Element>SeatLetter</Element> <Element>Departure</Element> <Element>Class</Element> </Group> </ElementDef> <!-- example omits boring field declarations --> <ElementDef Type="SeatRow" Model="Data" Datatype="i1" Min="1" Max="72" /> <ElementDef Type="SeatLetter" Model="Data" Datatype="char" Min="A" Max="K"/> <ElementDef Type="Class" Model="Data" Datatype="char" Default="1"/> </DCD>
Sample DCD Code: Airline Booking • Booking record that conforms to the schema <Booking> <LastName>Bray</LastName><FirstInitial>T</FirstInitial> <SeatRow>33</SeatRow><SeatLetter>B</SeatLetter> <Departure>1997-05-24T07:55:00+1</Departure> </Booking>
Design Principles • DCD is based on the following design principles: 1. DCD semantics is superset of those provided by XML DTDs 2. DCD data model & syntax conformant with RDF 3. Constraints in DCD are usable by authoring tools and other applications retrieving information about document’s content and structure 4. DCD to use mechanisms from other W3C working groups wherever appropriate & efficient 5. DCDs should be human-readable and reasonably clear
DCD Framework • Syntax • Conformant to RDF Model & Syntax Specification • Assumes certain simplifications • Syntax only adopted if ratified by RDF working group
DCD Framework • DCD Nodes and Resource Types • namespace which describes DCD properties and resources is identified by the URI http://w3.org/Schemas/DCD • URI contains the following types: DCD, ElementDef, Group, AttributeDef, ExternalEntityDefand InternalEntityDef • DCD is a document structure description • XML document can fall under the constraints of more than one DCD • Benefit 1 - single DCD used to provide constraints for large numbers of separate documents • Benefit 2 - DCD object provides convenient level of granularity for applying namespace mechanisms
DCD Framework • Resource Types • ElementDef & AttributeDef are more detailed structure descriptors • provide constraints governing elements & attributes in the XML document
DCD Framework • Referring to Elements • DCD declarations constrain the content & attributes of elements in document instances • done by assigning properties to objects of type ElementDef • Elements may have other elements as children, or have attributes provided with certain names and properties • Child elements must be collected together into Groupswhich have Orderand Occursproperties • Each ElementDef must have a unique Typeproperty within the DCD
DCD Framework • Referring to Elements • attributes & elements referred to in a particular DCD may come from the same DCD or from other DCDs identified by namespaces • if element definition comes from another namespace, the value of the Type property may be a qualified name, where the prefix identifies the namespace
Sample DCD Code: Namespace • Element definition comes from another namespace • FirstName, MIand LastNameare defined elsewhere in the DCD but Address comes from a namespace declared with a common prefix <ElementDef Type="person" Model="Elements"> <Group RDF:Order="Seq"> <Element>FirstName</Element> <Group Occurs="Optional"> <Element>MI</Element> </Group> <Element>LastName</Element> <Element>common:Address</Element> </Group> </ElementDef>
DCD Framework • Referring to Attributes • Attributes are defined in DCDs using objects of type AttributeDef • Attribute property • occur on its own as a property of the DCD, or • occur within an element definition • Global property whose value may be True or False (default) • If value of Globalproperty True, the name property must be unique in the DCD • Global attributes can be referred to by their names in any element definition within the DCD
Sample DCD Code: Global Attributes • Hidden is a global attribute in the DCD, while schemas:CLASS is a global attribute from another namespace <DCD> <AttributeDef Name="Hidden" Default="False" Global="True" /> <ElementDef Type="MyType" /> <Attribute>Hidden</Attribute> <Attribute>schemas:CLASS</Attribute> </ElementDef> </DCD>
DCD Vocabulary • Properties Which Apply to DCDs • AttributeDef • declares an attribute type which may be provided for one or more elements in such documents • property does not assert that the attribute is provided for any individual element type • Description • provides a presumably human-readable description of the semantics and usage of this DCD • Value of this property must match the Content under the XML specification
DCD Vocabulary • Properties Which Apply to DCDs • InternalEntityDef & ExternalEntityDef • identify an entity which may be invoked via reference within such documents • value of these properties must be a Node (in RDF terms) • resource which is the property value must be identified by the class mechanism as an InternalEntityDef or ExternalEntityDef • Contents • signals where elements of types not explicitly declared via ElementDef properties may appear in such documents • value of property must be a string whose value is Open or Closed
DCD Vocabulary • Properties Which Apply to DCDs • Namespace • provides the namespace of DCD • value of this property must be a URI which identifies a namespace • this property is required to exist for every DCD • applies to all elements & attributes attached by properties to the DCD <DCD> <?DCD syntax="explicit"?> <Description>about HTML</Description> <Namespace>http://www.w3.org/TR/REC-html40</Namespace> <ElementDef Type="B" Model="Data"/> </DCD>
DCD Vocabulary • Properties Which Apply to Element Definitions • Attribute & AttributeDef • identifies attributes which may be provided for elements of this type • no element definition may have two Attribute or AttributeDef properties referencing attributes that have the same name • Contents • signals whether elements of types not explicitly declared via the Group property may appear as children of elements of this type • value of this property must be a string whose value is Open or Closed
DCD Vocabulary • Properties Which Apply to Element Definitions • Datatype • identifies a specific datatype which constrains the content of elements of this type • value of property must be a string which matches one of an enumerated list of datatypes • property is only meaningful if the value of the Model property is Data
DCD Vocabulary • Properties Which Apply to Element Definitions • Default & Fixed • provides default values for the content of elements of this type • signals whether any value other than the default is allowed • value of default property must be a string • only allowed values of the Fixedproperty are the strings True& False • default property is only meaningful if value of the Model property is Data
DCD Vocabulary • Properties Which Apply to Element Definitions • Description • provides presumably human-readable description of semantics and usage of elements of this type • value of property must match production labeled Content in the XML specification
DCD Vocabulary • Properties Which Apply to Element Definitions • Groups, Occurs & Order • an ElementDef whose Model property has the value Elements must also have a single property named Group, containing specification of the elements and groups which can appear as children of elements of this type • Occurs can take one of 4 values • Required (occurs exactly once)… default value • Optional (occurs zero or only once) • OneOrMore (occurs one or more times) • ZeroOrMore (occurs zero or more times) • Order • Seq (children must occur in specified order… default value) • Alt (only one of specified children may appear)
DCD Vocabulary • Properties Which Apply to Element Definitions • Max, Min, MaxExclusive, MinExclusive • provide upper & lower bounds on the content of elements of this type • Max and Min allow values upto and including the bound • MaxExclusive and MinExclusive allow value less than and greater than the bound, respectively • properties are only meaningful if value of Model property is Data • Model • indicates which of 5 broad classes of constraints apply to the content of elements of this type • value of this property must be a string whose value is one of Empty, Any, Data*, Elements, or Mixed (*default)
DCD Vocabulary • Properties Which Apply to Element Definitions • Root • element definitions can have a root property that indicates whether an element of that type can serve as the root of a conforming document • allowed values are Trueand False (default) • Type • gives the type of the element • property required for every Element resource in DCD • may not contain a prefix or a colon
DCD Vocabulary • Properties Which Apply to Attribute Definitions • Global • indicates whether name property of this attribute must be unique in the DCD • can serve as an address for this attribute definition • possible values are True and False (default) • ID-Role • signals that attribute has unique identifier or unique ID pointer semantics • value of property must be a string whose value is one of ID, IDREF, or IDREFS
DCD Vocabulary • Properties Which Apply to Attribute Definitions • Name • gives name of the attribute • property required for every Attribute resource in DCD • may not contain a prefix or a colon • Occurs • indicates whether the presence of the Attribute is required • can take one of two values • Required • Optional
DCD Vocabulary • Properties Which Apply to Internal Entity Definitions • Name • name by which the entity may be invoked • property is required for every InternalEntity definition resource in DCD • Value • provides replacement text for the internal entity • value of this property must match the production labeled Content in the XML specification • may contain markup and is well-formed
DCD Vocabulary • Properties Which Apply to External Entity Definitions • Name • name by which the entity may be invoked • required to be present for every ExternalEntity definition resource in DCD • PublicID • provides a public identifier for the entity • a string with syntax and semantics similar to XML specifications • SystemID • provides system identifier for the entity • must be provided for every ExternalEntity resource in DCD
Datatypes • Datatype Specifications • modeled after datatypes supported by SQL & other modern programming languages • purpose • specify maximum values on certain datatypes • specify syntax to constrain value of particular element/attribute within these maximum values • specify acceptable formats for specification of such datatypes • referenced from datatype namespace • some require additional properties to be specified
Datatypes • Datatypes in Instances • provides benefit of datatype support to well-formed documents that may not have an associated DTD or DCD • XML parsers expected to provide assistance in encoding & decoding these datatypes
Datatypes • Picture Constraints • picture is an alphanumeric string consisting of character symbols • each symbol usually one character • may be two characters • can be used to constrain format of strings • in some cases control their conversion to numbers
Examples : Picture Constraints • Used to constrain the format of strings & in some cases control their conversion to numbers A A single alphabetic character. B A single blank character. E The character E, used to indicate floating point numbers. S The leftmost character of a picture indicating a signed number. The characters "+” or "-" may appear in the S position. V An implied decimal sign. The input 1234 validated by a picture 99V99 is converted into 12.34. X Any character. Z The leftmost leading numeric character that can be replaced by a space character when the content of that content position is a zero. 9 Any numeric character. 1 Any boolean character (0 or 1). 0,/,-,., and , Represent themselves. cs The currency symbol.
Examples : Picture Constraints • Used to constrain the format of strings & in some cases control their conversion to numbers $123,45.90 satisfies picture $999,99.99 $123,45.90 satisfies picture XXXX,XX.XX 123-45-5678 satisfies picture 999-99-9999 (Social Security Number) 24E80 satisfies picture 99E99 (floating point) 23.45 satisfies picture 99.99 2345 satisfies picture 99V99 (translates to 23.45)
Conclusion • Future Work • DCD’s full potential • requests from database community • several types of constraints required beyond those described • Subclassing and Inheritance • Database Interface • The &-Connector
References • Document Content Description for XML • http://www.w3.org/TR/NOTE-dcd • Namespaces in XML • http://www.w3.org/TR/REC-xml-names/ • Resource Description Framework Model & Syntax Specification • http://www.w3.org/TR/PR-rdf-syntax/