Presentation is loading. Please wait.

Presentation is loading. Please wait.

INFSY 547: WEB-Based Technologies Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.

Similar presentations


Presentation on theme: "INFSY 547: WEB-Based Technologies Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg."— Presentation transcript:

1 INFSY 547: WEB-Based Technologies Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg

2 Document Type Definitions

3 XML Parsers Two types of parsers: –Validating: checks document against a DTD or schema –Non-validating: recognizes syntax errors All parsers require well-formed documents Eclipse will check your document

4 DTD Describes the XML object to the processor Models XML structure Constrains the structure –On sequence –On nesting of tags Content may be processed without a DTD

5 DTD’s: 1.Strict rule book for XML document 2.Each tag must be declared 3.Should not contain elements that are absent in the XML document

6 DTD Schemas do the same and more Valid: Structure is correct Ask Eclipse to check Well-formed: XML code may not be be valid. DTD’s can be shared, guaranteeing consistency

7 DTD Provides a list of: –Elements –Attributes –Entities May be embedded in xml document file or in separate file –Always create an external DTD.

8 DTD Attribute types: PCDATA ( parsed character data ) Only content CDATA ( character data that is not markup

9 DTD Document type declaration: refers to the external file: Example:

10 DTD keywords  ELEMENT  Defines tags  ATTLIST  Defines attributes  ENTITY  Defines entities

11 DTD Element Declaration: 1.Element Type Declaration is main building block of a DTD 2.May begin with a a)Letter b)Colon c)Underscore 3.Subsequent to the 1rst character, may also include a period and hyphen

12 1.Build the DTD hierarchically– i.e. from the outside/in 2.Identify the root ELEMENT e.g. Example 1) An * : 0..MANY 2) A + : 1..MANY 3) A ? : 1 TIME DTD Element Declaration (describes document tree structure) Element content/child element

13 Element Declarations: 1.Types of content within an ELEMENT o A list of other elements (as per last page) o Keyword EMPTY (if element will not contain anything)

14  EMPTY e.g. oAn element that has no content. i.e. no child elements.  oReferred to as having children specified.

15 Defining ELEMENT Content 1.Content specification 2.The right side (content specification/model) defines the left side (element name) 3.MIXED content specifies both PCDATA and other elements 4.

16 Attribute declaration:  Can be located anywhere in the DTD good practice: keep it close to the corresponding element  Attributes cannot contain sub elements.

17 Attribute declaration <!ATTLIST book lang CDATA #REQUIRED >

18 Attribute that indicates a reference/link: <!ATTLIST RESOURCES type CDATA "href" > Note: xsl:

19 Image! DTD file:  PIC is listed in the appropriate ELEMENT list in the DTD  an attribute is then defined: ATTLIST elementname attributename CDATA #IMPLIED Example of the attribute in the DTD file:

20 Common Attributes types 1. #CDATA Stands for character/string data Contains any combination of characters except “<“ or “&” Is simple and easy to use May have multiple attributes for an element

21 2.#REQUIRED: attribute must contain some value 3.#IMPLIED: attribute has no default value and may be omitted 4.#FIXED fixedvalue: attribute must always be set to the value, fixedvalue 5.Default: merely type a default value instead of the above

22 Programmer Defined Entities An tag in the DTD In the XML document: Start with a “&” Ends with a “;” Once defined, you may use the entity anywhere within your XML document.

23 Lab Assignment To Be Added!


Download ppt "INFSY 547: WEB-Based Technologies Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg."

Similar presentations


Ads by Google