Presentation is loading. Please wait.

Presentation is loading. Please wait.

Valid XML documents (contd.) For example, if we wanted to turn the example well- formed XML document we have just seen into a valid document, we would.

Similar presentations


Presentation on theme: "Valid XML documents (contd.) For example, if we wanted to turn the example well- formed XML document we have just seen into a valid document, we would."— Presentation transcript:

1 Valid XML documents (contd.) For example, if we wanted to turn the example well- formed XML document we have just seen into a valid document, we would insert a line which would look like where someDTDspec would specify what rules must be followed by a valid people element Although a doctype statement may directly contain an internal DTD, we will consider only the cases where a doctype statement refers to an external DTD, because these are the most useful

2 DOCTYPEs referring to external DTDs A doctype statement which refers to an external DTD has one of two formats: In the first format, the keyword SYSTEM says that the external DTD is on the local machine and fileNameAndPath says where to find it In the second format, the keyword PUBLIC says that the external DTD is publicly available on the Internet, the fpi (Formal Public Identifier) gives its formal name and the url says where it can be found

3 Example DOCTYPEs referring to external DTDs The doctype statement says that the external DTD is on the local machine, in a file called myFirstDTD.dtd The doctype statement says that the external DTD is publicly available on the Internet, gives it a formal name which should be used by everybody who wants to refer to it, and says where it can be found

4 Formal Public Identifiers We will be focussing on system DTDs but some of you may be wondering about the format of FPIs like -//UCC//DTD PEOPLE v1.0//EN This format is actually defined by an ISO standard and FPIs like this can be registered with organizations which are authorized by the ISO Council to act as FPI registrars The format is the - (which could also be a + ) indicates whether/not the organization name which follows is ISO-registered; UCC is not UCC is an OwnerID, the name of the organization which owns and maintains the document identified by the FPI DTD is a Public Text Class, a keyword identifying the type of doc PEOPLE v1.0 is a unique descriptive name for the document EN is the Public Text Language, in which the doc is written

5 Formal Public Identifiers (contd.) For example, this is the formal public identifier for one version of the HTML 4 specification: -//W3C//DTD HTML 4.01//EN the W3C is not an ISO-registered organization the HTML4 specification is a DTD HTML 4.01 is a unique descriptive name EN says that the specification is written in English

6 XML document which claims to be valid The Daffodils William Wordsworth I wandered lonely as a cloud That floats on high o’er vales and hills When all at once I saw a crowd A host of golden daffodils Something something something...

7 Another XML document claiming to be valid Ray Burke 1 Margaret Thatcher 75

8 Document Type Definitions A DTD defines the syntax rules for an application-specific type of XML-documents. A DTD describes the root element that may appear in a valid document and, in doing so, also describes the kinds of children elements that the root element may possess A DTD must contain element type declarations, statements which have the following general format: In addition, a DTD may contain a range of other types of statement, only one of which we will cover here, attribute declarations, statements which are used to define the attributes which elements may have.

9 Element Type Declarations An element type declaration is a statements which has the following general format: where contentModel describes the content (if any) that may or must exist between the start tag and the closing tag (if any) of the element whose name is elementName

10 Empty Elements Empty elements are declared using the keyword EMPTY inside the parentheses Example: which declares an element which only has a start tag and which, unless it has some attribute(s), must be written as

11 Elements with Character content Elements that contain character data are declared as follows: where #PCDATA stands for “parsed character data” Example: This element declaration would be satisfied by the following text in an XML file January

12 Elements with element content Elements that contain only children elements are declared as follows: or <!ELEMENT element-name (child-name1, child-name2,...)> Example which specifies that a country element contains exactly one child element, a position element:.....

13 Elements with element content (contd.) Example which specifies that a memorandum element contains a sender element, followed by a recipient element, followed by a message element When a sequence of children elements is declared, as above, the children must appear in exactly the same sequence in conforming XML documents:...........


Download ppt "Valid XML documents (contd.) For example, if we wanted to turn the example well- formed XML document we have just seen into a valid document, we would."

Similar presentations


Ads by Google