Quick and Dirty XML Intro P. Conrad for CISC474 4/19/2005 Not intended to be a complete introduction; This is just to "get you started". Sources: [1] Schaum's.

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

HTML popo.
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Website Design.
Cascading Style Sheets
1 Web Data Management XML Schema. 2 In this lecture XML Schemas Elements v. Types Regular expressions Expressive power Resources W3C Draft:
XSL XSLT and XPath 11-Apr-17.
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
Copyright © 2004 ProsoftTraining, All Rights Reserved. Lesson 3: XHTML Coding © 2007 Prosoft Learning Corporation All rights reserved ITD 110 Web Page.
ICS-FORTH 1 May 22, 2001 Christos Georgis The extensible markup language: An introduction to XML What is a XML document ? How do we check its validity.
3 November 2008CIS 340 # 1 Topics To define XML as a technology To place XML in the context of system architectures.
Cascading Style Sheets. Slide 2 Lecture Overview Overview of Cascading Style Sheets (CSS) Ways to declare a CSS CSS formatting capabilities New features.
CS 898N – Advanced World Wide Web Technologies Lecture 21: XML Chin-Chih Chang
Unit 2, cont. September 14 HTML,Validating your pages, Publishing your site.
XML Simple Types CSPP51038 shortcourse. Simple Types Recall that simple types are composed of text-only values. All attributes are of simple type Elements.
XML Schemas and Namespaces Lecture 11, 07/10/02. BookStore.dtd.
Tutorial 11 Creating XML Document
More HTML Chapter 4. 2 Nesting Tags How do you write the following in HTML? The wrong way: This is really, REALLY fun ! Tags must be correctly nested.
Introduction to XML Extensible Markup Language
Computer Sciences Department
XML – Extensible Markup Language Sivakumar Kuttuva & Janusz Zalewski.
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
Headings, Paragraphs, Formatting, Links, Head, CSS, Images
XML introduction to Ahmed I. Deeb Dr. Anwar Mousa  presenter  instructor University Of Palestine-2009.
Cascading Style Sheets (CSS) 1.  What is CSS?  Why CSS?  How to write a CSS? 2.
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
Today’s objectives  Complete web page  Using xhtml & CSS  Adding CSS to documents Embed url(File);  CSS.
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
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.
XML Open Computing Institute, Inc. 1 eXtensible Markup Language (XML)
IS432 Semi-Structured Data Lecture 5: XSLT Dr. Gamal Al-Shorbagy.
School of Computing and Management Sciences © Sheffield Hallam University To understand the Oracle XML notes you need to have an understanding of all these.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
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.
XHTML. Introduction to XHTML What Is XHTML? – XHTML stands for EXtensible HyperText Markup Language – XHTML is almost identical to HTML 4.01 – XHTML is.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Introduction to XML Extensible Markup Language. What is XML XML stands for eXtensible Markup Language. A markup language is used to provide information.
Intro. to XML & XML DB Bun Yue Professor, CS/CIS UHCL.
Cascading Style Sheets Orientation Learning Web Design: Chapter 11.
Tutorial 1: XML Creating an XML Document. 2 Introducing XML XML stands for Extensible Markup Language. A markup language specifies the structure and content.
XML TUTORIAL Portions from w3 schools By Dr. John Abraham.
Browsing MITA Seminar 2003 Mikko Pohja & Alessandro Cogliati.
1 Chapter 10: XML What is XML What is XML Basic Components of XML Basic Components of XML XPath XPath XQuery XQuery.
XML 2nd EDITION Tutorial 1 Creating An Xml Document.
HTML: Hyptertext Markup Language Doman’s Sections.
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.
XP 1 Creating an XML Document Developing an XML Document for the Jazz Warehouse XML Tutorial.
17 Apr 2002 XML Syntax: Documents Andy Clark. Basic Document Structure Element tags – Elements have associated attributes Text content Miscellaneous –
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.
1 Credits Prepared by: Rajendra P. Srivastava Ernst & Young Professor University of Kansas Sponsored by: Ernst & Young, LLP (August 2005) XBRL Module Part.
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.
XML Design Goals 1.XML must be easily usable over the Internet 2.XML must support a wide variety of applications 3.XML must be compatible with SGML 4.It.
1 Tutorial 11 Creating an XML Document Developing a Document for a Cooking Web Site.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
XML A Language Presentation. Outline 1. Introduction 2. XML 2.1 Background 2.2 Structure 2.3 Advantages 3. Related Technologies 3.1 DTD 3.2 Schemas and.
HTML A brief introduction HTML1. HTML, what is? HTML is a markup language for describing web documents (web pages). HTML stands for Hyper Text Markup.
XML Technology. Emerging Importance of XML –HTML-tagging is display oriented. –XML-based content tagging has important uses: data mining role-oriented.
WEEK -1 ACM 262 ACM 262 Course Notes. HTML What is HTML? HTML is a language for describing web pages. HTML stands for Hyper Text Markup Language HTML.
Agenda 1.WSDL & XML Schema Astronomicko-geofyzikálne observatórium, Modra An Order.
Basic HTML Document Structure. Slide 2 Goals (XHTML HTML5) XHTML Separate document structure and content from document formatting HTML 5 Create a formal.
Introduction to Programming the WWW I CMSC Summer 2003 Lecture 6.
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.
Cascading Style Sheets Part 1 1 IT 130 – Internet and the Web.
Extensible Markup Language (XML) Pat Morin COMP 2405.
Creating an XML Document
THE DATATYPES OF XML SCHEMA A Practical Introduction
Presentation transcript:

Quick and Dirty XML Intro P. Conrad for CISC474 4/19/2005 Not intended to be a complete introduction; This is just to "get you started". Sources: [1] Schaum's Easy Outlines: XML, Ed Tittel, McGraw-Hill, ($8.95 at Liebemann's). [2] [3] [4] For the data itself: Google searches on "NASCAR Driver Numbers" and "New York Times Bestsellers" [5] For info on XPointer and XLink.

XML provides a way to structure data Jeff Gordon 24 Chevrolet DuPont Dale Earnhardt, Jr. 8 Chevrolet Budweiser NASCAR data Book Data The World Is Flat Thomas L. Friedman Farrar, Straus & Giroux Blink Malcolm Gladwell Little, Brown

The structure is application-specific; you develop it yourself Jeff Gordon 24 Chevrolet DuPont Dale Earnhardt, Jr. 8 Chevrolet Budweiser If you are programming a system for NASCAR drivers, you decide what the elements should be through your knowledge of NASCAR: Jeff Gordon A element: Chevrolet

Elements and attributes Attributes: name,value pairs inside the open tag rookie, position and positionLastWeek are attributes Kyle Busch 5 Chevrolet Kellogg's/Delphi Blink Malcolm Gladwell Little, Brown My Life So Far Jane Fonda Random House Elements: The book element include the opening tag, the closing tag, and everything in between The author element is nested inside the book element

You specify the proper nesting of elements in one of two ways: Jeff Gordon 24 Chevrolet DuPont <schema xmlns=" xmlns:nascar=" targetNamespace=" DTD (Document Type Definition) The old school way Syntax: cryptic, compact, limited A newer way Syntax: XML (familiar), verbose, powerful XML Schema

Validation of XML documents "Without a DTD or a schema, there is no way to validate a document. Validation means conformity to a schema or DTD". [1, p. 26]. ID IDREF CDATA NOTATION ENTITY ENTITITES DTD Types: Schema Types (for both elements and attributes) 3.2 Primitive datatypes string boolean decimal float double duration dateTime time date gYearMonth gYear gMonthDay gDay gMonth hexBinary base64Binary anyURI QName NOTATIONstringbooleandecimalfloatdoubledurationdateTimetimedategYearMonthgYeargMonthDaygDaygMonthhexBinarybase64BinaryanyURIQNameNOTATION 3.3 Derived datatypes normalizedString token language NMTOKEN NMTOKENS Name NCName ID IDREF IDREFS ENTITY ENTITIES integer nonPositiveInteger negativeInteger long int short byte nonNegativeInteger unsignedLong unsignedInt unsignedShort unsignedByte positiveIntegernormalizedStringtokenlanguageNMTOKENNMTOKENSNameNCNameIDIDREFIDREFSENTITYENTITIESintegernonPositiveIntegernegativeIntegerlongintshortbytenonNegativeIntegerunsignedLongunsignedIntunsignedShortunsignedBytepositiveInteger for elements:for attributes: #PCDATA (parsed character data)

XML Schema Types from ur-types: base of the type hierarchy What is "ur-type"? An abbreviation for "un-restricted"? I don't know, but my guess is it comes from the German word "ur-text", meaning the "original" text of a document.... built-in primitive types built-in derived types

Things you can do with an XML document Validate it against a DTD or Schema Format it for a browser using a Cascading Style Sheet (CSS) Parse it from Java (C++,Python,Perl, etc...) with the DOM or SAX APIs –DOM parses whole document into a tree, then lets you access it –SAX is event-based; it provides callbacks for a depth-first traversal Transform it into another format (e.g. HTML) using XSL/XSLT –often HTML is the target format, but could be LaTeX, MySQL commands, CSV, etc. Search it using XPath expressions –XPath is sort of a "query language" for XML –can be used to specify subset of elements that match some criteria Make links to subsets of content in the document using XPointer –XPointer provides a way of making a hyperlink to the subset of an XML document specified by an XPath expression. Use XLink to make hyperlinks with XLink –more sophisticated than can be made with regular HTML.

Preliminary notes on CSS "XML is content driven, not presentation driven." [1,p. 66] Cascading Style Sheets (CSS) provide rules for formatting style CSS version: –current version: –CSS3 is being worked on; drafts available at Jeff Gordon 24 Chevrolet DuPont CSS

Formatting XML with a CSS (part 1) (taken directly from XML fragment, with Processing Instruction (PI) added at top: Fredrick the Great meets Bach Johann Nikolaus Forkel One evening, just as he was getting his flute ready and his musicians were assembled, an officer brought him a list of the strangers who had arrived. To display like a document, for each element, declare it as either: inline-level (i.e., does not cause line breaks) block-level (i.e., causes line breaks). INSTRUMENT { display: inline } ARTICLE, HEADLINE, AUTHOR, PARA { display: block } Put both files in same directory, view with a XML/CSS aware browser bach.css article1.xml Warning: possible typo? See later slide

Formatting XML with a CSS (part 2) (taken directly from Same XML fragment, but specify a different CSS: Fredrick the Great meets Bach Johann Nikolaus Forkel One evening, just as he was getting his flute ready and his musicians were assembled, an officer brought him a list of the strangers who had arrived. headline font size larger than then rest of the text display the author's name in italic: INSTRUMENT { display: inline } ARTICLE, HEADLINE, AUTHOR, PARA { display: block } HEADLINE { font-size: 1.3em } AUTHOR { font-style: italic } ARTICLE, HEADLINE, AUTHOR, PARA { margin: 0.5em } bach2.css article1.xml Warning: possible typo? See next slide

An annoying mystery... An annoying mystery: – is the official place to go for Web Standardswww.w3c.org –I copied this XML Processing instruction directly from their own tutorial: –It works fine in IE, but refuses to work in Firefox. What's up with that, I think? Is Firefox broken? Could IE be "better"? Say it isn't so!!! Further investigation reveals: –Firefox claims to adhere "strictly" to w3c.org standards. Their story: If something works in IE or other browsers, but not in Firefox, then the other browser is permissive, while Firefox is strictly interpreting the standard. –I looked at other examples on the web, and found the following syntax in many: Note hyphen instead of colon: <?xml-stylesheet type="text/css"... –Firefox uses the MIME type set by the server rather than the file extension to determine how to present content (which is more in keeping with the standard.) The Web server is the one that sets the MIME type in the HTTP response If you can't configure the server directly, an.htaccess file might help (see next slide). Typo? or alternative syntax?

Note the use of Unix command to show hidden files: ls -al Example.htaccess file for setting MIME types > ls -al total 120 drwxr-xr-x 2 pconrad Apr 19 12:02. drwxr-xr-x 3 pconrad Apr 17 13:34.. -rw-r--r-- 1 pconrad Apr 18 20:06.foo -rw-r--r-- 1 pconrad Apr 18 19:58.htaccess... > more.htaccess # CSS AddType text/css.css # XHTML AddType application/xhtml+xml.xhtml # XML AddType text/xml.xml # SVG AddType image/svg+xml.svg.svgz AddEncoding x-gzip.svgz # HTML # Server Side Includes (SSI) AddType text/html.shtml # Active Server Pages AddType text/html.asp... Compare: Firefox: "Tools/Page Info" IE: " File/Properties" On strauss, without a.htaccess file, IE worked, but Firefox did not. Firefox claims to be more "correct" in this behavior, i.e. working from MIME type in HTTP response header, not the file extension.

Let's try it with our Drivers file A few practical things I ran into: –I put both files in the same directory on my web site. –I had to put a top-level element called " " around my list of " ". The browsers didn't like it if there was more than one top-level element in the document. –On strauss, I had to include a.htaccess file to set the MIME types to get Firefox to work. driver, name, number, sponsor, make { display: block; } driver { margin: 0.5em; } name { font-weight: bold; color: red; } make { font-style: italic; } sponsor { color: green; } Jeff Gordon 24 Chevrolet DuPont Dale Earnhardt, Jr. 8 Chevrolet Budweiser drivers.css drivers.xml

Homework assignment H04 Using the same product you used for your H02 and H03, and following the example of the NASCAR drivers file in these slides, create an XML file called prod.xml. –Your prod.xml file should embed at least four elements inside each element (e.g. four elements for each NASCAR driver). Create a prod.css file so that your product is formatted in some interesting way. Use fonts, colors, and margins. Create a directory on strauss called ~userid/public_html/cisc474/H04 and place your prod.xml and prod.css file in this directory. Include also an.htaccess file so that this file can seen with formatting from both IE and Firefox.