Presentation is loading. Please wait.

Presentation is loading. Please wait.

CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:

Similar presentations


Presentation on theme: "CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:"— Presentation transcript:

1 CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Email Address: meyer@sci.brooklyn.cuny.edu Course Page: http://www.sci.brooklyn.cuny.edu/~meyer/ http://www.sci.brooklyn.cuny.edu/~meyer/ CISC3140-Meyer-lec7 1

2 Content Interoperability XML What XML is used for Tree Structure Syntax Rules Elements Naming Rules Attributes Document Type Definition (DTD) CISC3140-Meyer-lec7 2

3 The Death of Codd's Dream Different RDBMS are NOT compatible. ▫Codd's 12 (13) commandments (for RDBMS) where supposed to insure that all RDBMS would be able to for work with each other. ▫Today, no RDBMS implements all 13 rules. ▫Proprietary systems implement their own rules. ▫Proprietary systems implement their own SQL. And yet we need to share database information. Interoperability: A property referring to the ability of diverse systems to work together. CISC3140-Meyer-lec7 3

4 Markup Languages Markup languages allow us to add information to text, in a manner that is distinguishable from the text. Within a markup language we find 3 distinct types of markup. 1.Presentational markup: WYSIWYG effect. 2.Procedural markup: Including instruction. 3.Semantic markup: Used to attach meaning to sections of text. CISC3140-Meyer-lec7 4

5 XML XML is a markup language (like HTML, SGML, ODF). XML stands for eXtensible Markup Language and was initially released in the late 90's. The XML standard was created by W3C to provide an easy to use and standardized way to store self-describing data (self-describing data is data that describes both its content and its structure) XML is a very useful tool for allowing communication between otherwise incompatible database systems (in other words it provide interoperability). In XML you can define your own tags. CISC3140-Meyer-lec7 5

6 Key Terminology Tag: A markup construct that begins with " ". Tags come in three flavors: start-tags, for example, end-tags, for example, and empty-element tags, for example. Element: A component that begins with a start-tag and ends with a matching end-tag, or consists only of an empty-element tag. The characters between the start-and end-tags, if any, are the element's content, and may contain include other elements, which are called child elements. An example of an element is Hello, world.. Another is Attribute: A construct consisting of a name/value pair that exists within a start-tag or empty-element tag. In the example (below) the element x has two attributes, id and instock:. CISC3140-Meyer-lec7 6

7 Difference Between XML and (X)HTML XML and HTML were designed with different goals: XML was designed to transport and store data ▫Data-centric markup -> focus on data ▫XML allows the author to create his/her own tags (X)HTML was designed to display documents ▫Document-centric markup -> focus on document ▫Default tag set allows designer to focus on how text is presented (how it looks) CISC3140-Meyer-lec7 7

8 XML Example XML was created to structure, store, and transport information Everyday Italian Giada De Laurentiis 2005 30.00 The first line is the XML declaration; It defines the XML version (1.0) and an encoding to use (Latin-1/West European character set) The next line describes the root element of the document CISC3140-Meyer-lec7 8

9 XML Tree Structure XML documents form a logical tree-like structure that starts at "the root" and branches into "the leaves". XML documents must contain a root element. This root elements is "the parent" of all other elements. All elements can have sub elements (child elements) Elements with the same parent are siblings. CISC3140-Meyer-lec7 9

10 XML Tree Structure - Example CISC3140-Meyer-lec7 10

11 Rules for XML (all examples are WRONG) 1.XML elements must be properly nested ▫EX: This text is bold and italic 2.XML elements must always be closed ▫EX: This is a paragraph 3.XML elements are case sensitive ▫EX: Content of x 4.XML documents must have one root element CISC3140-Meyer-lec7 11

12 Rules for XML (cont) (all examples are CORRECT) 5.Attribute values must be quoted ▫Ex: 6.XML elements must be properly named: CAN contain letters, numbers, and other characters CANNOT start with a number or punctuation CANNOT start with the letters xml (XML, or Xml, etc) CANNOT cannot contain spaces CAN be any name you want (namespaces can be used to delimitate between identical names) CISC3140-Meyer-lec7 12

13 XML Attributes Attributes often provide information that is not a part of the data (meta-data). There are problems with using attributes: 1.Attributes cannot contain multiple values (elements can) 2.Attributes cannot contain tree structures (elements can) 3.Attributes are not easily expandable (for future changes) 4.Attributes are more difficult to read and maintain. Use elements for data. In general use attributes for information that is not part of the data itself (meta-data). CISC3140-Meyer-lec7 13

14 What do we use XML for? XML Simplifies Data Sharing ▫XML data is stored in plain text in a standardized format. This provides a software- and hardware- independent way of storing data. XML Simplifies Data Transport ▫Exchanging data as XML greatly reduces the complexity of exchanging data amongst different systems (SOAP, ODF). CISC3140-Meyer-lec7 14

15 What do we use XML for (cont)? XML Simplifies Platform Changes ▫Makes it easier to expand or upgrade to new operating systems, new applications, or new browsers, without losing data. XML Separates Data from HTML ▫Store data in separate XML files. This way you can concentrate on using HTML for layout and display, and be sure that changes in the underlying data will not require any changes to the HTML. CISC3140-Meyer-lec7 15

16 Problems with XML XML is profoundly wasteful in terms of storage space requirements: ▫Repeated tag names induce repeated “overhead” cost (2N +5)E where N denotes the average size of tag names in the document and E is the number of elements.. Working with XML is also costly, whether I move it in and out of a RDMS to query it, or I query it natively (XPATH, XSLT, Xquery). CISC3140-Meyer-lec7 16

17 Document Type Definitions (DTDs) The purpose of a DTD (Document Type Definition) is to define the legal building blocks of a particular XML document. If the DTD is declared inside the XML file, it should be wrapped in a DOCTYPE definition with the following syntax: CISC3140-Meyer-lec7 17

18 DTD In-File Declaration ]> Jack Jill Reminder Pick up some water! CISC3140-Meyer-lec7 18

19 DTD External-File Declaration If the DTD is declared in an external file, it should be wrapped in a DOCTYPE definition with the following syntax: Jack Jill Reminder Pick up some water! CISC3140-Meyer-lec7 19

20 Well-Formed VS. Valid XML An XML document that is “well-formed” is obeying all of the rules for XML. A "Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a DTD or XSD. W3C Schools has a “validator” tool that you can use to see if an XML document is valid for a particular DTD.“validator” tool CISC3140-Meyer-lec7 20

21 You got this… This lecture has been mostly about defining XML in terms of a data storage and transport mechanism. In your lab you will create some XML files with a DTD. See if you can get them to validate. Next week we will look at XML in terms of its use in data retrieval systems (rather than relational tables). XHTML is a valid subset of XML, and is used to create web-pages. Why would this be advantageous? CISC3140-Meyer-lec7 21

22 CISC3140-Meyer-lec7 Source http://www.w3schools.com/xml/default.asp 22


Download ppt "CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:"

Similar presentations


Ads by Google