Presentation is loading. Please wait.

Presentation is loading. Please wait.

August 20061 Chapter 2 - Markup and Core Concepts Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.

Similar presentations


Presentation on theme: "August 20061 Chapter 2 - Markup and Core Concepts Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology."— Presentation transcript:

1 August 20061 Chapter 2 - Markup and Core Concepts Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology Radford University

2 August 20062 XML Syntax “Syntax” refers to the rules of a language Syntax is needed with any language so that the documents created with that language are consistent Programs that process documents expect the syntax rules to be followed, otherwise the document may not be interpreted correctly

3 August 20063 Components of an XML Document XML Declaration Elements Attributes Entities Comments

4 August 20064 Components: The XML Declaration The XML Declaration: –Tells the processing program that the document is an XML document, along with other optional information –The declaration is always the first line of an XML document –Attributes that can be used in the Declaration: version encoding standalone –Example:

5 August 20065 Document Type Declaration Document type declarations are used to define entities or default attribute values. Secondly, they are used to support validation, a special mode of parsing that checks grammar and vocabulary of markup. A validating parser needs to read a list of declarations for element rules before it can begin to parse. In both cases, this is done in document type declaration section. A document type declaration consists of: - delimeter <!DOCTYPE - element name identifies the type element - dtd id local path or url - entity decl optional list of entity declara. dtd identifier supports two methods of identification: system-specific and public

6 August 20066 XML Syntax “Syntax” refers to the rules of a language Syntax is needed with any language so that the documents created with that language are consistent Programs that process documents expect the syntax rules to be followed, otherwise the document may not be interpreted correctly

7 August 20067 Components: XML Elements Elements: –Used to describe the data. Consist of: A start tag Content An end tag –Example: Content –The “root” element of a document is the outermost element, and contains all of the other elements in the document. There can be only one root element in a single document An element that does not contain any content is known as an “empty element”

8 August 20068 Element Nesting The term “nesting” refers to the process of containing elements within other elements Terminology: –Child elements – elements that are contained within other elements –Parent elements – elements that contain other elements –Sibling elements – elements that share the same parent element

9 August 20069 Nesting Example 1 2 Sally 3 Joe 4 5 Larry 6 Curly 7 Mo 8 9

10 August 200610 Components: XML Attributes Attributes help to describe XML elements Attributes are always contained in the start tag of the element they are describing Attributes are known as “name-value pairs” Example: address=“123 Main Street”

11 August 200611 Components: XML Entities Two types of entities: –General – placeholders for information contained in the XML document –Parameter – used within a DTD to reference a grouping of elements Three types of general entities: –Character – used in place of special characters –Content – used for blocks of frequently used text –Unparsed – used for binary or non-text data, like image files

12 August 200612 Examples of Entities Character entity: –Character: > –Entity reference: > or > –Usage: x > y Content entity: –Declaration: –Usage: &address; Unparsed entity: –Declaration: –Usage: &aimage;

13 August 200613 Components: Comments An XML comment is ignored by applications that process XML Comments are commonly used for documentation, or to add information for others viewing the document The content of the comment is surrounded by special comment tags: Example:

14 August 200614 Well-Formed XML Documents A “well-formed” document is one which adheres to the syntax rules for XML: –An XML document contains one root element –All elements must have start and end tags, except for empty elements –Elements must be properly nested –All attributes must have a value –Attributes can only appear in the start tag and must be unique to that element –Element names are case-sensitive –Special characters must be written as entities –Names of element can start only with letters or an underscore, and can contain letters, numbers, hyphens, periods and underscores

15 August 200615 XML Parsers A “parser” is a program that checks the syntax of an XML document to ensure that the document is well-formed Two types of parsers: –Non-validating – only checks for syntax –Validating – checks syntax and verifies the document against a DTD or Schema


Download ppt "August 20061 Chapter 2 - Markup and Core Concepts Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology."

Similar presentations


Ads by Google