Download presentation
Presentation is loading. Please wait.
Published byMitchell Weaver Modified over 9 years ago
1
CIS 451: XML DTDs Dr. Ralph D. Westfall February, 2009
2
Additional XML Issues what is a "well-formed" XML document? what is a "valid" XML document? what is a DTD? how do you create DTDs?
3
Well-Formed XML Document Great Gatsby a uniquely named root element one or more elements elements are properly nested inner tags always closed before outer ones
4
Well-Formed Document - 2 complies with XML rules for example: has "legal" characters regular alphanumeric characters &#_ _ _ ; special characters identified by decimal #s (like &60; = < in HTML) &#x_ _ _ _ _ _ ; hexadecimal #s (0-f) other files pulled into document must also be well-formed (e.g., stylesheets)
5
Valid XML Document must be a well-formed document must also comply with "rules" in a data type definition (DTD) DTD contains specifications ("rules") created by user user creates both rules and XML document tags if you don't like the rules, change them!!
6
Creating a DTD separate file (use.dtd extension, not.xml) DTD can be in same file, but separate is much better all elements defined by DTD starts with a root element, which contains other elements remaining elements either contain more elements, or specifications for type of data
7
Creating a DTD - Start slsrcpt.xml.doc make sure that you: put <?xml etc. at top of.dtd file don't put <!DOCTYPE etc. in.dtd file error if <!DOCTYPE is in both.xml and.dtd files put identifies DOCTYPE (root element) and pulls in.dtd file (like an include or a reference to an external stylesheet)
8
Creating a DTD - Root textbooks is "root" element textbooks element contains at least one book element + means one or more (like in regular expressions) similar spelling is NOT necessary e.g., could have texts element as root
9
Creating a DTD - Children book element contains 5 elements description element can be absent ? means optional (once or not at all) (just like in regular expressions) how many times does price appear?
10
Creating a DTD - Data title element contains PC (parsed character) data e.g., the.xml file has following line ASP.NET 1.0 the text between the tags is the data
11
Creating a DTD - Empty price is an "empty" element (no data) empty element can have attributes (next page) can also have an effect (cf. HTML effect) 2 ways to close elements (empty or not) (always have to close) (abbreviated like in ASP form)
12
Creating a DTD - Attributes <!ATTLIST price US CDATA #REQUIRED> identifies 1 or more attributes, as follows: element name price attribute name US type CDATA (character data) default #REQUIRED (other options) better if attribute list is just below the corresponding element (but not required)
13
Creating a DTD - Declarations element declaration symbols ( ) group of items (title, ISBN, authors), comma means exact order (a, b, c) a b c | pipe means any order (a | b | c) c b a ok ? once or not at all * zero to many times + one to many times (no symbol) means exactly one time
14
Put DTD Link into XML File 2 nd line of file replace [name of] with actual filename
15
Exercise modify the slsrcpt.xml.doc file (or your file)slsrcpt.xml.doc create.dtd file to match this file's pattern can use syllabus2.dtd.doc as a sample patternsyllabus2.dtd.doc put a link to slsrcpt.dtd file in slsrcpt.xml test with a VBScript file (or use xmlint.exe)VBScriptfilexmlint.exe xmlint [file].xml (in DOS) put xmlint.exe and slsrcpt.xml in same directory now correct your errors
16
Sample Form
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.