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:39] – knehez | tanszek:oktatas:techcomm:dtd [2024/10/07 17:57] (current) – [Complex DTD Example for a Hypothetical Mail Processing System] knehez | ||
|---|---|---|---|
| Line 14: | Line 14: | ||
| === Internal declaration === | === Internal declaration === | ||
| - | < | + | <sxh> | 
| < | < | ||
| .... | .... | ||
| Line 21: | Line 21: | ||
| === External URI === | === External URI === | ||
| - | < | + | <sxh> | 
| < | < | ||
| </ | </ | ||
| === External file === | === External file === | ||
| - | < | + | <sxh> | 
| < | < | ||
| </ | </ | ||
| Line 36: | Line 36: | ||
| Here is a DTD file named '' | Here is a DTD file named '' | ||
| - | < | + | <sxh> | 
| < | < | ||
| < | < | ||
| Line 52: | Line 52: | ||
| In the XML structure, a **comma** indicates the required order of elements: | In the XML structure, a **comma** indicates the required order of elements: | ||
| - | < | + | <sxh> | 
| < | < | ||
| < | < | ||
| Line 69: | Line 69: | ||
| The **pipe symbol `|`** expresses an **either-or** relationship. For example, the storage device can be either a **pendrive** or an **SSD**, but not both: | The **pipe symbol `|`** expresses an **either-or** relationship. For example, the storage device can be either a **pendrive** or an **SSD**, but not both: | ||
| - | < | + | < | 
| - | < | + | < | 
| < | < | ||
| < | < | ||
| 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.1728322746.txt.gz · Last modified: 2024/10/07 17:39 by knehez
                
                