xml - dtd. the building blocks of xml documents elements, tags, attributes, entities, pcdata, and...
TRANSCRIPT
![Page 1: XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA](https://reader036.vdocument.in/reader036/viewer/2022080923/56649e6b5503460f94b68b72/html5/thumbnails/1.jpg)
XML - DTD
![Page 2: XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA](https://reader036.vdocument.in/reader036/viewer/2022080923/56649e6b5503460f94b68b72/html5/thumbnails/2.jpg)
The building blocks of XML documents
• Elements,
• Tags,
• Attributes,
• Entities,
• PCDATA, and
• CDATA
![Page 3: XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA](https://reader036.vdocument.in/reader036/viewer/2022080923/56649e6b5503460f94b68b72/html5/thumbnails/3.jpg)
Elements
• main building blocks of both XML and HTML documents
• HTML elements are "body" and "table”• XML elements could be "note" and "message“• can contain text, other elements, or be empty• Examples of empty HTML elements are "hr", "br"
and "img".
![Page 4: XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA](https://reader036.vdocument.in/reader036/viewer/2022080923/56649e6b5503460f94b68b72/html5/thumbnails/4.jpg)
Tags
• Tags are used to markup elements.
• A starting tag like <element_name> mark up the beginning of an element
• A body element: <body>body text in between</body>.
• A message element: <message>some message in between</message>
![Page 5: XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA](https://reader036.vdocument.in/reader036/viewer/2022080923/56649e6b5503460f94b68b72/html5/thumbnails/5.jpg)
Attributes
• Attributes provide extra information about elements• placed inside the start tag of an element• Attributes come in name/value pairs• E.g. <img src="computer.gif" />• the attribute is "src". • value of the attribute is "computer.gif". • Since the element itself is empty it is
closed by a " /"
![Page 6: XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA](https://reader036.vdocument.in/reader036/viewer/2022080923/56649e6b5503460f94b68b72/html5/thumbnails/6.jpg)
PCDATA
• PCDATA means parsed character data• character data - the text found between the
start tag and the end tag of an XML element.
• PCDATA is text that will be parsed by a parser
• Tags inside the text will be treated as markup and entities will be expanded.
![Page 7: XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA](https://reader036.vdocument.in/reader036/viewer/2022080923/56649e6b5503460f94b68b72/html5/thumbnails/7.jpg)
CDATA
• CDATA also means character data
• CDATA is text that will NOT be parsed by a parser
• Tags inside the text will NOT be treated as markup and entities will not be expanded.
![Page 8: XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA](https://reader036.vdocument.in/reader036/viewer/2022080923/56649e6b5503460f94b68b72/html5/thumbnails/8.jpg)
Entities• Entities are variables used to define
common text
• Entity references are references to entities
• the HTML entity reference: " "
• Entities are expanded when a document is parsed by an XML parser.
< <
> >
& &
" “
' ‘
The following entities are predefined in XML:
![Page 9: XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA](https://reader036.vdocument.in/reader036/viewer/2022080923/56649e6b5503460f94b68b72/html5/thumbnails/9.jpg)
Declaring an Element
• elements are declared with an element declaration
• <!ELEMENT element-name (element-content)>• Empty elements
– <!ELEMENT img (EMPTY)>
• Elements with data– <!ELEMENT element-name (#CDATA)> – or <!ELEMENT element-name (#PCDATA)> – or <!ELEMENT element-name (ANY)>– example:<!ELEMENT note (#PCDATA)>
![Page 10: XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA](https://reader036.vdocument.in/reader036/viewer/2022080923/56649e6b5503460f94b68b72/html5/thumbnails/10.jpg)
Elements with children (sequences)
• <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#CDATA)>
• <!ELEMENT from (#CDATA)> • <!ELEMENT heading (#CDATA)> • <!ELEMENT body (#CDATA)>
![Page 11: XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA](https://reader036.vdocument.in/reader036/viewer/2022080923/56649e6b5503460f94b68b72/html5/thumbnails/11.jpg)
Wrapping
• <?xml version="1.0"?>• <!DOCTYPE note [ <!ELEMENT note
(to,from,heading,body)> <!ELEMENT to (#CDATA)> • <!ELEMENT from (#CDATA)> • <!ELEMENT heading (#CDATA)> • <!ELEMENT body (#CDATA)> ]>
• <note> • <to>Tove</to> • <from>Jani</from> • <heading>Reminder</heading> • <body>Don't forget me this weekend</body> • </note>
![Page 12: XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA](https://reader036.vdocument.in/reader036/viewer/2022080923/56649e6b5503460f94b68b72/html5/thumbnails/12.jpg)
Declaring Attributes
• attributes are declared with an ATTLIST declaration
• <!ATTLIST element-name attribute-name attribute-type default-value>
• DTD example: – <!ELEMENT square EMPTY> – <!ATTLIST square width CDATA "0">
• XML example: – <square width="100"></square>
![Page 13: XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA](https://reader036.vdocument.in/reader036/viewer/2022080923/56649e6b5503460f94b68b72/html5/thumbnails/13.jpg)
TV Scedule DTD
<!DOCTYPE TVSCHEDULE [ <!ELEMENT TVSCHEDULE (CHANNEL+)><!ELEMENT CHANNEL (BANNER, DAY+)><!ELEMENT BANNER (#PCDATA)><!ELEMENT DAY ((DATE, HOLIDAY) | (DATE, PROGRAMSLOT+))+><!ELEMENT HOLIDAY (#PCDATA)><!ELEMENT DATE (#PCDATA)><!ELEMENT PROGRAMSLOT (TIME, TITLE, DESCRIPTION?)><!ELEMENT TIME (#PCDATA)><!ELEMENT TITLE (#PCDATA)> <!ELEMENT DESCRIPTION (#PCDATA)><!ATTLIST TVSCHEDULE NAME CDATA #REQUIRED><!ATTLIST CHANNEL CHAN CDATA #REQUIRED><!ATTLIST PROGRAMSLOT VTR CDATA #IMPLIED><!ATTLIST TITLE RATING CDATA #IMPLIED><!ATTLIST TITLE LANGUAGE CDATA #IMPLIED> ]>
![Page 14: XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA](https://reader036.vdocument.in/reader036/viewer/2022080923/56649e6b5503460f94b68b72/html5/thumbnails/14.jpg)