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:40] – knehez | tanszek:oktatas:techcomm:dtd [2024/10/07 17:57] (current) – [Complex DTD Example for a Hypothetical Mail Processing System] knehez | ||
---|---|---|---|
Line 70: | Line 70: | ||
<sxh> | <sxh> | ||
- | < | + | < |
< | < | ||
< | < | ||
Line 90: | Line 90: | ||
| ''?'' | | ''?'' | ||
- | === Example: A music CD contains **tracks**: === | + | ==== Example: A music CD contains **tracks**: |
<sxh> | <sxh> | ||
Line 105: | Line 105: | ||
</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> |
- | + | < | |
- | ```dtd | + | < |
- | < | + | < |
- | < | + | < |
- | < | + | < |
- | < | + | |
- | < | + | |
]> | ]> | ||
- | ``` | + | </ |
**Syntactically correct XML**: | **Syntactically correct XML**: | ||
- | ```xml | + | < |
< | < | ||
- | <cim>Title 1</cim> | + | <title>Title 1</title> |
- | <cim> | + | <title> |
- | <dalcim>Track Title 1</dalcim> | + | <tracktitle>Track Title 1</tracktitle> |
- | <idotartam> | + | <duration> |
- | <dalcim>Track Title 2</dalcim> | + | <tracktitle>Track Title 2</tracktitle> |
- | <idotartam> | + | <duration> |
</ | </ | ||
- | ``` | + | </ |
- | #### Example: A library may contain **books** (zero or more): | + | ---- |
- | ```dtd | + | ==== Example: A library may contain **books** (zero or more)==== |
- | < | + | |
- | < | + | <sxh> |
- | < | + | < |
- | < | + | < |
- | < | + | < |
+ | < | ||
+ | < | ||
]> | ]> | ||
- | ``` | + | </ |
**Syntactically correct XML**: | **Syntactically correct XML**: | ||
- | ```xml | + | < |
- | <konyvtar> | + | <library> |
- | <konyv> | + | <book > |
- | <szerzo>Orwell, George</szerzo> | + | <author>Orwell, George</author> |
- | <cim> | + | <title > |
- | </konyv> | + | </book> |
- | <konyv> | + | <book> |
- | <szerzo>Brown, Dan</szerzo> | + | <author>Brown, Dan</author> |
- | <cim>The Da Vinci Code</cim> | + | <title >The Da Vinci Code</title > |
- | </konyv> | + | </book > |
- | </konyvtar> | + | </library> |
- | ``` | + | </ |
+ | |||
+ | ===== Defining Attributes in DTD ===== | ||
+ | |||
+ | If a class has an attribute such as " | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | Attributes can be: | ||
+ | - **# | ||
+ | - **# | ||
+ | - **#FIXED**: fixed value | ||
+ | |||
+ | === Specifying a Default Attribute Value == | ||
+ | |||
+ | Example: | ||
+ | |||
+ | < | ||
+ | < | ||
+ | </sxh | ||
+ | |||
+ | The XML could look like this: | ||
+ | |||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | === Enumerated Values === | ||
+ | |||
+ | **Syntax**: | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | **DTD Example**: | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | **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: | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | === 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.1728322821.txt.gz · Last modified: 2024/10/07 17:40 by knehez