Review Writing XML  Style  Common errors 1XML Technologies - 2012 - David Raponi.

Slides:



Advertisements
Similar presentations
XML 6.3 DTD 6. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:  Elements.
Advertisements

History Leading to XHTML
XML Document Type Definitions ( DTD ). 1.Introduction to DTD An XML document may have an optional DTD, which defines the document’s grammar. Since the.
Tutorial 9 Working with XHTML
XML Study-Session: Part II Validating XML Documents.
Document Type Definition DTDs CS-328. What is a DTD Defines the structure of an XML document Only the elements defined in a DTD can be used in an XML.
CS 898N – Advanced World Wide Web Technologies Lecture 21: XML Chin-Chih Chang
Document Type Definitions
A Technical Introduction to XML Transparency No. 1 XML quick References.
Tutorial 9 Working with XHTML. XP Objectives Describe the history and theory of XHTML Understand the rules for creating valid XHTML documents Apply a.
Creating a Well-Formed Valid Document. 2 Objectives Introducing XHTML Creating a Well-Formed Document Creating a Valid Document Creating an XHTML Document.
Declare A DTD File. Declare A DTD Inline File For example, use DTD to restrict the value of an XML document to contain only character data.
Sistemi basati su conoscenza XML Prof. M.T. PAZIENZA a.a
XML Technologies XML Basics  What is XML?  Why use XML?  How to write XML? 1XML Technologies David Raponi.
XML Verification Well-formed XML document  conforms to basic XML syntax  contains only built-in character entities Validated XML document  conforms.
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
Introduction to XML This material is based heavily on the tutorial by the same name at
XP New Perspectives on XML Tutorial 3 1 DTD Tutorial – Carey ISBN
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
XP Tutorial 9New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
XP The University of Akron Summit College Business Technology Department Computer Information Systems 2440: 140 Internet Tools Instructor: Enoch E. Damson.
Copyright © 2003 Pearson Education, Inc. Slide 3-1 Created by Cheryl M. Hughes, Harvard University Extension School — Cambridge, MA The Web Wizard’s Guide.
XML CPSC 315 – Programming Studio Fall 2008 Project 3, Lecture 1.
Document Type Definitions Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XML - DTD. The building blocks of XML documents Elements, Tags, Attributes, Entities, PCDATA, and CDATA.
1 herbert van de sompel CS 502 Computing Methods for Digital Libraries Cornell University – Computer Science Herbert Van de Sompel
Web page - A Web page is a simple text file that contains a set of HTML tags (code) that describe (to the browser) what should go on a web page. It may.
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
August Chapter 2 - Markup and Core Concepts Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
XML Syntax - Writing XML and Designing DTD's
XHTML. Introduction to XHTML What Is XHTML? – XHTML stands for EXtensible HyperText Markup Language – XHTML is almost identical to HTML 4.01 – XHTML is.
XP 1 DECLARING A DTD A DTD can be used to: –Ensure all required elements are present in the document –Prevent undefined elements from being used –Enforce.
FIGIS’ML Hands-on training - © FAO/FIGIS An introduction to XML Objectives : –what is XML? –XML and HTML –XML documents structure well-formedness.
1 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.
XML A web enabled data description language 4/22/2001 By Mark Lawson & Edward Ryan L’Herault.
1 Chapter 10: XML What is XML What is XML Basic Components of XML Basic Components of XML XPath XPath XQuery XQuery.
XP Tutorial 9 1 Working with XHTML. XP SGML 2 Standard Generalized Markup Language (SGML) A standard for specifying markup languages. Large, complex standard.
Copyrighted material John Tullis 10/17/2015 page 1 04/15/00 XML Part 3 John Tullis DePaul Instructor
XML - DTD Week 4 Anthony Borquez. What can XML do? provides an application independent way of sharing data. independent groups of people can agree to.
CIS 451: XML DTDs Dr. Ralph D. Westfall February, 2009.
Waqas Anwar Next SlidePrevious Slide. Waqas Anwar Next SlidePrevious Slide XML XML stands for EXtensible Markup Language.
XML Documents Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University Elements Attributes Comments PI Document.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
1 Introduction to XML XML stands for Extensible Markup Language. Because it is extensible, XML has been used to create a wide variety of different markup.
An Introduction to XML Sandeep Bhattaram
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Understanding How XML Works Ellen Pearlman Eileen Mullin Programming the.
XML Introduction. What is XML? XML stands for eXtensible Markup Language XML stands for eXtensible Markup Language XML is a markup language much like.
1 Dr Alexiei Dingli XML Technologies DTD. 2 Document Type Definition Defines –the legal building blocks of an XML document –the document structure –The.
What it is and how it works
The Official 2002 XML Marathon April 4, Revised Requirements A photocopy of the original text A short description (read: single paragraph) discussing.
Introduction to XML February 07, From HTML to XML As mentioned in previous classes, if you know HTML, then you already know XML… really! In this.
INFSY 547: WEB-Based Technologies Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
CIS 375—Web App Dev II DTD. 2 Introduction to DTD DTD stands for ______________________. The purpose of a DTD is to define the legal building blocks of.
XML Document Type Definitions and the Document object model.
Introduction to DTD A Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines the document structure with a list.
XML DTD. XML Validation XML with correct syntax is "Well Formed" XML. XML validated against a DTD is "Valid" XML.
XP Tutorial 9New Perspectives on HTML and XHTML, Comprehensive 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
Objective: To describe the evolution of the Internet and the Web. Explain the need for web standards. Describe universal design. Identify benefits of accessible.
DTD Document Type Definition. Agenda Introduction to DTD DTD Building Blocks DTD Elements DTD Attributes DTD Entities DTD Exercises DTD Q&A.
Tutorial 9 Working with XHTML. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Describe the history and theory of XHTML.
Tutorial 9 Working with XHTML. XP Objectives Describe the history and theory of XHTML Understand the rules for creating valid XHTML documents Apply a.
Copyrighted material John Tullis 3/18/2016 page 1 04/29/00 XML Part 4 John Tullis DePaul Instructor
XML Introduction to XML Extensible Markup Language.
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
Extensible Markup Language (XML) Pat Morin COMP 2405.
XML intro. What is XML? XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display.
XML BASICS and more…. What is XML? In common:  XML is a standard, simple, self-describing way of encoding both text and data so that content can be processed.
XML Technologies DTD.
CSCE 315 – Programming Studio Spring 2013
Presentation transcript:

Review Writing XML  Style  Common errors 1XML Technologies David Raponi

2 Week 1 Review: 1. Style 1. Style issues Be consistent: The Title The description (same for camelCasing vs under_scores)

3XML Technologies David Raponi Week 1 Review: 1. Style 2. Common errors Be sure to group related items The book Another book The book Another book

4XML Technologies David Raponi Week 1 Review: 1. Style 2. Common errors Avoid repeated names. Examine the following:  Something that holds text  Something that holds more elements Eek! We’re using “name” to define two different structural things.

5XML Technologies David Raponi Week 1 Review: 1. Style 2. Common errors No need to increment elements! Hey! What’s the name of that book2 you’re reading? (That doesn’t make sense.) Tag names should be thought of as pure nouns. In this case, just, forget the numbers.

XML Technologies Week 2: Document Type Definitions (DTD)  What is a DTD?  How to write a DTD? 6XML Technologies David Raponi

7 Week 2: DTDs > 1. What is a DTD? 1. What is a DTD? Recall: XML is a language that can make new markup languages This involves two steps: 1.Creating own tags and structure (last week) 2.Defining that structure (DTDs, this week)

8XML Technologies David Raponi Week 2: DTDs > 1. What is a DTD? Define the blocks W3C: “The purpose of a DTD is to define the legal building blocks of an XML document.” A successful check of an XML file against a DTD makes it “valid” for that DTD (not just well-formed) Note: It still doesn’t DO anything  Sorry. … so why bother?

9XML Technologies David Raponi Week 2: DTDs > 1. What is a DTD? So why bother? Tons of data being passed around Tons of keeners coming up with their own way to manipulate the data The Apocalypse + =

10XML Technologies David Raponi Week 2: DTDs > 1. What is a DTD? Standards: ensuring predictability With a DTD, you: restrict the data content and how that content is organized This is important because if several people are passing along updated versions of an XML file, and each is trying to be clever by adding/changing things, then the file is no longer “predictable”, which would make future processing of that XML file cumbersome.  The more predictable the structure of an XML file, the easier it is to work with it

11XML Technologies David Raponi Week 2: DTDs > 1. What is a DTD? HTML goes XHTML Compare: Q: What are some differences?

12XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? 2. How to write a DTD? To write a DTD, ask yourself these questions: What elements are there? How many times are those elements allowed to appear? What is inside those elements What attributes are there?

13XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? Declaring an element Empty elements (like hr and br tags) Parsed Character Data (your text) Any Data Elements with subelements

14XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? Declaring a subelement’s recurrence How many times does the subelement appear?  Once  (do nothing, default)  Once or more  elem+  Zero or more  elem*  Zero or once  elem?  Either / or  (elem1|elem2)

15XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? Declaring a subelement’s recurrence Recurrence examples: *gnatho-what?! Dude, it’s any animal that has a jaw. Doesn’t everyone know that?

16XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? Declaring an attribute Type: CDATA (attribute values are not parsed) Enumerated (this|that|another) – specific values Value: #REQUIRED (must be present, and can’t be “ “) #IMPLIED (attr may/may not be there) #FIXED “value” (attr must always have this value) “value” (sets a default, but it can be changed)

17XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? Declaring an attribute Enumeration Examples: CDATA Examples:

18XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? Declaring an attribute: special note! Spaces Recall: Spaces are NOT allowed in tag names Recall: Spaces ARE allowed in attribute values BUT: not allowed in DTD enumerated values!  Ex: (this is bad) In other words: You can have well-formed XML docs with spaces in attributes, but it may not validate with a DTD. In general: Avoid spaces in attributes! Instead, use _, -, or if you need to.

19XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? Putting it together (program_v1.xml) Please open up program_v1.xml and look at it as we go through these slides…

20XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? Putting it together (program_v1.xml) <!DOCTYPE program [ …(other elements to follow) ]> Begin with a doctype declaration: 

21XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? DTD for program_v1.xml <!DOCTYPE program [ ]> Now list the next element (don’t forget the root itself!) and any sub elements it may contain 

22XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? DTD for program_v1.xml <!DOCTYPE program [ ]> Add recurrences: (how many times the subelements appear):

23XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? DTD for program_v1.xml To move on, state the contents of the elements in the order you listed them. The contents are one of three options: Text Another element (the cycle continues) Both (a “mixed element”)

24XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? DTD for program_v1.xml <!DOCTYPE program [ ]> Updated:

25XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? DTD for program_v1.xml Now keep cycling through until the elements are all accounted for: <!DOCTYPE program [ ]> Updated:

26XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? DTD for program_v1.xml Then finish up with attributes: <!DOCTYPE program [ ]> Updated:

27XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? To sum up: Doctypes are (basically) written as follows: 1.Wrap everything in the <!DOCTYPE… 2.Then list the elements with recurrences 3.List what’s inside those elements Text More elements? 4.Repeat steps 2 and 3 until all elements are accounted for 5.Declare attributes

28XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? Attaching a DTD to an XML file Internal Just place the whole DTD right after your declaration External Remove the initial <!DOCTYPE declaration Save your DTD as a.dtd file Add the following to your.xml file

29XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? Other notes CAPITALIZATION Note that <!ELEMENT and <!ATTLIST must be in CAPS Indenting The convention is to NOT indent your DTD items

30XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? Other notes CDATA Character Data (XML engine will NOT parse the info) because the value is just text (no markup) and so it simply spits it out to screen #PCDATA Parsed Character Data (XML engine will try to interpret the contents before spitting it out) to check if there’s actually another node or special characters.  What you need to know: CDATA for attributes, #PCDATA for elements with just text

31XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? Other notes Mixed Data Some text More text If you do this, let me know so I can come over and yell at you. But if you MUST, then you’d declare it like so: … or …

32XML Technologies David Raponi Week 2: DTDs > 2. How to write a DTD? Other notes XML docs are made to follow DTDs, NOT the other way around: <!DOCTYPE band [ ]> Q: Why is this technically correct, but conceptually wrong?