Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to XML: Part I By Sandeep Jangity CS 157B, Section 2 Dr. Lee.

Similar presentations


Presentation on theme: "Introduction to XML: Part I By Sandeep Jangity CS 157B, Section 2 Dr. Lee."— Presentation transcript:

1 Introduction to XML: Part I By Sandeep Jangity CS 157B, Section 2 Dr. Lee

2 Overview What is XML? Why XML is popular? How to write a XML document? How to write XML DTD’s/Schemas?

3 What is XML? eXtensible Markup Language XML is a standard developed by the W3C XML is a syntax for expressing structured data in a text format XML is not a language on its own. Instead, XML is used to build markup languages. XML is like html per-se, but unlike html tags, XML tags convey meaning of the data inside their tags

4 Structured Data Structured data refers to data that is tagged for its content, meaning, or use Includes: spreadsheets, address books, databases, PDF documents, … Stored in binary or text format

5 XML Technology Model Data is modeled in XML The structure and constraints are modeled using DTD’s or Schemas The document format can be modeled using XSL (XML Style Sheets) REMEMBER: XML allows us to separate data from presentation!

6 Why use XML? Interoperability – XML is operating system, platform, language independent Separates content from presentation Well supported by most browsers Simple XML documents are human-readable and can be easily parsed by machines, as well. Easily converted to other formats. XML->PDF || Microsoft CHM etc., Can represent almost any kind of data –Many, many applications: Math/Science/etc., –(continued: next slide)

7 MyMathML 4 + (5 * 3) add 4 mult 5 3

8 MyChemML ChemML (tracking experiments) The compound under investigation is common water: It boils at 100 degrees and freezes at 0 degrees! For more information about this amazing compound see the March 2003 issue of: Water World (Now the technical stuff)

9 XML document syntax Root element Elements and attributes are case sensitive Elements must be correctly nested Attributes values must be in quotes Tags must be closed Spaces are not allowed in element and attribute names

10 XML Example John Doe Introduction to XML 12 June 2001 121232323 XYZ Foo Bar Introduction to XSL 12 June 2001 12323573 ABC

11 Well-formed vs Valid Syntax & Semantic checking Well-formed (syntax): –Properties: (1) every start tag has a matching end tag, and (2) elements are properly nested –an XML document might be “well-formed” without being “valid“, but a “valid” document is “well-formed” Valid (semantic): –A valid XML document conforms to the vocabulary constraints defined in a DTD or Schema

12 Well-Formed (cont’d) Well formed? Bill Sue Dinner tonight?

13 Definition and Validation Two ways to define the structure of an XML document –DTDs –Schemas Each set of rules specifies an XML vocabulary

14 What is a DTD? Document Type Definitions (DTD) –Emphasis on the structure of the XML, what elements and attributes can appear and their relationships –Difficult to work with –No support for data types –Not extensible

15 Bookstore Example John Doe Introduction to XML 12 June 2001 121232323 XYZ Foo Bar Introduction to XSL 12 June 2001 12323573 ABC

16 Problems with DTD’s It's not XML syntax You write your XML document using one syntax and the DTD using another syntax -> inconsistent, more work for the parsers. Limited set of primitive datatypes Desire a set of datatypes compatible with those found in databases –One of the main weaknesses of DTD is its lack of support for data types beyond character strings (PCDATA). Limited support for applying constraints. Can support only constraints like “+” (1 or more occurences), “?” (0 or 1 occurences), “*” (0 or more occurences), etc. No facility for providing constraints like those found in databases (enumerations, ranges, string length, etc.)

17 What are Schemas? Schemas –More complex than DTD’s –Specify structure –Support for precise data type constraints –Allows for user-defined data types (complex/simple types) –Enhanced datatypes (unlike PCDATA in DTD’s): Wider range of primitive data types, supporting those found in databases (string, boolean, decimal, integer, date, etc.) Can create your own datatypes (complexType) –Support namespaces for extensibility

18 Schema Example (next SLIDE) John Doe Introduction to XML 12 June 2001 121232323 XYZ Foo Bar Introduction to XSL 12 June 2001 12323573 ABC

19 < xsd:schema xmlns:xsd =“http://www.w3.org/2001/XMLSchema” targetNamespace="http://www.books.org" xmlns =“http://www.books.org”>

20 XML Namespaces: Code-reuse Namespaces –Identifies an XML vocabulary defined by a URI (Uniform Resource Identifier) –Allows reuse of XML markup –Resolves problems with recognition and collision of tags with similar names. Can happen if your combining elements from multiple documents. (see previous slide)

21 Cool XML Application: RSS XML.com http://www.xml.com/ XML.com features a rich mix of information and services for the XML community. en-us Normalizing XML, Part 2 http://www.xml.com/pub/a/2002/12/04/normalizing.html In this second and final look at applying relational normalization techniques to W3C XML Schema data modeling, Will Provost discusses when not to normalize, the scope of uniqueness and the fourth and fifth normal forms. The.NET Schema Object Model http://www.xml.com/pub/a/2002/12/04/som.html Priya Lakshminarayanan describes in detail the use of the.NET Schema Object Model for programmatic manipulation of W3C XML Schemas.

22 ?? Almost done …

23 TOools/Software XML Spy By far, the most comprehensive editor. Handles XML files, DTD’s, XSL files, as well as XSD (XML Schema). Unfortunately only a 30 day trial version. http://www.xmlspy.com/download.html XML Notepad Microsoft XML Notepad is a simple application for building and editing small sets of XML-based data. Freeware. http://msdn.microsoft.com/xml/notepad/download.asp XML Pro XML Pro is a top-notch XML editor but it doesn’t include as many features as XML Spy. Shareware. http://www.vervet.com/demo.html $$ You can also validate your XML files by just opening them with IE5.0 or above. It checks if the XML file is well-formed or not, and also validates against a DTD (if specified on the DOCTYPE declaration Great links: www.w3schools.com http://www.cs.sjsu.edu/faculty/pearce/web/front.htm

24 Conclusion You thought HTML was easy? XML just got easier!  Get XML certified before you graduate! Visit: http://www.whizlabs.com/articles/xml- article.html Questions skumarjang@hotmail.com


Download ppt "Introduction to XML: Part I By Sandeep Jangity CS 157B, Section 2 Dr. Lee."

Similar presentations


Ads by Google