95-733 Internet Technologies 1 Lecture 1 Introduction.

Slides:



Advertisements
Similar presentations
J0 1 Marco Ronchetti - Web architectures – Laurea Specialistica in Informatica – Università di Trento Java XML parsing.
Advertisements

XML & Data Structures for the Internet Yingcai Xiao.
The Semantic Web. The Web Today Designed for Human to read Cannot express meaning Architecture: URL –Decentralized: Link structure Language: html.
SDPL 2002Notes 3: XML Processor Interfaces1 3.3 JAXP: Java API for XML Processing n How can applications use XML processors? –A Java-based answer: through.
SDPL 2003Notes 3: XML Processor Interfaces1 3.3 JAXP: Java API for XML Processing n How can applications use XML processors? –A Java-based answer: through.
Internet Technologies1 XML Messaging A PowerWarning application using servlets and SAX The PowerWarning Application is from “XML and Java” by Maruyama,
Summer A-2000, Project Course-- Carnegie Mellon University 1 Financial Engineering Project Course.
Writing Enterprise Applications with J2EE (Sixth lesson) Alessio Bechini June 2002 (based on material by Monica Pawlan)
1 The Simple API for XML (SAX) Part I ©Copyright These slides are based on material from the upcoming book, “XML and Bioinformatics” (Springer-
JSP Tag Extensions And Java Bean. JSP Tag Extensions Tag extensions look like HTML (or rather, XML) tags embedded in a JSP page. They have a special meaning.
Week 5 Basic SAX Example From Chapter 5 of XML and Java Working with XML SAX Filters as described in Chapter 5.
Summer A-2000, Project Course-- Carnegie Mellon University 1 Financial Engineering Project Course.
F DIGITAL MEDIA: COMMUNICATION AND DESIGN INTRODUCTION TO XML AND XHTML.
Implementation of One Stop Search by XSLT By Dave Low University of Hong Kong 9-Dec-2003.
Internet Technologies1 More XML Schema The main source for these slides is “The XML Companion” by Bradley Other resources:
CS 898N – Advanced World Wide Web Technologies Lecture 22: Applying XML Chin-Chih Chang
Introduction to XML Extensible Markup Language
Introducing XHTML: Module B: HTML to XHTML. Goals Understand how XHTML evolved as a language for Web delivery Understand the importance of DTDs Understand.
Technical Track Session XML Techie Tools Tim Bornholt.
Chapter 24 XML. CHAPTER GOALS Understanding XML elements and attributes Understanding the concept of an XML parser Being able to read and write XML documents.
Xpath Sources:
Sheet 1XML Technology in E-Commerce 2001Lecture 4 XML Technology in E-Commerce Lecture 4 Case Study: XmlMessenger.
CSE 6331 © Leonidas Fegaras XML Tools1 XML Tools Leonidas Fegaras.
17 Apr 2002 XML Programming: JAXP Andy Clark. Java API for XML Processing Standard Java API for loading, creating, accessing, and transforming XML documents.
Java Programming Robert Chatley William Lee
XP The University of Akron Summit College Business Technology Department Computer Information Systems 2440: 140 Internet Tools Instructor: Enoch E. Damson.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
1 XML at a neighborhood university near you Innovation 2005 September 16, 2005 Kwok-Bun Yue University of Houston-Clear Lake.
CREATED BY ChanoknanChinnanon PanissaraUsanachote
XML for E-commerce III Helena Ahonen-Myka. In this part... n Transforming XML n Traversing XML n Web publishing frameworks.
Java WWW Week 10 Version 2.1 Mar 2008 Slide Java (JSP) and XML  Format of lecture: What is XML? A sample XML file… How to use.
Examples of Using Servlets and JSP Representation and Management of Data on the Internet.
SDPL 2004Notes 3: XML Processor Interfaces1 3.3 JAXP: Java API for XML Processing n How can applications use XML processors? –A Java-based answer: through.
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
Advanced Java Session 9 New York University School of Continuing and Professional Studies.
3/29/2001 O'Reilly Java Java API for XML Processing 1.1 What’s New Edwin Goei Engineer, Sun Microsystems.
1 Java and XML Modified from presentation by: Barry Burd Drew University Portions © 2002 Hungry Minds, Inc.
Introduction to XML Extensible Markup Language. What is XML XML stands for eXtensible Markup Language. A markup language is used to provide information.
SDPLNotes 3.3: DOM Examples1 3.3 DOM Examples 1. DOM processing in a Web browser –a toy "XML database browser" –with JavaScript and MS Internet Explorer.
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
XML Processing in Java. Required tools Sun JDK 1.4, e.g.: JAXP (part of Java Web Services Developer Pack, already in Sun.
Java API for XML Processing (JAXP) Dr. Rebhi S. Baraka Advanced Topics in Information Technology (SICT 4310) Department of Computer.
WEB BASED DATA TRANSFORMATION USING XML, JAVA Group members: Darius Balarashti & Matt Smith.
Sheet 1XML Technology in E-Commerce 2001Lecture 3 XML Technology in E-Commerce Lecture 3 DOM and SAX.
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.
Internet Technologies Review Week 1 How does Jigsaw differ from EchoServer.java? What abstractions are made available to the servlet writer (under.
Document Object Model DOM. Agenda l Introduction to DOM l Java API for XML Parsing (JAXP) l Installation and setup l Steps for DOM parsing l Example –Representing.
Java and XML. What is XML XML stands for eXtensible Markup Language. A markup language is used to provide information about a document. Tags are added.
Schema Data Processing
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
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.
Unit 3 — Advanced Internet Technologies Lesson 11 — Introduction to XSL.
1 Introduction JAXP. Objectives  XML Parser  Parsing and Parsers  JAXP interfaces  Workshops 2.
Java Web 应用开发: J2EE 和 Tomcat 蔡 剑, Ph.D.. 本讲内容 Web 层技术 (III) Custom Tags JSP and XML JSTL.
XP Tutorial 9New Perspectives on HTML and XHTML, Comprehensive 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
Tutorial 9 Working with XHTML. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Describe the history and theory of XHTML.
7-Mar-16 Simple API XML.  SAX and DOM are standards for XML parsers-- program APIs to read and interpret XML files  DOM is a W3C standard  SAX is an.
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
1 Introduction SAX. Objectives 2  Simple API for XML  Parsing an XML Document  Parsing Contents  Parsing Attributes  Processing Instructions  Skipped.
Java API for XML Processing
Week-9 (Lecture-1) XML DTD (Data Type Document): An XML document with correct syntax is called "Well Formed". An XML document validated against a DTD is.
1 Introduction to XML Babak Esfandiari. 2 What is XML? introduced by W3C in 98 Stands for eXtensible Markup Language it is more general than HTML, but.
Unit 4 Representing Web Data: XML
Using XML Tools CS551 – Fall 2001.
Java/XML.
Database Processing with XML
Chapter 7 Representing Web Data: XML
Jagdish Gangolly State University of New York at Albany
XML document processing in Java using XPath and XSLT
Presentation transcript:

Internet Technologies 1 Lecture 1 Introduction

Internet Technologies 2 Course Web Site

Internet Technologies 3 Course TA TBA

Internet Technologies 4 Structure of the Course Lectures / class participation Homeworks (programming) Final exam

Internet Technologies 5 Readings The required text is “XML and Java” Second edition Addison-Wesley Readings will be assigned each week. Readings from the web will also be assigned.

Internet Technologies 6 Grading Homework(3-4) 60% Final Exam 40%

Internet Technologies 7 Selected Course Topics DTD’s XSDL and JAXB XSLT XPath, Xlink Java Server Faces XML Encryption and XML Digital Signature RDF and RDFS OWL

Internet Technologies 8 Introduction XML and Java Chapter 1 Web Applications, XML, and Java

Internet Technologies 9 Introduction In this course we will be concerned with B2B applications. We will study how applications can send, receive, verify and manipulate XML documents. Definition: By Web Application we mean a distributed application based on Web technologies: HTTP, HTML, and the family of XML technologies.

10 Introduction Definition: By traditional three-tier application we mean applications consisting of: First tier – Browsers that act as a human interface Second tier – a program running in a web server Third tier – backend systems that provide databases and transaction services Let’s replace the browser with a program…

Internet Technologies 11 From web for eyeballs to web for programs Consider a PowerWarning application allows users To register their geographical position and their temperature concerns. Users will receive when the temperature exceeds the user specified parameters.

Internet Technologies 12 [1] [2] [3] Weather Report [4] [5] [6] Weather Report -- White Plains, NY [7] [8] Date/Time 11 AM EDT Sat Jul [9] Current Tem. 70° [10] Today’s High 82° [11] Today’s Low 62° [12] [13] [14] Suppose that we know that the weather information is available from the web at

Internet Technologies 13 Strategy 1: For the current temperature of White Plains, go to line 9, column 46 of the page and continue until reaching the next ampersand. Strategy 2: For the current temperature of the White Plains, go to the first tag, then go to the second tag within the table, and then go to the second tag within the row. Neither of these seems very appealing…

Internet Technologies 14 <!DOCTYPE WeatherReport SYSTEM “http>// White Plains NY Sat Jul AM EDT XML would help

Internet Technologies 15 Strategy 3: For the current temperature of White Plains, N.Y., go to the tag.

16 XML Mobile users PC users WeatherReport application WML HTML PowerWarning application Application programs XML notifications Registrations XML XSLT

Internet Technologies 17 XML Extensible Markup Language (really a meta- language) Generic syntax (not like HTML) Simple, human-readable tags From Web for eyeballs to Web for programs Tools exist that allows us to easily process any type of XML document

Internet Technologies 18 Introduction XML and Java Chapter 2 Basics of Parsing Documents

Internet Technologies 19 Department.xml John Doe Bob Smith

Internet Technologies 20 Alice Miller

21 SimpleParse.java // Download Xerces from // Two Jar files are needed- xercesImpl.jar and xmlParserAPIs.jar // add these to the classpath /** * From XML and Java Chapter 2 SimpleParse.java **/ import org.w3c.dom.Document; import org.apache.xerces.parsers.DOMParser; import org.xml.sax.SAXException; import java.io.IOException;

Internet Technologies 22 public class SimpleParse { public static void main(String[] argv) { if (argv.length != 1) { System.err.println( "Usage: java SimpleParse "); System.exit(1); } try { // Creates a parser object DOMParser parser = new DOMParser(); // Parses an XML Document parser.parse(argv[0]); // Gets a Document object Document doc = parser.getDocument();

Internet Technologies 23 } catch (SAXException se) { System.out.println("Parser error found: " +se.getMessage()); System.exit(1); } catch (IOException ioe) { System.out.println("IO error found: " + ioe.getMessage()); System.exit(1); } D:\McCarthy\www\95-733\examples\chap02>java SimpleParse department.xml D:\McCarthy\www\95-733\examples\chap02>

Internet Technologies 24 Let’s Introduce an Error John Doe Bob Smith This code is OK.

Internet Technologies 25 Alice Miller Missing closing tag on name. The document is not well-formed.

Internet Technologies 26 D:\McCarthy\www\95-733\examples\chap02>java SimpleParse department.xml [Fatal Error] department.xml:16:5: The element type "name" must be terminated by the matching end-tag " ". Parser error found: The element type "name" must be terminated by the matching e nd-tag " ". After displaying the error status an exception was throw to the application

Internet Technologies 27 Simple Validation

Internet Technologies 28 department-dtd.xml John Doe Bob Smith

Internet Technologies 29 Alice Miller

Internet Technologies 30 department.dtd

Internet Technologies 31 SimpleParseWithValidation.java /** * SimpleParseWithValidation.java **/ import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.ErrorHandler; import org.apache.xerces.parsers.DOMParser; import java.io.IOException;

Internet Technologies 32 public class SimpleParseWithValidation { public static void main(String[] argv) { if (argv.length != 1) { System.err.println("Usage: java "+ "SimpleParseWigthValidation "); System.exit(1); } try { // Creates parser object DOMParser parser = new DOMParser(); // Sets an ErrorHandler parser.setErrorHandler(new MyErrorHandler());

Internet Technologies 33 // Tells the parser to validate documents parser.setFeature( " true); // Parses an XML Document parser.parse(argv[0]); // Gets a Document object Document doc = parser.getDocument(); // Does something } catch (Exception e) { e.printStackTrace(); }

Internet Technologies 34 MyHandler.java import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; public class MyErrorHandler implements ErrorHandler { /** Constructor. */ public MyErrorHandler(){ }

35 /** Warning. */ public void warning(SAXParseException ex) { System.err.println("[Warning] "+ getLocationString(ex)+": "+ ex.getMessage()); } /** Error. */ public void error(SAXParseException ex) { System.err.println("[Error] "+ getLocationString(ex)+": "+ ex.getMessage()); } /** Fatal error. */ public void fatalError(SAXParseException ex) { System.err.println("[Fatal Error] "+ getLocationString(ex)+": "+ ex.getMessage()); }

36 /** Returns a string of the location. */ private String getLocationString(SAXParseException ex) { StringBuffer str = new StringBuffer(); String systemId = ex.getSystemId(); if (systemId != null) { int index = systemId.lastIndexOf('/'); if (index != -1) systemId = systemId.substring(index + 1); str.append(systemId); } str.append(':'); str.append(ex.getLineNumber()); str.append(':'); str.append(ex.getColumnNumber()); return str.toString(); } Get the file name after the /’s.

Internet Technologies 37 Runs without error D:\McCarthy\www\95-733\examples\chap02>java SimpleParseWithValidation department-dtd.xml D:\McCarthy\www\95-733\examples\chap02>

Internet Technologies 38 Using the same dtd…

39 Introduce an error John Doe Bob Smith

Internet Technologies 40 Alice Miller D:\McCarthy\www\95-733\examples\chap02>java SimpleParseWithValidation department-dtd2.xml [Error] department-dtd2.xml:4:13: Attribute "id" is required and must be specifi ed for element type "employee". The parser does not throw an exception.

41 Make a fatal error (not well- formed) John Doe Bob Smith id="A.M">

Internet Technologies 42 D:\McCarthy\www\95-733\examples\chap02>java SimpleParseWithValidation department-dtd2.xml [Error] department-dtd2.xml:10:39: Element type "someTag" must be declared. [Fatal Error] department-dtd2.xml:12:5: The element type "someTag" must be termi nated by the matching end-tag " ". org.xml.sax.SAXParseException: The element type "someTag" must be terminated by the matching end-tag " ". at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at SimpleParseWithValidation.main(SimpleParseWithValidation.java:31) An exception is thrown to the caller for this Fatal Error.

43 JAXP An API but really an abstraction layer Does not provide a new means of parsing XML Does not add to DOM, SAX or XSLT Does not provide new functionality in handling XML JAXP enables applications to parse and transform XML documents independent of a particular XML processing implementation. Just change a system variable or classpath setting and you change parsers. Six classes included in JDK1.4 in javax.xml.parsers package

44 SimpleParseJAXP.java /** * SimpleParseJAXP.java **/ import java.io.IOException; import org.w3c.dom.Document; import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; Note: no mention of xerces.

Internet Technologies 45 public class SimpleParseJAXP { public static void main(String[] argv) { if (argv.length != 1) { System.err.println( "Usage: java SimpleParseJAXP "); System.exit(1); } try { // Creates document builder factory DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); // Tells the parser to validate documents factory.setValidating(true);

46 // Tells the parser to be aware namespaces factory.setNamespaceAware(true); // Creates builder object DocumentBuilder builder = factory.newDocumentBuilder(); // Sets an ErrorHandler builder.setErrorHandler(new MyErrorHandler()); // Parses the document Document doc = builder.parse(argv[0]); } catch (ParserConfigurationException pe) { pe.printStackTrace(); } catch (SAXException se) { se.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); }

Internet Technologies 47 Suppose we want Xerces to be our parser D:\McCarthy\www\95-733\examples\chap02>java -Djavax.xml.parsers.DocumentBuilderFactory= org.apache.xerces.jaxp.DocumentBuilderFactoryImpl SimpleParseJAXP department-dtd.xml