Copyrighted material John Tullis 10/17/2015 page 1 04/15/00 XML Part 3 John Tullis DePaul Instructor

Slides:



Advertisements
Similar presentations
CSCI N241: Fundamentals of Web Design Copyright ©2004 Department of Computer & Information Science Introducing XHTML: Module B: HTML to XHTML.
Advertisements

HTML/XML XHTML Authoring. Creating Tables  Table: An arrangement of horizontal rows and vertical columns. The intersection of a row and a column is called.
1 DTD (Document Type Definition) Imposing Structure on XML Documents (W3Schools on DTDs)W3Schools on DTDs.
© De Montfort University, XML – a meta language Howell Istance and Peter Norris School of Computing De Montfort University.
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.
XML Study-Session: Part II Validating XML Documents.
176 Formal Languages and Applications: We know that Pascal programming language is defined in terms of a CFG. All the other programming languages are context-free.
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
Review Writing XML  Style  Common errors 1XML Technologies David Raponi.
 2002 Prentice Hall, Inc. All rights reserved. ISQA 407 XML/WML Winter 2002 Dr. Sergio Davalos.
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.
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.
5-1 Facilitating Business over the Internet: The XML language CR (2004) Prentice Hall, Inc. The xml goals The main objects of xml: Diagrams: Blocks and.
Introduction to XML This material is based heavily on the tutorial by the same name at
1 Advanced Topics XML and Databases. 2 XML u Overview u Structure of XML Data –XML Document Type Definition DTD –Namespaces –XML Schema u Query and Transformation.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Creating Document Type Definitions (DTDs) Ellen Pearlman Eileen Mullin.
Tutorial 3: Adding and Formatting Text. 2 Objectives Session 3.1 Type text into a page Copy text from a document and paste it into a page Check for spelling.
4/20/2017.
XP New Perspectives on XML Tutorial 4 1 XML Schema Tutorial – Carey ISBN Working with Namespaces and Schemas.
Tutorial 3: XML Creating a Valid XML Document. 2 Creating a Valid Document You validate documents to make certain necessary elements are never omitted.
XP New Perspectives on XML Tutorial 3 1 DTD Tutorial – Carey ISBN
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
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 New Perspectives on Microsoft Access 2002 Tutorial 51 Microsoft Access 2002 Tutorial 5 – Enhancing a Table’s Design, and Creating Advanced Queries and.
Why XML ? Problems with HTML HTML design - HTML is intended for presentation of information as Web pages. - HTML contains a fixed set of markup tags. This.
HTML II. Factors to consider in designing a website. Organizing your files. HTML Tables. Unordered Lists. Ordered Lists. HTML Forms. Learning Objectives.
Document Type Definitions Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
XML Syntax - Writing XML and Designing DTD's
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.
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 data.
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.
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.
New Perspectives on XML, 2nd Edition
Waqas Anwar Next SlidePrevious Slide. Waqas Anwar Next SlidePrevious Slide XML XML stands for EXtensible Markup Language.
XP 1 New Perspectives on XML Binding XML Data with Internet Explorer.
Introduction to XML This presentation covers introductory features of XML. What XML is and what it is not? What does it do? Put different related technologies.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
DATABASE MANAGEMENT SYSTEMS CMAM301. Introduction to database management systems  What is Database?  What is Database Systems?  Types of Database.
Jeff Ullman: Introduction to XML 1 XML Semistructured Data Extensible Markup Language Document Type Definitions.
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.
Semistructured Data Extensible Markup Language Document Type Definitions Zaki Malik November 04, 2008.
The Official 2002 XML Marathon April 4, Revised Requirements A photocopy of the original text A short description (read: single paragraph) discussing.
XML 2nd EDITION Tutorial 4 Working With Schemas. XP Schemas A schema is an XML document that defines the content and structure of one or more XML documents.
1 Tutorial 14 Validating Documents with Schemas Exploring the XML Schema Vocabulary.
Tutorial 13 Validating Documents with Schemas
1 Tutorial 12 Working with Namespaces Combining XML Vocabularies in a Compound Document.
XML Engr. Faisal ur Rehman CE-105T Spring Definition XML-EXTENSIBLE MARKUP LANGUAGE: provides a format for describing data. Facilitates the Precise.
INFSY 547: WEB-Based Technologies Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
When we create.rtf document apart from saving the actual info the tool saves additional info like start of a paragraph, bold, size of the font.. Etc. This.
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.
XP Tutorial 9New Perspectives on HTML and XHTML, Comprehensive 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
DTD Document Type Definition. Agenda Introduction to DTD DTD Building Blocks DTD Elements DTD Attributes DTD Entities DTD Exercises DTD Q&A.
Copyrighted material John Tullis 3/18/2016 page 1 04/29/00 XML Part 4 John Tullis DePaul Instructor
CITA 330 Section 2 DTD. Defining XML Dialects “Well-formedness” is the minimal requirement for an XML document; all XML parsers can check it Any useful.
XML Databases Presented By: Pardeep MT15042 Anurag Goel MT15006.
Extensible Markup Language (XML) Pat Morin COMP 2405.
Intro to PHP & Variables
Web Programming Maymester 2004
New Perspectives on XML
Using Templates and Library Items
DTD (Document Type Definition)
New Perspectives on XML
Presentation transcript:

Copyrighted material John Tullis 10/17/2015 page 1 04/15/00 XML Part 3 John Tullis DePaul Instructor

Copyrighted material John Tullis 10/17/2015 page 2 XML Part 3 Creating a DTD One of the main tasks in creating an XML application is writing a Document Type Definition (DTD). The DTD lets us define the different pieces of data we plan to model, along with the relationships between them. The ability to include this semantic information is the source of XML's power, and its main advantage over HTML.

Copyrighted material John Tullis 10/17/2015 page 3 XML Part 3 Creating a DTD Our first step will be to create a simple DTD that mirrors the structure of the database data source that we are concerned with. Lets use the Orders table as an example. There are some ideas we can state about the database: The table we're concerned with is called Orders. Each record in the orders table represents a complete order. For each order, there are seventeen fields, of which we shall use a subset for our example. Be aware that an actual order is stored in more than one table for reasons of database normalization.

Copyrighted material John Tullis 10/17/2015 page 4 XML Part 3 Specifying useful tags Lets create a useful tag set to start:

Copyrighted material John Tullis 10/17/2015 page 5 XML Part 3 Converting tags Now lets start converting the tags into XML DTD. Start with the document element ‘order’: Note that if the closing ‘>’ appeared as ‘+>’, it would mean that document element name ‘order’ could contain one or more content model ‘order_info’ tags. That is not appropriate here….but consider its use when handling the ‘items’ within an order (hint hint). The element declaration above specifies the name of the tag as ‘order’ and the content model for the tag as containing the ‘order_info’ tag.

Copyrighted material John Tullis 10/17/2015 page 6 XML Part 3 Occurrence indicators The previous slide listed a possible ‘+>’. This is known as an “occurrence indicator”. The possible occurrence indicators are: ‘?’ - the content must appear either once or not at all. ‘*’ - the content can occur one or more times, or not. ‘+’ - the content must appear at least once, or more often. No indicator - then the content must appear exactly as described. These indicators can be combined with parentheses in any order to create complex expressions. See online documentation for details.

Copyrighted material John Tullis 10/17/2015 page 7 XML Part 3 Elements We've already decided that for our first DTD, we'll simply describe the format of a subset of the orders table. That means we'll define a tag for each field in the row. Because rows are represented by the tag, we'll include all of the field tags: Notice that the definition of the order_info element doesn't use any occurrence indicators; this means that the elements must occur in exactly this order, and will occur only once.

Copyrighted material John Tullis 10/17/2015 page 8 XML Part 3 Elements Now that we've defined the tag that contains the data for each row in the orders table, we can start defining the individual tags. Each of these tags will look like this: ………. The #PCDATA keyword above means that the tag contains parsed character data; this means that the XML parser will find only character data, no tags or entity references (more about these in a minute). There are other keywords, such as EMPTY, which means the tag can't contain anything, and ANY, which means the tag can contain text, other tags, entity references, etc.

Copyrighted material John Tullis 10/17/2015 page 9 XML Part 3 A basic orders DTD (where’s the DOCTYPE?)

Copyrighted material John Tullis 10/17/2015 page 10 XML Part 3 Attribute declarations Attribute declarations allow you to define the attributes that can appear inside a tag, as well as the kinds of data the attributes can contain. One type of attribute declaration lets you specify a set of valid values along with a default value. Here the element store_name has the attribute Company which has a list of values, along with a default value.

Copyrighted material John Tullis 10/17/2015 page 11 XML Part 3 Attributes versus tags Attributes or tags? When should something exist as a tag versus when should it exist as an attribute? In most cases, the tags versus attributes decision doesn't make any difference. However, if the data we're modelling needs to be reused, data in tags is easier to access. As an example, say the information about a store that provides a catalog on a site that is returned by a database query needs to be used as input into another query. Finding and reusing a tag is much easier than finding and reusing the Company attribute of the tag.

Copyrighted material John Tullis 10/17/2015 page 12 XML Part 3 Entity declarations The last thing we'll add to our DTD is an entity declaration. Entities allow you to define symbols that are replaced by other text before they're displayed to the user. Here's an entity that defines the symbol &t1; as equivalent to the name ”Team One.” Markup such as: Site created by &t1;! will replace the entity name with its value. If you use an entity for a common word or phrase, such as a product name, you can change all occurrences of that word or phrase simply by changing the entity declaration.

Copyrighted material John Tullis 10/17/2015 page 13 XML Part 3 More about entities An entity is the fundamental building block in XML. Each entity consists of a name and a value. Every XML document contains a root or document entity. (Remember the slide a few slides back that said - where’s the DOCTYPE?) For example: <!DOCTYPE invoice [ <!ELEMENT invoice …… ….. ]>

Copyrighted material John Tullis 10/17/2015 page 14 XML Part 3 More about entities If you declare an entity more than once, the XML parser is supposed to accept only the 1st declaration and ignore the others. It may or may not warn you! An external entity has a declaration where the replacement data is not contained within the declaration, but is instead referenced. For example: Please do not do this for the assignments!!!!! It will work but then you will be sending me 2 files for each assignment, not 1.

Copyrighted material John Tullis 10/17/2015 page 15 XML Part 3 DTD Summary This presentation has covered the basics of creating a DTD. The most important part of this task is understanding the structure of our source data and the data relationships we want our XML tags to convey. As mentioned earlier, the XML tags we've created add semantic meaning and let us process our data in much more flexible ways. These benefits will be more apparent as we continue to develop our XML application.

Copyrighted material John Tullis 10/17/2015 page 16 XML Part 3 Assignments The 1st assignment is to create a purchase order based on the “paper” copy shown in the EDI presentation. The 2nd assignment is to create an invoice based on the “paper” copy shown in the EDI presentation. Please create the files in the form of: lastname_firstname_PO.xml and lastname_firstname_Invoice.xml The format should be.txt format, and I will inport into a parser such as XMLSpy. Send both files in an as an attachment. I will check for validity, wellformedness, and content.

Copyrighted material John Tullis 10/17/2015 page 17 XML Part 3 Assignments Note that you should be able to handle multiple line items for both the purchase order and the invoice. Note that it would be nice to handle multiple shipping address for each order (thus, a single order could have items sent to different loading docks in different warehouses in a factory complex, or to different factories.