Chapter 13 XML Concept of XML Simple Example of XML XML vs. HTML in Syntax XML Structure DTD and CDATA Sections Concept of SAX Processing Download and.

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

What is XML? a meta language that allows you to create and format your own document markups a method for putting structured data into a text file; these.
XML: Extensible Markup Language
XML and Enterprise Computing. What is XML? Stands for “Extensible Markup Language” –similar to SGML and HTML –document “tags” are used to define content.
XML 6.3 DTD 6. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:  Elements.
XML Unit 6 October 31. XML, review XML is used to markup data Used to describe information Uses tags like HTML –But all tags are user-defined –Must be.
3 November 2008CIS 340 # 1 Topics To define XML as a technology To place XML in the context of system architectures.
INF201 Fall2010 Intro. to Info. Technologies Department of Informatics University at Albany – SUNY Original Source: w3schools.com Prepared by Xiao Liang,
Document Type Definitions
Tutorial 11 Creating XML Document
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Document Type Definitions. XML and DTDs A DTD (Document Type Definition) describes the structure of one or more XML documents. Specifically, a DTD describes:
4/20/2017.
By: Shawn Li. OUTLINE XML Definition HTML vs. XML Advantage of XML Facts Utilization SAX Definition DOM Definition History Comparison between SAX and.
Chapter 9 Web Services Architecture and XML. Objectives By study in the chapter, you will be able to: Describe what is the goal of the Web services architecture.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
XML eXtensible Markup Language by Darrell Payne. Experience Logicon / Sterling Federal C, C++, JavaScript/Jscript, Shell Script, Perl XML Training XML.
CREATED BY ChanoknanChinnanon PanissaraUsanachote
Copyright © 2012 Accenture All Rights Reserved.Copyright © 2012 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are.
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
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.
Introduction to XML Eugenia Fernandez IUPUI. What is XML? From the World Wide Web Consortium (W3C) The Extensible Markup Language (XML) is the universal.
WORKING WITH XSLT AND XPATH
Extensible Markup and Beyond
XML What is XML? XML v.s. HTML XML Components Well-formed and Valid Document Type Definition (DTD) Extensible Style Language (XSL) SAX and DOM.
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
Introduction to XML Extensible Markup Language. What is XML XML stands for eXtensible Markup Language. A markup language is used to provide information.
 XML is designed to describe data and to focus on what data is. HTML is designed to display data and to focus on how data looks.  XML is created to structure,
Intro. to XML & XML DB Bun Yue Professor, CS/CIS UHCL.
Tutorial 1: XML Creating an XML Document. 2 Introducing XML XML stands for Extensible Markup Language. A markup language specifies the structure and content.
Electronic Commerce COMP3210 Session 4: Designing, Building and Evaluating e-Commerce Initiatives – Part II Dr. Paul Walcott Department of Computer Science,
Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display.
XML 2nd EDITION Tutorial 1 Creating An Xml Document.
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.
Chapter 10 Intro to SOAP and WSDL. Objectives By study in the chapter, you will be able to: Describe what is SOAP Exam the rules for creating a SOAP document.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
Accessing Data Using XML CHAPTER NINE Matakuliah: T0063 – Pemrograman Visual Tahun: 2009.
Web Technologies COMP6115 Session 4: Adding a Database to a Web Site Dr. Paul Walcott Department of Computer Science, Mathematics and Physics University.
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.
C# and Windows Programming XML Processing. 2 Contents Markup XML DTDs XML Parsers DOM.
XML Study-Session: Part III
CS 157B: Database Management Systems II February 11 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
Web Technologies Lecture 4 XML and XHTML. XML Extensible Markup Language Set of rules for encoding a document in a format readable – By humans, and –
1 Introduction JAXP. Objectives  XML Parser  Parsing and Parsers  JAXP interfaces  Workshops 2.
Martin Kruliš by Martin Kruliš (v1.1)1.
C Copyright © 2011, Oracle and/or its affiliates. All rights reserved. Introduction to XML Standards.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
CHAPTER NINE Accessing Data Using XML. McGraw Hill/Irwin ©2002 by The McGraw-Hill Companies, Inc. All rights reserved Introduction The eXtensible.
XP 1Creating Web Pages with XML Tutorial 1 New Perspectives on XML Tutorial 1 – Creating an XML Document.
XML Extensible Markup Language
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.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
I Copyright © 2004, Oracle. All rights reserved. Introduction.
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.
Extensible Markup Language (XML) Pat Morin COMP 2405.
XML BASICS and more…. What is XML? In common:  XML is a standard, simple, self-describing way of encoding both text and data so that content can be processed.
Chapter 13 XML Concept of XML Simple Example of XML
Unit 4 Representing Web Data: XML
Using XML Tools CS551 – Fall 2001.
XML in Web Technologies
Database Processing with XML
Chapter 7 Representing Web Data: XML
Creating an XML Document
Unit 6 - XML Transformations
Presentation transcript:

Chapter 13 XML Concept of XML Simple Example of XML XML vs. HTML in Syntax XML Structure DTD and CDATA Sections Concept of SAX Processing Download and Configure SAXP Pack Example of SAX Parser in Java with XML Concept of DOM Processing Building a DOM Tree from a XML File Concept of XSLT

Chapter 13 XML (continue) Examples of Stylesheets Concept of SOAP Examples of Using SOAP Servers with Messages SOAP API and SOAP Server Tomcat Configuring SOAP API and SOAP Server Tomcat Example of Using SOAP API with Tomcat In-Class Exercises and Lab Assignment

Concept of XML What is XML? - is eXtensible Markup Language - Easily modifying, changing, or adding data features due to its modular structure - is actually “meta-language” Why XML? - Simplify documents communication across different applications and languages - Customize data storage, arrangement, and organization - Easily validating, integrating, and error detecting within an application

Concept of XML(continue) - Data in stylesheet can be customized to any output desired - Any type of data can be expressed as an XML document. XML provides rules to describe data

Simple Example of XML Fairy Princess Scratch sound with emphasis on color, texture. 04/16/2002 is an empty tag without data -->

Simple Example of XML (continue) Execution result in Netscape 6.0: Fairy Princess Scratch sound with emphasis on color, texture. 04/16/2002 Execution result in Internet Explorer: - Fairy Princess Scratch sound with emphasis on color, texture. 04/16/2002

XML vs. HTML in syntax Every XML document must have one root element, i.e., ….. Tags are case-sensitive in XML, but not in HTML No whitespace is permitted at the beginning of a tag (i.e., is not allowed), however whitespace at the end of tag is allowed (i.e., is okay), but not a case in HTML The tag name must start with either a letter or an underscore, but user-defined tags are not allowed in HTML The tag names may contain any of following: letters, numerals, hyphens, periods, or underscores

XML vs. HTML in Syntax(continue) Each tag must have an end tag, the same as HTML: i.e, ……………., or just an empty tag as, which is incorrect in HTML Tags must be nested i.e., ….. ….. is incorrect, but is okay in HTML Attribute values must be enclosed in quotes i.e., date status=canceled is incorrect Comments use the same HTML syntax i.e.,

XML Structure Each XML file starts with an optional prolog:, or Each XML file must have one and only one root element Each XML file may have DTD section (Document Type Definition) or schemas section

DTD and CDATA Sections What is DTD? - Document Type Definition describes the structural requirements of an XML document - a DTD can define the following: The elements and attributes appeared in a file Which elements are child elements and what number, order, and placement they must have The default values for elements and attributes Why DTD? - Its is used to ensure that each XML document follows a specific document model, and thus is in the exact format required for whatever processing may come its way

DTD and CDATA Sections (continue) A DTD can be saved as a separate file with.dtd file extension and be referenced by the XML file A DTD can be completely included within the XML file Examples of DTD file - (p. 501) – author.dtd - (downloading file: Intro to XML and XSL) – shows.dtd DTD Generator (free download): type DTD Generator, XML in

DTD and CDATA Sections (continue) What are CDATA sections? - Are areas in which the parser doesn’t process the XML data Why CDATA sections? - is very useful when there is text in the XML file that needs to be passed through the parser unprocessed - to prevent the parser from reacting to offending characters in other languages

DTD and CDATA Sections (continue) An example of an element with a CDATA section: y && z y? ] ]> General form of CDATA:

Concept of SAX Processing What is SAX? - Simple API for XML in Java, now it’s called as JAXP (Java API for XML Processing) - Event-based model for accessing XML document contents Why SAX? - Different tags as events invoke different methods by the SAX parser sequentially from start to finish - This enables us to do something as a result of the event

Download and Configure SAXP pack Download free from the following Sun’s site: java.sun.com/xml/index.html The current new version is Java XML Pack - Summer 02 Update Release After download, unzip the pack into a separate directory, i.e, SAXP Set up the following environment parameter at DOS prompt: set SAXP_HOME=c:/SAXP/java_xml_pack- summer-02_01/jaxp-1.2_01

Example of SAX Parser in Java with XML A simple example without DTD (p. 504 –507) - steps: 1. Write a XML file (authorSimple.xml) 2. Write a Java program with SAX parser (Sax.java) 3. Compile the program as (one line command): javac –classpath.;%JAXP_HOME%\jaxp.jar; %JAXP_HOME% \crimson.jar Sax.java 4. Execute the program: java –classpath.;%JAXP_HOME%\jaxp.jar; %JAXP_HOME% \crimson.jar Sax authorSimple.xml false

Example of SAX Parser in Java with XML (continue) Execute the program with DTD: java –classpath.;%JAXP_HOME%\jaxp.jar; %JAXP_HOME% \crimson.jar Sax authorSimpleInternal.xml true You can execute those programs without type in the long-command if you are using JDK1.4.0 or later version, i.e.: –compile: javac Sax.java false –execution: java Sax authorSimpleInternal.xml true

Concept of DOM Processing What is DOM? - Stands for Document Object Model - Is a tree structure consisting of a hierarchy of nodes stored in memory - Is used to represent the content and model of an XML file Why DOM? - Is standard by W3C - DOM API in SAXP - Locate data in XML by access nodes of the tree - Rich interfaces and methods in DOM parser by SAXP

Building a DOM Tree from a XML File A simple example (p. 512) Dom.java - steps: 1. Write a XML file (author.xml) 2. Write a Java program with the DOM parser (D om.java) 3. Compile the program as (one-line command): javac –classpath.;%JAXP_HOME%\jaxp.jar;%JAXP_HOME%\ crimson.jar Dom.java 4. Execute program as: java –classpath.;%JAXP_HOME%\jaxp.jar;%JAXP_HOME%\ crimson.jar Dom author.xml false

Building a DOM Tree from a XML File (continue) Example of building a DOM tree from database - (p. 515 – 517) MakeXml.java - compile: javac MakeXml.java - execute: java MakeXml - note: Make sure JDBC-ODBC is registered and the Sales table exists

Concept of XSLT What is XSLT? –Stands for eXtensible Stylesheet Language for Transformations) –XSL for formatting and XSLT for transformations –is based on XML rules Why XSL/XSLT? -Transfer a XML document to another XML file or to HTML file -Specify the transformation as a stylesheet following XML syntax - Use templates to let processor matches against the tags in a XML file

Examples of Stylesheets Example of converting XML to HTML using stylesheet (p. 518) – authorSimple.xsl - Steps: 1. Write the.xsl file based on the.xml file (authorSimple.xml and authorSimple.xsl) 2. Write the java program to convert (XmlToHtml.java) 3. Compile as (one-line command): javac –classpath.;%JAXP_HOME%/jaxp.jar; %JAXP_HOME% /crimson.jar;%JAXP_HOME%/xalan.jar XmlToHtml.java 4. Execute as (one-line command): java –classpath.;%JAXP_HOME%/ jaxp.jar; %JAXP_HOME% /crimson.jar;%JAXP_HOME%/xalan.jar XmlToHtml authorSimple.xml authorSimple.xsl authorSimple.html

Examples of Stylesheets (continue) Another example of converting XML to HTML using stylesheet (p. 522) – author.xml, author.xsl - use XmlToHtml.java to do the conversion - steps of compilation and execution the same as last example

Concept of SOAP What is SOAP? - Stands for Simple Object Access Protocol - Is interoperability standard for Web services - Provides a simple mechanism for making remote procedure calls and document exchanges using XML Why SOAP? - Easier to use - Distributed computing - Accessibility - XML based protocol

Examples of Using SOAP Servers with Messages Use SOAP servers and SOAP message to request information/data in XML with Java application - Xmethods site provides many SOAP servers and SOAP message that give us information we need to write to obtain the information/data from the SOAP serverhttp:// - SOAP message is an XML document that contains SOAP format we need to follow in order to send request to the server - Example of SOAP message from ITime server in Xmethods site (p. 528 Figure 13.23)

Examples of Using SOAP (continue) Example of write Java application using the SOAP message in XML (p. 529) TrySoapTime.java Example of calling request method with arguments from the command line execution - the SOAP message from BN.com server (p. 531) Figure Java application using the SOAP message in XML (p. 531) GetPrice.java - to execute (online command): java GetPrice services.xmethods.net 80 /soap/servlet/ rpcrouter

SOAP API and SOAP Server Tomcat SOAP API allows us to write clients without having to write XML request explicitly SOAP API is free to download SOAP server, i.e., tomcat, is also from to use Author has re-written the section Using the SOAP API, for new section, check the site: Download SOAP API 2.0 soap-bin-2.0.zip from Download SOAP server (Tomcat 4.0) from

Configuring SOAP API and SOAP Server Tomcat Assume the SOAP API 2.0 is installed in c:\SOAP\soap-2_2 directory, we set SOAP API home path as: set SOAP_HOME=c:\SOAP\soap-2_2 Assume the Tomcat 4.0 is installed in c :\TOMCAT\jakarta-tomcat-4.0 directory, we set Tomcat home path as: set CATALINA_HOME=C:\TOMCAT\jakarta-tomcat- 4.0

Configuring SOAP API and SOAP Server Tomcat (continue) We need to modify the classpath that Tomcat uses. In: %CATALINA_HOME%\bin\catalina.bat change the line: SET CLASSPATH=%CP% to: SET CLASSPATH=%CATALINA_HOME%\common\ lib\crimson.jar;%CP%;%SOAP_HOME%

Configuring SOAP API and SOAP Server Tomcat (continue) We need also to copy: soap.war file from: %SOAP_HOME%\webapps\ to: %CATALINA_HOME%\webapps\ so, after copy it should like this: %CATALINA_HOME%\webapps\ soap.war

Example of Using SOAP API with Tomcat Example of Using SOAP API without XML - (p. 533) GetJavaPrice.java - to compile the program (one-line command): javac –classpath.;%SOAP_HOME%\lib\soap.jar GetJavaPrice.java - to execute (one-line command): java –classpath.;%SOAP_HOME%\lib\soap.jar;%CATALINA_HOME%\ common\lib\crimson.jar;%CATALINA_HOME%\commo n\lib\mail.jar;%CATALINA_HOME%\common\lib\activat ion.jar GetJavaPrice

In-Class Exercises and Lab Assignment Do TEST YOUR UNDERSTANDING 1, 3, 5, 7, 9,11, 13, and 15 Lab Assignment (p. 536) 5, 7, and 8