Your SlideShare is downloading. ×
Document type definitions part 2
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply
  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Document Type Definitions – Elements & Attributes
  • 2. How many times can an element occur?
    How many times must an element occur?
  • 3. A student must have a first name
    A student may or may not have a last name
    A student may have one or more majors, or none (undeclared)
    <!ELEMENT student (first, last?, major*)>
    Note: Cardinality indicator doesn’t affect the element declaration (i.e. major)
    Cardinality: Example
  • 4. Elements tend to be used to describe a logical unit of information
    Attributes are typically used to store data about characteristics (properties)
    May have a Movie element with attributes for Title, Rental Price, Rental Days
    No specific rules about how to use elements and attributes
    Attributes and DTD’s
  • 5. Attributes allow more limits on data
    Can have a list of acceptable values
    Can have a default value
    Some ability to specify a data type
    Concise, about a single name/value pair
    Attributes have limits
    Can’t store long strings of text
    Can’t nest values
    Whitespace can’t be ignored
    Attributes and Elements
  • 6. Declaration:
    <!ATTLISTElementNameAttrNameAttrType Default>
    Specify the Element the attribute belongs to
    Specify the Name of the attribute
    Specify the Type of data the attribute stores
    Specify characteristics of the values (Default or attribute value)
    List either the default value or other characteristic of value – required, optional
    Specifying Attributes
  • 7. CDATA – unparsed character data
    Enumerated – series/list of string values
    Entity/Entities – reference entity definition(s)
    ID – unique identifier for the element
    IDREF – refer to the ID of another element
    IDREFS – list of ID’s of other elements separated by whitespace
    NMTOKEN/NMTOKENS – value(s) of attribute can be anything that follows rules for XML name
    Sample Attribute Data Types
  • 8. Specifies that attribute value must be found in a particular list
    Each value in list must be valid XML name
    Limits on spaces, characters
    Use | (pipe) to separate members of list
    If specifying list letter grades for a student:
    <!ATTLIST student grade (A | B | C | D | F | V | W | I) #IMPLIED>
    Enumerated Attributes
    Enumerated List
  • 9. An ID specifies that the element must have a unique value within the document
    Allows reliable way to refer to a specific element
    No spaces allowed in value
    Typically replace space with underscore
    Attribute list can include only one ID
    IDREF, IDREFS allows an element to be associated with another or multiple other elements
    A student element must have a student ID:
    <!ATTLIST student studentID ID #REQUIRED>
  • 10. Attributes can refer to entities
    “Entity” refers to substituting a reference for a text value
    &amp; refers to the & character
    Unparsed Entity is a reference that isn’t parsed
    Can reuse references for long values, or hard to manage characters (i.e. tab, line feed)
    Entity must be declared in the DTD
    <!ENTITY classTitle “XML”>
    When classTitle found in document, replaced with XML
    Entities and Attributes
  • 11. Can specify how the value will appear in the document
    Must always specify a value declaration
    DEFAULT sets a value for an attribute if a value isn’t provided
    Include default value in double quotes
    FIXED sets a value that must occur; if an attribute has a different value, a validation error occurs
    REQUIRED specifies that the attribute (and value) must exist
    IMPLIED means the attribute is optional
    Attribute Value Declarations