5 &2 ( )" " & 6 7 83-4 6& )9 2) " *



Similar documents
XML & Databases. Tutorial. 2. Parsing XML. Universität Konstanz. Database & Information Systems Group Prof. Marc H. Scholl

+ <xs:element name="productsubtype" type="xs:string" minoccurs="0"/>

Databases and Information Systems 2

XML in programming. Patryk Czarnik. XML and Modern Techniques of Content Management 2012/13

How To Write An Xml Document In Java (Java) (Java.Com) (For Free) (Programming) (Web) (Permanent) (Powerpoint) (Networking) (Html) (Procedure) (Lang

Structured Data and Visualization. Structured Data. Programming Language Support. Programming Language Support. Programming Language Support

XML Programming in Java

Java 2 Platform, Enterprise Edition (J2EE): Enabling Technologies for EAI

XML nyelvek és alkalmazások

XML Parsing and Web Services Seminar Enterprise Computing

Network Programming. CS 282 Principles of Operating Systems II Systems Programming for Android

technische universität dortmund Prof. Dr. Ramin Yahyapour

Oracle Java CAPS Message Library for EDIFACT User's Guide

Service Description: NIH GovTrip - NBS Web Service

Languages for Data Integration of Semi- Structured Data II XML Schema, Dom/SAX. Recuperación de Información 2007 Lecture 3.

User manual for e-line DNB: the XML import file. User manual for e-line DNB: the XML import file

Java and XML parsing. EH2745 Lecture #8 Spring

Modernize your NonStop COBOL Applications with XML Thunder September 29, 2009 Mike Bonham, TIC Software John Russell, Canam Software

An Empirical Study on XML Schema Idiosyncrasies in Big Data Processing

JAXB: Binding between XML Schema and Java Classes

No Trade Secrets. Microsoft does not claim any trade secret rights in this documentation.

Continuous Integration Part 2

DocuSign Connect Guide

Orders.java. ArrayList of Drinks as they are ordered. Functions to calculate statistics on Drinks

by LindaMay Patterson PartnerWorld for Developers, AS/400 January 2000

Android Programming. Android App. Høgskolen i Telemark Telemark University College. Cuong Nguyen,

DRAFT. Standard Definition. Extensible Event Stream. Christian W. Günther Fluxicon Process Laboratories

ASPIRE Programmable Language and Engine

D4.1.2 Cloud-based Data Storage (Prototype II)

Security for industrial automation and control systems: Patch compatibility information

JAXB Tips and Tricks Part 2 Generating Java Classes from XML Schema. By Rob Ratcliff

[MS-FSDAP]: Forms Services Design and Activation Web Service Protocol

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach.

XML Filtering in Peer-to-peer Systems

BACHELOR S THESIS. Roman Betík XML Data Visualization

ADF Code Corner. 66. How-to color-highlight the bar in a graph that represents the current row in the collection. Abstract: twitter.

Introduction to Java. CS 3: Computer Programming in Java

client application supporting SMTP and POP3

Can I Make XML Go Faster?

JDOM Overview. Application development with XML and Java. Application Development with XML and Java. JDOM Philosophy. JDOM and Sun

API for java.util.iterator. ! hasnext() Are there more items in the list? ! next() Return the next item in the list.

Connecting Custom Services to the YAWL Engine. Beta 7 Release

COM_2006_023_02.xsd <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs=" elementformdefault="qualified">

Table of Contents. Java CGI HOWTO

Anexo XI - Código para Processar PDML e Gerar Script SQL

Inheritance, overloading and overriding

Sophro Ksantypa2 report editor and generator: Architecture Design

keyon Luna SA Monitor Service Administration Guide 1 P a g e Version Autor Date Comment

N CYCLES software solutions. XML White Paper. Where XML Fits in Enterprise Applications. May 2001

J a v a Quiz (Unit 3, Test 0 Practice)

Summary. Griglie e Sistemi di Elaborazione Ubiqui. Corso di Laurea Specialistica in Ingegneria informatica. Lucidi delle Esercitazioni

Java and XSLT. Java and XSLT. By GiantDino. Eric M. Burke Publisher: O'Reilly First Edition September 2001 ISBN: , 528 pages

[MS-QoE]: Quality of Experience Monitoring Server Protocol Specification

Web Service Caching Using Command Cache

Recursion. Definition: o A procedure or function that calls itself, directly or indirectly, is said to be recursive.

ONVIF TM. ONVIF Specification Version 2.4 Release Notes. ONVIF

The Forger s Art Exploiting XML Digital Signature Implementations HITB 2013

Developer Experience: Because Coders are People Too

CAS Protocol 3.0 specification

VILNIUS GEDIMINAS TECHNICAL UNIVERSITY

XML Processing with Java

Data Structures and Algorithms

Data Integration Hub for a Hybrid Paper Search

java Features Version April 19, 2013 by Thorsten Kracht

Creating Web-Based EDI Applications with AJAX Joseph R. McVerry American Coders, Ltd & Ralph Naylor June 28, 2006

Pemrograman Dasar. Basic Elements Of Java

Data Structures and Algorithms Lists

Responders: Language Support for Interactive Applications

Brekeke PBX Version 2 IVR Script Developer s Guide Brekeke Software, Inc.

Introduction to Java

Design Patterns in Parsing

Balisage: The Markup Conference

APM for Java. AppDynamics Pro Documentation. Version 4.0.x. Page 1

Java Programming Fundamentals

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007

Plugin JUnit. Contents. Mikaël Marche. November 18, 2005

The following program is aiming to extract from a simple text file an analysis of the content such as:

PHP and XML. Brian J. Stafford, Mark McIntyre and Fraser Gallop

European Access Point for Truck Parking Data

Tutorial for Creating Resources in Java - Client

16.1 DataFlavor DataFlavor Methods. Variables

COSC Introduction to Computer Science I Section A, Summer Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19

How to develop your own app

Extending XSLT with Java and C#

Java. Java. e=mc 2. composition

[MS-QoE]: Quality of Experience Monitoring Server Protocol. Intellectual Property Rights Notice for Open Specifications Documentation

Model-driven Rule-based Mediation in XML Data Exchange

Service Oriented Computing: SOAP, WSDL and UDDI. Dr. Cristian Mateos Diaz ( ISISTAN - CONICET

XML Validation Guide. Questions or comments about this document should be directed to: E mail CEPI@michigan.gov Phone

Rhea. Automatic IO Filtering for Optimizing Cloud Analytics

Evidence based performance tuning of

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

WEB SERVICES VULNERABILITIES

Intruduction to Groovy & Grails programming languages beyond Java

Management Information Systems 260 Web Programming Fall 2006 (CRN: 42459)

Anatomy of Credit card Numbers

UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming

CS 378 Big Data Programming. Lecture 9 Complex Writable Types

How To Understand The Architecture Of Java 2Ee, J2Ee, And J2E (Java) In A Wordpress Blog Post

JMS Messages C HAPTER 3. Message Definition

Transcription:

! " #$%&

0 ) ( )" %+ %*,( )" -" ".. /+% ()( )" ' &2 34%* 5 &2 ( )" " & 6 7 83-4 6& )9 2) " * 1

6 5 75 6 5 75 %* %* 32 %,6,) 5 " )& 8 * 2-4;< 7)&%*2 : = 75 75 75 %* 32,) 5, 37 %,2-4;< 7)&%*2

?7 7 (? A% % A%4A&%+8 A%A5 (?4( "?@ %4" 7%+8 > B

! 83 %+ 73 A&%+ $* * &7 3$4D D EE- ) 'D 8 74FF***2/7 @ 2 F C " # % " % H 5 4,) 5 7 5&G %*

$ <pricelist> <coffee> <name> Mocha Java </name> <price> 11.95 </price> </coffee> </pricelist> 8startElement(,priceList, ) 82 8startElement(,coffee, ) 82 8startElement(,name, ) 82 8characters("Mocha Java", ) 82 8endElement(,name,..) 82 8startElement(,price, ) 82 8characters("11.95", ) 82 8endElement(,price, ) 82 8endElement(,coffee, ) 82 8endElement(,priceList, ) 82 58 84 5 7* * %* 2-45 * )-" 8= %# 5&G I %* J & " 88* 83@,) 5 D ) 224 - startdocument enddocument - startelementendelement - characters - processinginstruction DefaultHandler +" 7" D ) 4 @* = )93 *

startelement public void startelement(java.lang.string uri, java.lang.string localname, java.lang.string qname, Attributes attributes) throws SAXException uri4! " " -$ localname4 )! " 68/ qname4! " " 68/ attributes4$" 5 " 9% %)93 I+/J! " $88* endelement 6 @ attributes ' characters public void characters(char[] buffer, int offset, int length) throws SAXException buffer: & 0 offset4%8/ offset+length String s = new String(buffer, offset, length); 1

$ <pricelist> <coffee> <name> Mocha Java </name name> <price> 11.95 </price price> </coffee> </pricelist> %84K & A&= G 839* $* (4 2 % 2 7D ) : & # ' SAXParserFactory factory = SAXParserFactory.newInstance(); 8SAXParserFactory SAXParser saxparser = factory.newsaxparser(); 8SAXParser saxparser.parse("pricelist.xml", handler); 9H% pricelist.xml: $7() L M " handler: +$& DefaultHandler" 7" D )N )

"() )* 5 * 8" ;(O& K " " G " A ICC:J 8?@)?@)+$) " +8 2 ) F+8 & " " 7" -74Iterator i = list.iterator(); -74SAXParser saxparser = factory.newsaxparser(); > % %# <pricelist> <coffee> <name> Mocha Java </name> <price> 11.95 </price> </coffee> </pricelist> 06 5" P" inname P A& inmochajava 5" P7 inmjprice P print(s) B

%# + public void startelement(..., String elementname,,...) { if (elementname.equals("name")){ inname = true; } else if (elementname.equals("price") && inmochajava ){ inmjprice = true; inmochajava = false; } } public void characters(char [] buf, int offset, int len) { String s = new String(buf, offset, len); if (inname && s.equals("mocha Java")) { inmochajava = true; inname = false; } else if (inmjprice) { System.out.println("The price of Mocha Java is: " + s); inmjprice = false; } } C!<name name>, public void startelement(..., String elementname,...){ if (elementname.equals("name")){")){ inname = true; } else if (elementname.equals("price") && inmochajava ){ inmjprice = true; <name>mocha Java</name> inmochajava = false; } } <price>11.95</price> public void characters(char [] buf, int offset, int len) { String s = new String(buf, offset, len); if (inname && s.equals("mocha Java")) { inmochajava = true; inname = false; } else if (inmjprice) { System.out.println("The %8$ price of Mocha Java is: " + s); inmjprice = false; } } )0 & 0 &P8 inname

inname:!"mocha Java", public void startelement(..., String elementname,...){ if (elementname.equals("name")){ inname = true; } else if (elementname.equals("price") && inmochajava ){ inmjprice = true; inmochajava = false; } } <name>mocha Java</name> <price>11.95</price> public void characters(char [] buf, int offset, int len) { String s = new String(buf, offset, len); if (inname && s.equals("mocha Java")) { inmochajava = true; inname = false; } else if (inmjprice) { System.out.println("The price of Mocha Java is: " + s); inmjprice = false; } } inname inmochajava " # public void characters(char [] buf, int offset, int len) { String s = new String(buf, offset, len); if (inname)) { if (s.equals("mocha Java")) { inmochajava = true; inname = false; } else inname = false; ; } else if (inmjprice) { System.out.println("The price of Mocha Java is: " + s); inmjprice = false; } } <name>mocha Java</name> <price>11.95</price> inname inmochajava

inmochajava!<price price>, public void startelement(..., String elementname,...){ if (elementname.equals("name")){ inname = true; } else if (elementname.equals("price")") && inmochajava ){ inmjprice = true; <name>mocha Java</name> inmochajava = false; } } <price>11.95</price> public void characters(char [] buf, int offset, int len) { String s = new String(buf, offset, len); if (inname && s.equals("mocha Java")) { inmochajava = true; inname = false; } else if (inmjprice) { System.out.println("The price of Mocha Java is: " + s); inmjprice = false; } } inname inmochajava inmjprice ' inmjprice # public void startelement(..., String elementname,...){ if (elementname.equals("name")){ inname = true; } else if (elementname.equals("price") && inmochajava ){ inmjprice = true; inmochajava = false; } } <name>mocha Java</name> <price>11.95</price> public void characters(char [] buf, int offset, int len) { String s = new String(buf, offset, len); if (inname && s.equals("mocha Java")) { inmochajava = true; inname = false; } else if (inmjprice)) { System.out.println("The price of Mocha Java is: : " + s); inmjprice = false; } } inmjprice print(s) 1

) # <pricelist> <coffee> <name> Mocha Java </name> <name> MS Java </name> <price> 11.95 </price> </coffee> </pricelist> 5" P" inname P A& inmochajava 5" P7 inmjprice P print(s) : ) # public void startelement(..., String elementname,...){ if (elementname.equals("name")){ inname = true; } else if (elementname.equals("price")") && inmochajava ){ inmjprice = true; <name>mocha Java</name> inmochajava = false; } } <name>ms Java</name> inmochajava * <price> ) " " <name>* )0 inmochajava &6 ) " " <price>* ) 0 inmjprice & A&* = <price>11.95</price> inname inmochajava inmjprice

) # % 3738" " 8 " ( )" 2 ) 0 6)$2(.( " 3738 " )$2-2(name price) + &,/ )8)% 8 D ) )9& * 8 " $6( )" 2 > - E 88$ H( )" Q /I-" J" & %* &* * 2 Q &,/ Q " 9 ) 8) 5 & ( )" B

. /0 0 1 0!! %* % % startelement characters ($8 ($8 8 8 getpricelist() %* ) +" " %* ) $6 & " ($88I %J2 0 2-2)9 getpricelist() & 82 & %%+ &,/ C 12 '

1 2 #3 412 5 (? %* " " ) ) $" 0 8 8$ 5 & -6" 'D 6& " " 7 83 83G. ( )" " 5 5 ' 12 $/ <?xml version="1.0"?> <pricelist> <coffee> <name>mocha Java</name> <price>11.95</price> </coffee> </pricelist> ( "!! 5 "! 4PriceList! 5 "! 4coffee - 4( )" $I( "! J pricelist ( "! 4&( )" $" $2-2 version="1.0" $76 Document Node Element Node " " NodeList '

6 $ <?xml version="1.0"?> <pricelist> <coffee> <name>mocha Java</name> <price>11.95</price> </coffee> </pricelist> - 4D(%.%* 2 5 "! 4coffee! 5 "! 4name!. /! 4Mocha Java 5 "! 4price!. /! 411.95 '' - 7! 7& - /! 8D D ()0 883! " " 9 4 getelementsbytagname '1

$ <pricelist> <coffee> <name> Mocha Java </name name> <price> 11.95 </price price> </coffee> </pricelist> %84K & A&= G 839* $* (4 2 (? 2 7 088" ': & # 12 ' DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 8DocumentBuilderFactory DocumentBuilder builder = factory.newdocumentbuilder(); 8(? Document document = builder.parse("pricelist.xml"); (? parse(). 8" ) " 7(?-" '

&.!! ' NodeList coffeenodes = document.getelementsbytagname("coffee"); "); for (int i=0; i < coffeenodes.getlength(); i++) { thiscoffeenode = coffeenodes.item(i); Node thisnamenode = thiscoffeenode.getfirstchild(); String data = thisnamenode.getfirstchild().getnodevalue(); (); if (data.equals("mocha Java")) { Node thispricenode = thisnamenode.getnextsibling(); String price = thispricenode.getfirstchild().getnodevalue(); (); break; } } PA& " " (? $ '> # coffee coffee" 7 NodeList coffeenodes = document.getelementsbytagname("coffee"); "); getelementsbytagname4 )0 888 5 " 3! " * 5 " M" " NodeList <?xml version="1.0"?> <pricelist> <coffee> <name>mocha Java</name> <price>11.95</price> </coffee> </pricelist> 'B

$ " coffee coffee 7 NodeList coffeenodes = document.getelementsbytagname("coffee"); for (int i=0; i < coffeenodes.getlength(); i++) { thiscoffeenode = coffeenodes.item(i); } coffeenodes.item(0) <?xml version="1.0"?> <pricelist> <coffee> <name>mocha Java</name> <price>11.95</price> </coffee> </pricelist> 'C # coffee coffee7 NodeList coffeenodes = document.getelementsbytagname("coffee"); for (int i=0; i < coffeenodes.getlength(); i++) { thiscoffeenode = coffeenodes.item(i); Node thisnamenode = thiscoffeenode.getfirstchild(); String data = thisnamenode.getfirstchild().getnodevalue(); if (data.equals("mocha Java")) { Node thispricenode = thiscoffeenode.getnextsibling(); String price = thispricenode.getfirstchild().getnodevalue(); <?xml version="1.0"?> <pricelist> break; } } <coffee> 8D <name>mocha Java</name> <price>11.95</price> </coffee> </pricelist> 1

# name name7 NodeList coffeenodes = document.getelementsbytagname("coffee"); for (int i=0; i < coffeenodes.getlength(); i++) { thiscoffeenode = coffeenodes.item(i); Node thisnamenode = thiscoffeenode.getfirstchild(); String data = thisnamenode.getfirstchild().getnodevalue(); (); if (data.equals("mocha Java")) { Node thispricenode = thiscoffeenode.getnextsibling(); <?xml version="1.0"?> String price = thispricenode.getfirstchild().getnodevalue(); <pricelist> break; } } 8D <coffee> Element Node: coffee <name>mocha Java</name> NodeList <price>11.95</price> Element Node: name Element Node: price </coffee> NodeList NodeList </pricelist> Text Node: Mocha Java Text Node: 11.95 1 #, " 7 NodeList coffeenodes = document.getelementsbytagname("coffee"); for (int i=0; i < coffeenodes.getlength(); i++) { thiscoffeenode = coffeenodes.item(i); Node thisnamenode = thiscoffeenode.getfirstchild(); String data = thisnamenode.getfirstchild().getnodevalue(); if (data.equals("mocha Java")) { Node thispricenode = thisnamenode.getnextsibling(); String price = thispricenode.getfirstchild().getnodevalue(); <?xml version="1.0"?> break; } } <pricelist> <coffee> <name>mocha Java</name> / <price>11.95</price> </coffee> </pricelist> 1

# price price7 NodeList coffeenodes = document.getelementsbytagname("coffee"); <?xml version="1.0"?> <pricelist> for (int i=0; i < coffeenodes.getlength(); i++) { <coffee> thiscoffeenode = coffeenodes.item(i); <name>mocha Java</name> Node thisnamenode = thiscoffeenode.getfirstchild(); <price>11.95</price> String data = thisnamenode.getfirstchild().getnodevalue(); </coffee> 8D if (data.equals("mocha Java")) { </pricelist> Node thispricenode = thisnamenode.getnextsibling(); String price = thispricenode.getfirstchild().getnodevalue(); (); break; } } 1' - 12 E /I-" J" & %* &* * 2 E )0 8885 " 3! " E 8) 5 & ( )" Q 7 & Q &,/ 11

12 ' % " $" ". & ( )" $8 $" 76 0 7). ( )" $9 )5 8$& ( )" (? " 8. ( )" $& 0 7) $$8 5 8$& ( )" 1: 8# 0 1

8# 0 Datenabstraktion Java- Klassen Instanzen Java- Objekte XML- Schema Instanz XML- Dokument Übersetzen Validieren Deserialisieren Serialisieren F * 2 0* )4 & 8$ 5& ( )" A%-4A&% 8 -. & A& & (& 7 ) 1> $ <pricelist> <coffee> <name>mocha Java</name> <price>11.95</price> </coffee> </pricelist> " A%- public interface PriceList { java.util.list getcoffee(); public interface CoffeeType { String getname(); void setname(string value) java.math.bigdecimal getprice(); void setprice(java.math.bigdecimal value) } } 1B

8# 0xsd:choice <xs:element name="boolcommentorvalue"> <xs:complextype> <xs:choice> <xs:element name="bool" type="xs:boolean"/> <xs:element name="comment" type="xs:string"/> <xs:element name="value" type="xs:int"/> </xs:choice> </xs:complextype> </xs:element> )(,7 A&3$ * 1C 8# 0xsd:choice <xs:element name="boolcommentorvalue"> <xs:complextype> public interface BoolCommentOrValue { <xs:choice> int getvalue(); <xs:element name="bool" type="xs:boolean"/> void setvalue(int value); <xs:element name="comment" boolean type="xs:string"/> issetvalue(); <xs:element name="value" type="xs:int"/> java.lang.string getcomment(); </xs:choice> void setcomment(java.lang.string value); </xs:complextype> boolean issetcomment(); </xs:element> boolean getbool(); void setbool(boolean value); boolean issetbool(); Object getcontent(); boolean issetcontent(); void unsetcontent(); } :

& ' " # $4 " )A& D R 3$* 2 G " )9( )" " 8$ * 2 " " " 68 : 9* "$ 3 08 - &* 3+ " K 68* )2 " 3 8% 8 " 2 :

"$ 3 K 68 * K 7- K 6876 * K 0 4- N " " 8* % )* )" " - 2 :' "$ 3 XML - N " " " " 6,/ %8 M $* 8*2 " " )9 " # $ $& 2 :1

& # /! ' +4 8* % ) 68 &" 7 - " 2 ++4 " " )9 " # $ $& 2 @)8* + ++ SBT :: &, ' / (?! & %(? " # $ # '2# 422K 77 6. 8 " & ( )" ". :