DTD Flashcards

1
Q

What is DTD and how is it structured (basic description - no code)?

A

It stands for Document Type Definition.

It is used to descrive the shape of the tree and uses a top down approach.

  1. Defines the name of the root
  2. Describe the direct children
  3. Then describes all their direct children
  4. And so on…

DTD is Dealing Top Down!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

To define an element you use the attached syntax.

What type of content can be defined?

A

Content includes:

  1. ANY: Subtree can take any shape
  2. EMPTY: Must be empty
  3. #PCDATA: Parsed Character Data
  4. (child_element, child_element_2): Define child elements
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you define multiple child elements with the same?

A

Using regular expressions!

  • *item*** (0 or many)
  • *item+** (1 or many)
  • *item?** (0 or 1)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do choice one content or another?

A

Same as majority of programming languages.
By using OR : |

You can mix up contents. See attached examples.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the starting line in a DTD file?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

It is possibel to link to external DTD within xml

What are the two ways to do this?

A

Private
DOCTYPE name SYSTEM “URI”

Public
DOCTYPE name PUBLIC “FPI” “URL”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When linking to an external DTD what are the FPI options?

A

FPI stands for Formal Public Identifier

1) - no standard | + standard DTD
2) Name of group or person who created DTD
3) Type of document and version
4) Language

Each FPI option is seperated with //

Example: “-//mel//Test v2//EN”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you define attributes?

Detail each section.

A

See attached

1) Name of the element
2) Name of the attribute
3) Types:
- CDATA: Simple Char Data
- ENUM: (e.g. (LEFT|CENTER|RIGHT))
- NMTOKEN: Chars of Token must be alphanum with no whitespace including .|-|_|:
Shouldn’t appear anywhere else in the xml
- IDREF: Holds the value of an ID attribute of some element (usually an ancestor element)
3) Defaults:
- #REQUIRED: No default but mandatory
- #IMLPIED: No default and not mandatory
- #FIXED VALUE: Must be present and have value specified
- VALUE: Has value as default

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are entities?

A

Entities are a way of referring to a data item.

Two types include:

General: used in the XML - &name;

Parameter: used within the DTD only - %name;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you define and use an entity?

A

Three ways to define (attached)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the disadvantages of DTD

A
  • No constrains on character data (e.g. int, bool, string(3))
  • Same for attributes
  • No support for namespaces
  • Difficult to reuse code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly