What is DTD DTD defines a set of
- Slides: 39
What is DTD?
ü DTD defines a set of rules that describes how an XML file should be. ü DTD is used for structuring the XML document. SYMBOLS USED IN DTD “No symbol” means element must appear exactly once. * Means 0…infinity (element can appear any number of times). | means only one element can appear at a time from a list of elements. + means >=1(element must appear atleast once). ? means 0 (or) 1(element must appear exactly once or not at all).
HOW TO WRITE DTD FILES
STATEMENT 1: <!ELEMENT bookstore (book)> Bookstore book book
STATEMENT 2: <!ELEMENT bookstore (book+)> Bookstore book book
STATEMENT 3: <!ELEMENT bookstore (book? )> Bookstore book book
STATEMENT 4: <!ELEMENT bookstore (book*)> Bookstore book book
<!ELEMENT bookstore (book | title | volume )> STATEMENT 5: Bookstore book title volume Bookstore book volume title Bookstore book title volume
STATEMENT 6: <!ELEMENT book (title, author, isbn, publisher, edition, price)> **NOTE: The order should be strictly followed. book title author title isbn publisher edition price
STATEMENT 7: <!ELEMENT book (title, author, isbn, publisher, edition, price)*> book title author isbn publisher edition price
<!ELEMENT book (name , author)> book name author book author STATEMENT 8: name author book name author
<!ELEMENT book (name , author)*> book name STATEMENT 9: name author book author name author book name author
<!ELEMENT book (name , author)+> book name STATEMENT 10: name author book author name author book name author
<!ELEMENT title (#PCDATA)> STATEMENT 11: title C C++ JAVA PHP
STATEMENT 12: <!ELEMENT author (#PCDATA)> author balaguruswamy Herbert Schildt author Uttam K Roy author Chris bates
<!ELEMENT edition (#PCDATA)> edition second edition first STATEMENT 13: edition third edition Twelfth
STATEMENT 14: <!ELEMENT price (#PCDATA)> price $45 edition $35 edition $90 edition $55
TYPES OF DTD’S
ü There are two types of DTD: (i) Internal DTD: If the DTD is declared inside an XML document, then the DTD is called Internal DTD. (ii) External DTD: If the DTD is declared in a separate file, and linked to the XML document, then the DTD is called External DTD.
ü The syntax for creating Internal DTD is: <!DOCTYPE Root-Element [Element Declarations]> ü The syntax for creating External DTD is: <!DOCTYPE Root-Element SYSTEM/PUBLIC “DTD-File-Name”> ü The syntax for declaring Element in DTD is: <!ELEMENT Element-Name Type-of-Element> ü The syntax for declaring Attribute in DTD is: <!ATTLIST Default> Element-Name Attribute-Type
EXAMPLES ON INTERNAL DTD’S
EXAMPLE 1
<!DOCTYPE lms [ <!ELEMENT lms (book) > Book. xml DTD (RULES) ]> <lms> <book> </book> <book> </lms> XML DOCUMENT
<!DOCTYPE lms [ Book. xml <!ELEMENT lms (book) > <!ELEMENT book (name, author) > DTD (RULES) <!ELEMENT name (#PCDATA)> <!ELEMENT author (#PCDATA)> ]> <lms> <book> <name> JAVA </name> <author> Herbert Schildt </author> </book> XML DOCUMENT </lms>
<!DOCTYPE lms [ Book. xml <!ELEMENT lms (book) > <!ELEMENT book (name, author) > DTD (RULES) <!ELEMENT name (#PCDATA)> <!ELEMENT author (#PCDATA)> ]> <lms> <book> <name> JAVA </name> <author> Herbert Schildt </author> </book> </lms> XML DOCUMENT
EXAMPLE 2
<!DOCTYPE lms [ Book. xml <!ELEMENT lms (book*) > <!ELEMENT book (name, author) > DTD (RULES) <!ELEMENT name (#PCDATA)> <!ELEMENT author (#PCDATA)> ]> <lms> <book> <name> JAVA </name> <author> Herbert Schildt </author> </book> <book> XML DOCUMENT <name> PHP </name> <author> Robert W Sabesta </author> </book> <name> C++ </name> <author> Balaguruswamy </author> </book> </lms>
EXAMPLE 3
<!DOCTYPE lms [ <!ELEMENT lms (title, author) > Book. xml DTD (RULES) ]> <lms> <title> <author> </title> </author> </lms> XML DOCUMENT
<!DOCTYPE lms [ <!ELEMENT lms (title, author) > <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> Book. xml DTD (RULES) ]> <lms> <title> JAVA </title> <author> schildt </author> XML DOCUMENT </lms>
<!DOCTYPE lms [ <!ELEMENT lms (title, author) > <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> Book. xml DTD (RULES) ]> <lms> <title> JAVA </title> <author> schildt </author> </lms> XML DOCUMENT
EXAMPLE 4
<!DOCTYPE lms [ <!ELEMENT lms (title, author)* > <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> Book. xml DTD (RULES) ]> <lms> SE </title> <author> Pressman </author> <title> C++ </title> <author> Ashok </author> <title> JAVA </title> <author> Schildt </author> <title> PPL </title> <author> Sabesta </author> </lms> XML DOCUMENT
EXAMPLE 5
<!DOCTYPE lms [ <!ELEMENT lms (title*, author*) > Book. xml DTD (RULES) ]> <lms> <title> <author> </title> </author> </lms> XML DOCUMENT
<!DOCTYPE lms [ <!ELEMENT lms (title*, author*) > <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> Book. xml DTD (RULES) ]> <lms> <title> SE </title> JAVA </title> C++ </title> PHP </title> XML DOCUMENT <author> Pressman </author> <author> Schildt </author> <author> Ashok </author> <author> Sabesta </author> </lms>
EXAMPLES ON EXTERNAL DTD’S
Book. xml <? xml version=“ 1. 0” standalone=“no”? > <!DOCTYPE lms SYSTEM “book. dtd”> Book. dtd <!ELEMENT lms (title, author)* > <!ELEMENT title (#PCDATA)> <!ELEMENT author (#PCDATA)> <lms> SE </title> <author> Pressman </author> <title> C++ </title> <author> Ashok </author> <title> JAVA </title> <author> Schildt </author> <title> PPL </title> <author> Sabesta </author> </lms>
- What is dtd?
- Training set validation set test set
- Total set awareness set consideration set
- Dtd
- 30% income tax
- Adbs
- Dtd
- Dtd
- Type:document
- Dtd syntax
- Dtd
- Dtd
- Dtd
- Abdurazik
- Visual studio
- Dtd in web technology
- Dtd xml
- Dtd idrefs
- Whats dtd
- Dtd vs schema
- Internal dtd
- Bounded set vs centered set
- What is the overlap of data set 1 and data set 2?
- Crisp set vs fuzzy set
- The function from set a to set b is
- Crisp set vs fuzzy set
- Crisp set vs fuzzy set
- Triangle ohms law
- Hair design elements
- Xml dom defines a standard way for
- A javacup specification defines which of the following?
- What statement defines the dynastic cycle
- Conclusion of cold chain
- Which statement best defines a cell
- Defines ohm's law
- The value of acknowledgement field in a segment defines
- Tragic definition literature
- The value of acknowledgement field in a segment defines
- Management dilemma meaning
- Cima management accounting definition