Technische universität dortmund Service Computing Service Computing Prof. Dr. Ramin Yahyapour IT & Medien Centrum 22. Oktober 2009.

Slides:



Advertisements
Similar presentations
CS Network Programming CS 3331 Fall CS 3331 Outline Socket programming Remote method invocation (RMI)
Advertisements

Chungnam National University DataBase System Lab
XPathAPI XPathAPI HOME : API : j/apidocs/ Lib.
1 eXtensible Markup Language. XML is based on SGML: Standard Generalized Markup Language HTML and XML are both based on SGML 2 SGML HTMLXML.
J0 1 Marco Ronchetti - Web architectures – Laurea Specialistica in Informatica – Università di Trento Java XML parsing.
1 Roger L. Costello 16 June 2010 XQuery
1 Streams and Input/Output Files Part 2. 2 Files and Exceptions When creating files and performing I/O operations on them, the systems generates errors.
Copyright © 2003 Pearson Education, Inc. Slide 7-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
Copyright © 2003 Pearson Education, Inc. Slide 8-1 Created by Cheryl M. Hughes, Harvard University Extension School Cambridge, MA The Web Wizards Guide.
0 - 0.
Addition Facts
Technische universität dortmund Service Computing Service Computing Prof. Dr. Ramin Yahyapour IT & Medien Centrum 12. November 2009.
Technische universität dortmund Service Computing Service Computing Prof. Dr. Ramin Yahyapour IT & Medien Centrum 24. November 2009.
1 / / / /. 2 (Object) (Object) –, 10 (Class) (Class) –, –, – (Variables) [ Data member Field Attribute](, ) – (Function) [ Member function Method Operation.
Molecular Biomedical Informatics Web Programming 1.
1 public class Newton { public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t)
Addition 1’s to 20.
25 seconds left…...
We will resume in: 25 Minutes.
Chapter 10 Ch 1 – Introduction to Computers and Java Streams and File IO 1.
Schema validation with java xml xsd Agenda Umgebung Programm Output.
XML Parsers By Chongbing Liu. XML Parsers  What is a XML parser?  DOM and SAX parser API  Xerces-J parsers overview  Work with XML parsers (example)
1 SAX and more… CS , Spring 2008/9. 2 SAX Parser SAX = Simple API for XML XML is read sequentially When a parsing event happens, the parser invokes.
SAX A parser for XML Documents. XML Parsers What is an XML parser? –Software that reads and parses XML –Passes data to the invoking application –The application.
1 The Simple API for XML (SAX) Part I ©Copyright These slides are based on material from the upcoming book, “XML and Bioinformatics” (Springer-
Xerces The Apache XML Project Yvonne Yao. Introduction Set of libraries that provides functionalities to parse XML documents Set of libraries that provides.
21-Jun-15 SAX (Abbreviated). 2 XML Parsers SAX and DOM are standards for XML parsers-- program APIs to read and interpret XML files DOM is a W3C standard.
26-Jun-15 SAX. SAX and DOM SAX and DOM are standards for XML parsers--program APIs to read and interpret XML files DOM is a W3C standard SAX is an ad-hoc.
Apache DOM Parser©zwzOctober 24, 2002 Wenzhong Zhao Department of Computer Science The University of Kentucky.
17 Apr 2002 XML Programming: SAX Andy Clark. SAX Design Premise Generic method of creating XML parser, parsing documents, and receiving document information.
Processing of structured documents Spring 2003, Part 5 Helena Ahonen-Myka.
CSE 6331 © Leonidas Fegaras XML Tools1 XML Tools Leonidas Fegaras.
CSE 6331 © Leonidas Fegaras XML Tools1 XML Tools Leonidas Fegaras.
SDPL 2003Notes 3: XML Processor Interfaces1 3. XML Processor APIs n How can applications manipulate structured documents? –An overview of document parser.
XML for E-commerce II Helena Ahonen-Myka. XML processing model n XML processor is used to read XML documents and provide access to their content and structure.
1 XML at a neighborhood university near you Innovation 2005 September 16, 2005 Kwok-Bun Yue University of Houston-Clear Lake.
XML for E-commerce III Helena Ahonen-Myka. In this part... n Transforming XML n Traversing XML n Web publishing frameworks.
5 Processing XML Parsing XML documents  Document Object Model (DOM)  Simple API for XML (SAX) Class generation Overview.
Advanced Java Session 9 New York University School of Continuing and Professional Studies.
CSE 6331 © Leonidas Fegaras XML Tools1 XML Tools.
1 Java and XML Modified from presentation by: Barry Burd Drew University Portions © 2002 Hungry Minds, Inc.
SDPL 2002Notes 3: XML Processor Interfaces1 3. XML Processor APIs n How can applications manipulate structured documents? –An overview of document parser.
SDPL 20113: XML APIs and SAX1 3. XML Processor APIs n How can (Java) applications manipulate structured (XML) documents? –An overview of XML processor.
SAX. What is SAX SAX 1.0 was released on May 11, SAX is a common, event-based API for parsing XML documents Primarily a Java API but there implementations.
Beginning XML 4th Edition. Chapter 12: Simple API for XML (SAX)
Extensible MarkUp Language. AGENDA  OVERVIEW OF XML  DATA TYPE DEFINITION LANGUAGE  XML SCHEMA  XML PARSERS 1) DOM PARSER 2) SAX PARSER 3) JAXB PARSER.
XML Processing in Java. Required tools Sun JDK 1.4, e.g.: JAXP (part of Java Web Services Developer Pack, already in Sun.
CSE 6331 © Leonidas Fegaras XML Tools1 XML Tools.
SNU OOPSLA Lab. DOM/SAX Applications The ubiquitous XML(9) © copyright 2001 SNU OOPSLA Lab.
Apache DOM Parser©zwzOctober 24, 2002 Wenzhong Zhao Department of Computer Science The University of Kentucky.
© Marty Hall, Larry Brown Web core programming 1 Simple API for XML SAX.
SAX2 and DOM2 Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XML and SAX (A quick overview) ● What is XML? ● What are SAX and DOM? ● Using SAX.
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.
SDPL 20063: XML Processor Interfaces1 3. XML Processor APIs n How can (Java) applications manipulate structured (XML) documents? –An overview of XML processor.
Simple API for XML (SAX) Aug’10 – Dec ’10. Introduction to SAX Simple API for XML or SAX was developed as a standardized way to parse an XML document.
Processing of structured documents Part 4. XML processing model zXML processor is used to read XML documents and provide access to their content and structure.
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.
SDPL 2001Notes 3: XML Processor Interfaces1 3. XML Processor APIs n How applications can manipulate structured documents? –An overview of document parser.
USING ANDROID WITH THE DOM. Slide 2 Lecture Summary DOM concepts SAX vs DOM parsers Parsing HTTP results The Android DOM implementation.
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
Simple API for XML SAX. Agenda l Introduction to SAX l Installation and setup l Steps for SAX parsing l Defining a content handler l Examples Printing.
Parsing with SAX using Java Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
XML Parsers By Chongbing Liu.
Jagdish Gangolly State University of New York at Albany
Java API for XML Processing
SAX2 29-Jul-19.
WaysInJavaToParseXML
Presentation transcript:

technische universität dortmund Service Computing Service Computing Prof. Dr. Ramin Yahyapour IT & Medien Centrum 22. Oktober 2009

technische universität dortmund 2 HTTP Response HTTP/ OK Date: Fri, 31 Dec :59:59 GMT Content-Type: text/html Content-Length: 1354 Welcome to my new Homepage! (more file contents).

technische universität dortmund 3 Sending Message via SMTP Connecting to mailhost via ether... Trying connected 220 noao.edu Sendmail 4.1/SAG-Noao.G89 ready at Mon, 19 Jul :47:34 MST >>> HELO sun.tuc.noao.edu 250 noao.edu Hello sun.tuc.noao.edu., pleased to meet you >>> MAIL From: Sender ok >>> RCPT To: Recipient ok >>> DATA 354 Enter mail, end with. on a line by itself >>>. 250 Mail accepted >>> QUIT 221 noao.edu delivering mail

technische universität dortmund 4 XML Example Java and XML Brett McLaughlin Java 2 Micro Edition Eric Giguere Core Jini W. Keith Edwards

technische universität dortmund 5 SAX Parser (1) Import SAX Classes import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.Locator; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.apache.xerces.parsers.SAXParser; …

technische universität dortmund 6 SAX Parser (2) Install Parser and Input Stream public class MySAXParser { public void parseFile(String uri) { } public static void main(String[] args) { MySAXParser mySAX = new MySAXParser(); mySAX.parseFile("booklist.xml"); }

technische universität dortmund 7 SAX Parser (3) Install ContentHandler and Exceptions public void parseFile(String uri) { XMLReader parser = new SAXParser(); // Create an instance of MyContentHandler ContentHandler myHandler = new MyContentHandler(); parser.setContentHandler(myHandler); try { parser.parse(uri); } catch (IOException e) { System.out.println("Error reading file: " + e.getMessage()); System.exit(1); } catch (SAXException e) { System.out.println("Error parsing file: " + e.getMessage()); System.exit(1); } System.out.println("File parsed successfully!"); }

technische universität dortmund 8 SAX Parser (4) ContentHandler class MyContentHandler implements ContentHandler { private Locator locator; public void setDocumentLocator(Locator locator) {…} public void startDocument() throws SAXException {…} public void endDocument() throws SAXException {…} public void startPrefixMapping(String prefix, String uri){…} public void endPrefixMapping(String prefix) throws SAXException {…} … }

technische universität dortmund 9 SAX Parser (5) ContentHandler class MyContentHandler implements ContentHandler { public void startElement( String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {…} public void endElement( String namespaceURI, String localName, String qName) throws SAXException {…} … }

technische universität dortmund 10 SAX Parser (6) ContentHandler class MyContentHandler implements ContentHandler { public void characters(char[] ch, int start, int length){…} public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {…} public void processingInstruction(String target, String data) throws SAXException {…} public void skippedEntity(String name) throws SAXException {…} }

technische universität dortmund 11 Validation Example DTD <!ELEMENT Book (Title, Author, ISBN)> <!ATTLIST Book available CDATA #REQUIRED >

technische universität dortmund 12 Validation Example XML Schema

technische universität dortmund 13 XML Document Tree Book Title Price Author ISBNContent Chapter XHTML HEADBODY TitleChapter Transforming Document Trees

technische universität dortmund 14 Transformations with XSL <xsl:stylesheet version="1.0" xmlns:xsl=" > …Rules…

technische universität dortmund 15 Transformations with XSL Rules <xsl:stylesheet version="1.0" xmlns:xsl=" > …Action…

technische universität dortmund 16 Transformations with XSL Example of Transformation <xsl:stylesheet version="1.0" xmlns:xsl=" > XPath-Referencing XPath-Filtering

technische universität dortmund 17 Transformations with XSL Iterations

technische universität dortmund 18 Using DOM public class DOMParserDemo { public void performDemo(String uri) { System.out.println("Parsing XML File: " + uri + "\n\n"); // Instantiate your vendor's DOM parser implementation DOMParser parser = new DOMParser(); parser.setFeature(" true); parser.parse(uri); Document doc = parser.getDocument(); … do something with DOM … } public static void main(String[] args) { String uri = args[0]; DOMParserDemo parserDemo = new DOMParserDemo(); parserDemo.performDemo(uri); }

technische universität dortmund 19 Using DOM (2) Example for Accessing DOM Nodes public void printNode(Node node, String indent) { switch (node.getNodeType()) { case Node.DOCUMENT_NODE: System.out.println(" \n"); // recurse on each child NodeList nodes = node.getChildNodes(); if (nodes != null) { for (int i=0; i<nodes.getLength(); i++) { printNode(nodes.item(i), ""); } break; case Node.ELEMENT_NODE: case Node.TEXT_NODE: case Node.CDATA_SECTION_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.ENTITY_REFERENCE_NODE: case Node.DOCUMENT_TYPE_NODE: }

technische universität dortmund 20 Using DOM (2) Example for Accessing DOM Nodes public void printNode(Node node, String indent) { switch (node.getNodeType()) { case Node.DOCUMENT_NODE: case Node.ELEMENT_NODE: String name = node.getNodeName(); System.out.print(indent + "<" + name); NamedNodeMap attributes = node.getAttributes(); for (int i=0; i<attributes.getLength(); i++) { Node current = attributes.item(i); System.out.print(" " + current.getNodeName() + "=\"" + current.getNodeValue() + "\""); } System.out.println(">"); // recurse on each child NodeList children = node.getChildNodes(); if (children != null) { for (int i=0; i<children.getLength(); i++) { printNode(children.item(i), indent + " "); } System.out.println(indent + " "); break; case Node.TEXT_NODE: case Node.CDATA_SECTION_NODE: case Node.PROCESSING_INSTRUCTION_NODE: case Node.ENTITY_REFERENCE_NODE: case Node.DOCUMENT_TYPE_NODE: }