Document Type Definition (DTD), Lecture notes of Computer Programming

A DTD is a sequence of these declarations enclosed in a DOCTYPE declaration or stored separately ... The DTD definition is stored in its own file, and the.

Typology: Lecture notes

2022/2023

Uploaded on 03/01/2023

dewan
dewan 🇺🇸

4.6

(17)

253 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Document Type Definition (DTD)
A formal, machine-readable specification that
defines the structure of an XML document and
provides some information about the required
content
DTDs Provides syntax for declaring elements,
attribute lists, entities, and notations
DTD element declarations begin with the opening
delimiter sequence
<!
, followed by one of the four
keywords
ELEMENT
,
ATTLIST
,
ENTITY
, or
NOTATION
,
then a case sensitive element name, a content
description, and end with
>
, e.g.,
<!ELEMENT element_name content_description>
A DTD is a sequence of these declarations enclosed
in a
DOCTYPE
declaration or stored separately and
referred to from a
DOCTYPE
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Document Type Definition (DTD) and more Lecture notes Computer Programming in PDF only on Docsity!

Document Type Definition (DTD)

-^

A formal, machine-readable specification thatdefines the structure of an XML document andprovides some information about the requiredcontent

-^

DTDs Provides syntax for declaring elements,attribute lists, entities, and notations

-^

DTD element declarations begin with the openingdelimiter sequence

, followed by one of the four

keywords

ELEMENT

,^

ATTLIST

,^

ENTITY

, or

NOTATION

then a case sensitive element name, a contentdescription, and end with

, e.g.,

•^

A DTD is a sequence of these declarations enclosedin a

DOCTYPE

declaration or stored separately and

referred to from a

DOCTYPE

DTD in XML Prolog (Internal Subset)

** ]>**

**BossTroops15 April 1951The buck stops here. ** •^

Parentheses are grouping operators and commas are andoperators

-^

#PCDATA

means parsed character data

Document Type Definition (DTD)

-^

DTDs can be declared as

PUBLIC

rather than

SYSTEM

where a unique name is specified as the URI and a URIis supplied following the DTD unique name (typicalpractice)

-^

Both external subset and internal subset DTDs may beused in the same document

-^

Operators and keywords available for declaring contentdescriptions: ,

(comma)ordered list (and operator) |

or operator

content grouping

preceding item may occur zero or one time

preceding item may occur one or more times

preceding item may occur zero or more times

#PCDATA

parsed character data

EMPTY

element may not contain content

ANY

element may contain any content

Document Type Definition (DTD)

-^

Attributes are declared with an

declaration, which contains the element name for whichthe attributes are being declared followed by a list ofattribute declarations. Each declaration includes theattribute name, a data type specification, and a defaultdefinition that tells whether the attribute is required andif not, what action the parser should take. Example:

-^

In this example, the

date

attribute is required

(#REQUIRED

) and is of type

CDATA

(character data).

The

priority

attribute is an enumerated type. The

values for the enumeration must be legal XML names,enclosed in parentheses, and separated by

operators. The quoted string

"medium"

in the example

makes the

priority

attribute optional with a default

value of

medium

XML Schema

-^

Created to solve DTD shortcomings.

-^

DTDs have a very weak typing system that can onlyrestrict XML elements to contain no data, other XMLelements, or text data

-^

DTDs do not support data types like integers,decimals, booleans, dates, or enumerations

-^

DTDs do not allow one to specify that the dataappear in a specific format.

-^

DTDs do not support namespaces

-^

DTDs use a different syntax than the XMLdocuments they describe

-^

An XML

s

chema is an XML document that conforms

to the XML

S

chema specification

XML Schema, cont.

-^

Binding an XML schema to an XML document is done via attributes inthe root XML element.

-^

xmlns:xsi

attribute declares the XML Schema namespace

-^

xsi:schemaLocation

attribute declares the location of the XML

schema document being used

-^

xmlns

attribute declares the default namespace being used, which is

defined in the schema document **BossTroops15 April 1951The buck stops here. **

XML Schema, cont.

-^

The root XML element for the XML schema definition is

-^

The

xmlns

attribute of the schema definition binds the

namespace prefix

xsd

to the version of XML Schema

being used, in this case http://www.w3.org/2001/XMLSchema

-^

The

targetNamespace

for the XML schema is the

namespace for the elements and attributes defined by theschema definition. When this schema is referenced byanother XML document, the

targetNamespace

will be

used to qualify the elements defined by this schema.

-^

The

elementFormDefault

attribute set to

"qualified"

indicates that nested elements in the XML

document instance must be namespace qualified; defaultis unqualified.

XML Schema, cont.

•^

XML elements are defined using the

tag

and XML element attributes are defined using the

tag.

•^

The

name

and

type

attributes are used to define the

element/attribute name and data type, respectively.

-^

Elements can be defined as either

complexType

or

simpleType

, attributes can only be

simpleType

. Simple

types can have neither attributes nor child elements.Complex types can have either.

-^

XML Schema defines many built-in atomic types includingstrings, numbers, dates, and times.

-^

The built-in atomic types can be further constrained by a derived

simple type specifying

facets

using the

element, e.g.,

minLength

and

maxLength