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
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
486
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
12
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Document Type Definitions – Elements & Attributes
    XML
  • 2. How many times can an element occur?
    How many times must an element occur?
    Cardinality
  • 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
    Element
    Attribute
    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>
    ID, IDREF, IDREFS
  • 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

×