tanszek:oktatas:techcomm:dtd
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tanszek:oktatas:techcomm:dtd [2024/10/07 17:45] – [DTD Through Examples] knehez | tanszek:oktatas:techcomm:dtd [2025/12/02 08:01] (current) – knehez | ||
|---|---|---|---|
| Line 15: | Line 15: | ||
| === Internal declaration === | === Internal declaration === | ||
| <sxh> | <sxh> | ||
| - | < | + | < |
| .... | .... | ||
| ]> | ]> | ||
| Line 27: | Line 27: | ||
| === External file === | === External file === | ||
| <sxh> | <sxh> | ||
| - | < | + | < |
| </ | </ | ||
| Line 90: | Line 90: | ||
| | ''?'' | | ''?'' | ||
| - | === Example: A music CD contains **tracks**: === | + | ==== Example: A music CD contains **tracks**: |
| <sxh> | <sxh> | ||
| Line 101: | Line 101: | ||
| <sxh xml> | <sxh xml> | ||
| <CD> | <CD> | ||
| - | <felvetel>Song 1</felvetel> | + | <recording>Song 1</recording> |
| - | <felvetel>Song 2</felvetel> | + | <recording>Song 2</recording> |
| </CD> | </CD> | ||
| </ | </ | ||
| - | + | ---- | |
| - | === Example: An album has at least one title, followed by at least one **track title** and **duration**: | + | ==== Example: An album has at least one title, followed by at least one **track title** and **duration**: |
| <sxh> | <sxh> | ||
| Line 130: | Line 130: | ||
| </ | </ | ||
| - | === Example: A library may contain | + | ---- |
| + | |||
| + | ==== Example: A library may contain | ||
| <sxh> | <sxh> | ||
| Line 156: | Line 158: | ||
| </ | </ | ||
| + | ===== Defining Attributes in DTD ===== | ||
| + | |||
| + | If a class has an attribute such as " | ||
| + | |||
| + | <sxh> | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | Attributes can be: | ||
| + | |||
| + | * **# | ||
| + | * **# | ||
| + | * **#FIXED**: fixed value | ||
| + | |||
| + | === Specifying a Default Attribute Value == | ||
| + | |||
| + | Example: | ||
| + | |||
| + | <sxh> | ||
| + | < | ||
| + | </sxh | ||
| + | |||
| + | The XML could look like this: | ||
| + | |||
| + | <sxh> | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | === Enumerated Values === | ||
| + | |||
| + | **Syntax**: | ||
| + | <sxh> | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | **DTD Example**: | ||
| + | <sxh> | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | **XML Example**: | ||
| + | <sxh xml> | ||
| + | <payment type=" | ||
| + | </ | ||
| + | |||
| + | ==== Complex DTD Example for a Hypothetical Mail Processing System ==== | ||
| + | |||
| + | **Task**: Provide an XML example that satisfies the following DTD: | ||
| + | |||
| + | <sxh> | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | === A Possible XML for the given DTD === | ||
| + | |||
| + | <sxh xml> | ||
| + | < | ||
| + | < | ||
| + | <address nick=" | ||
| + | <sender nick=" | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | This provides an example of how attributes, including mandatory, optional, and default values, can be defined in a DTD and represented in an XML document. | ||
tanszek/oktatas/techcomm/dtd.1728323122.txt.gz · Last modified: 2024/10/07 17:45 by knehez
