Bioinforma)cs Resources XML / Web Access

Similar documents
markup language carry data define your own tags self-descriptive W3C Recommendation

XML (Extensible Markup Language)

Data formats. { "firstname": "John", "lastname" : "Smith", "age" : 25, "address" : { "streetaddress": "21 2nd Street",

XML extensible Markup Language

Software Engineering Methods, XML extensible Markup Language. Tutorial Outline. An Example File: Note.xml XML 1

11. EXTENSIBLE MARKUP LANGUAGE (XML)

Extensible Markup Language (XML) Hamid Zarrabi-Zadeh Web Programming Fall 2013

INTERNET PROGRAMMING XML

What is XML? XML is designed to transport and store data.

XML for Android Developers. partially adapted from XML Tutorial by W3Schools

Web services CSCI 470: Web Science Keith Vertanen Copyright 2011

Web Computing. Revision Notes

Web Services Part I. XML Web Services. Instructor: Dr. Wei Ding Fall 2009

E-Applications. XML and DOM in Javascript. Michail Lampis

XML: a "skeleton" for creating markup languages you already know it! <element attribute="value">content</element> languages written in XML specify:

XML. Presented by : Guerreiro João Thanh Truong Cong

XML CSC 443: Web Programming

EXtensible Markup Language XML

but XML goes far beyond HTML: it describes data

MANAGING INFORMATION (CSCU9T4) LECTURE 2: XML STRUCTURE

COMP9321 Web Application Engineering. Extensible Markup Language (XML)

Web Programming Paper Solution (Chapter wise)

Extensible Markup Language (XML) What is XML? An example XML file. CSE 190 M (Web Programming), Spring 2008 University of Washington

Extensible Markup Language (XML) What is XML? Structure of an XML document. CSE 190 M (Web Programming), Spring 2007 University of Washington

Introduction Syntax and Usage XML Databases Java Tutorial XML. November 5, 2008 XML

Web Programming Step by Step

CSC Web Technologies, Spring Web Data Exchange Formats

The <schema> Element. <?xml version="1.0"?> <xs:schema>... </xs:schema>

Session 23 XML. XML Reading and Reference. Reading. Reference: Session 23 XML. Robert Kelly, 2018

INTERNET & WEB APPLICATION DEVELOPMENT SWE 444. Fall Semester (081) Module 4 (VII): XML DOM

CSE 154 LECTURE 23: XML

XML. Marie Dubremetz Uppsala, April 2014

Languages of the WEB. Jukka K. Nurminen

Introduction to XML. M2 MIA, Grenoble Université. François Faure

Copyright 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 7 XML

Comp 336/436 - Markup Languages. Fall Semester Week 4. Dr Nick Hayward

XML: extensible Markup Language

Introduction to XML. An Example XML Document. The following is a very simple XML document.

Semantic Web. XML and XML Schema. Morteza Amini. Sharif University of Technology Fall 94-95

EXtensible Markup Language XML

Java EE 7: Back-end Server Application Development 4-2

CSC System Development with Java Working with XML

INFO/CS 4302 Web Informa6on Systems

Introduction to XML. Chapter 133

7.1 Introduction. extensible Markup Language Developed from SGML A meta-markup language Deficiencies of HTML and SGML

XML. extensible Markup Language. ... and its usefulness for linguists

Comp 336/436 - Markup Languages. Fall Semester Week 4. Dr Nick Hayward

CLASS DISCUSSION AND NOTES

XML. Document Type Definitions XML Schema. Database Systems and Concepts, CSCI 3030U, UOIT, Course Instructor: Jarek Szlichta

The components of a basic XML system.

EAE-2037 Loading transactions into your EAE/ABSuite system. Unite 2012 Mike Bardell

INFO/CS 4302 Web Informa6on Systems

XML, XPath, and XSLT. Jim Fawcett Software Modeling Copyright

M359 Block5 - Lecture12 Eng/ Waleed Omar

XML 2 APPLICATION. Chapter SYS-ED/ COMPUTER EDUCATION TECHNIQUES, INC.

Well-formed XML Documents

PART. Oracle and the XML Standards

COMP9321 Web Application Engineering

Semistructured data, XML, DTDs

W3C XML XML Overview

Introduction to XML. National University of Computer and Emerging Sciences, Lahore. Shafiq Ur Rahman. Center for Research in Urdu Language Processing

Overview. Introduction. Introduction XML XML. Lecture 16 Introduction to XML. Boriana Koleva Room: C54

User Interaction: XML and JSON

Introduction to XML Zdeněk Žabokrtský, Rudolf Rosa

XML: Introduction. !important Declaration... 9:11 #FIXED... 7:5 #IMPLIED... 7:5 #REQUIRED... Directive... 9:11


Appendix H XML Quick Reference

Author: Irena Holubová Lecturer: Martin Svoboda

CSS, Cascading Style Sheets

extensible Markup Language

XML. Jonathan Geisler. April 18, 2008

XML Structures. Web Programming. Uta Priss ZELL, Ostfalia University. XML Introduction Syntax: well-formed Semantics: validity Issues

EMERGING TECHNOLOGIES. XML Documents and Schemas for XML documents

XML: Extensible Markup Language

extensible Markup Language

Bioinforma)cs Resources - Swissprot -

Data Presentation and Markup Languages

XML. Objectives. Duration. Audience. Pre-Requisites

Chapter 1: Getting Started. You will learn:

Computer Science E-75 Building Dynamic Websites

TASC Consulting Technical Writing Courseware Training

Outline. XML vs. HTML and Well Formed vs. Valid. XML Overview. CSC309 Tutorial --XML 4. Edward Xia

CSI 3140 WWW Structures, Techniques and Standards. Representing Web Data: XML

Fundamentals of Web Programming a

Semistructured Content

Solution Sheet 5 XML Data Models and XQuery

Chapter 2 XML, XML Schema, XSLT, and XPath

XML 2 APPLICATION. Chapter SYS-ED/ COMPUTER EDUCATION TECHNIQUES, INC.

COMP9321 Web Application Engineering

XML. XML Syntax. An example of XML:

StreamServe Persuasion SP5 XMLIN

XML Extensible Markup Language

XML (Extensible Markup Language

XML. Miroslav Trajanović. Šta je XML

Internet Technologies 11-XML. F. Ricci 2010/2011

The main Topics in this lecture are:

Computer Science S-75 Building Dynamic Websites

Chapter 13 XML: Extensible Markup Language

CIS192 Python Programming

ADT 2005 Lecture 7 Chapter 10: XML

Transcription:

Bioinforma)cs Resources XML / Web Access Lecture & Exercises Prof. B. Rost, Dr. L. Richter, J. Reeb Ins)tut für Informa)k I12

XML Infusion (in 10 sec) compila)on from hkp://www.w3schools.com/xml/default.asp XML is a sopware- and hardware-independent tool to store and to transport data XML stands for extensible Markup Language designed to store and transport data designed to be self-descrip)ve W3C recommenda)on it does NOT DO anything

About Tags XML tags are not predefined like HTML tags everybody can/has to invent his own tags new tags can be added any )me the author has to define content and structure of the document everything is plain text

Document Structure <?xml version="1.0" encoding="utf-8"?>! <bookstore>!! <book category="cooking">! <title lang="en">everyday Italian</title>! <author>giada De Laurentiis</author>! <year>2005</year>! <price>30.00</price>! </book>!! <book category="children">! <title lang="en">harry Potter</title>! <author>j K. Rowling</author>! <year>2005</year>! <price>29.99</price>! </book>!!...! </bookstore>!! taken from hkp://www.w3schools.com/xml/xml_usedfor.asp

Syntax Rules elements are defined using tags: <tagname>... </tagname> or <tagname/>! elements can be nested (contain other elements - parent and child nodes, sibling nodes) elements can have text content each document must contain ONE root element that is the parent of all other elements

Syntax Refined prolog line <?xml...> is op)onal tags must be (self-) closed tag are case sensi)ve tags must be properly nested: <a><b>...</a></b> Wrong! <a><b>...</b></a>! Right!

Syntax Refined tags may have akributes akribute values must always be quoted some special characters cannot be used directly -> coded by en)ty references: < < less than > > greater than & & ampersand &apos; apostrophe " quota)on mark comments: <!--... -->!

case sensi)ve Tag Names must start with a leker or underscore must not start with the lekers xml in any case can contain: lekers, digits, hyphens, underscores and periods cannot contain spaces apply common sense and a consistent style avoid: minus (-), period (.), colon (:), non-english characters for compa)bility reasons

XML Element everything between the start and the end tag tags are included can contain: - text - akributes - other elements - a mix of all are extensible

XML AKributes values must be quoted: single or double quotes the unused quo)ng character can be used inside the value decision for akribute or element undecided, but: - akributes cannot contain mul)ple values - akributes cannot contain tree structures - akributes are not easily expandable useful to store meta data, like element id, etc.

A Glimpse of Namespaces allows to prevent tag name collisions between different authors/applica)ons/domains implemented by the introduc)on of prefixes defined as an akribute: xmlns:prefix= URI! usage: <prefix:tagname>! the URI is only needed to be unique used to integrate other specifica)ons, e.g. XSLT

Levels of Correctness well formed: a document obey the syntax rules: - root element - closing tag - case sensi)ve - properly nested - akribute values quoted valid documents: in addi)on to being valid the also conform to a document type defini)on (format specifica)on)

Document Type Defini)ons two ways to specify a document structure: DTD: Document Typ Defini)on XML Schema: XML based alterna)ve to DTD

Example <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE note SYSTEM "Note.dtd > <note> <to>tove</to> <from>jani</from> <heading>reminder</heading> <body>don't forget me this weekend! &copyright; </body> </note>!

Example <!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> <!ENTITY copyright Copyright by.. > ]>!

XML DTD referenced from a document with: <!DOCTYPE note SYSTEM "Note.dtd">!!DOCTYPE defines the root element!element defines the structure of the elements #PCDTA means parse-able text data!entity defines special characters or strings

XML Schema alterna)ve to DTD <xs:element name="note > <xs:complextype> <xs:sequence> <xs:element name="to" type="xs:string"/> <xs:element name="from" type="xs:string"/> <xs:element name="heading" type="xs:string"/> <xs:element name="body" type="xs:string"/> </xs:sequence> </xs:complextype> </xs:element>! support of data types and namespaces wriken in XML and extensible!

XML with Python basic: xml.etree.elementtree import xml.etree.elementtree as ET! if you parse XML from untrusted sources use safeguarded libraries like defusedxml read xml input from file into a tree element: parse( filename )! read xml input from string into a tree element: fromstring(data_as_string)! retrieve root element from tree element: getroot()

XML with Python element type: tag (string) element akributes: attrib (dic)onary). Prefer access via e.get(key, default=none), e.items(), e.keys(), e.set(key, value)! element (text) content: text (string) child elements: simply iterate if you know the structure you can access children via index nota)on: root[0][1]! select child nodes of a certain type: root.iter( typename )!

XML with Python inser)on of new elements: - create new element with: Element( typename )! - add content via text and akributes via attrib! - add exis)ng sub-elements with append()! - append new element to the parent element simple output: treeelement.write( filename )! for valida)on and full XPath support use: lxml!

Web Access URI (Uniform Resource Iden)fier): is a string URL is a specific type of URI including the loca)on of a resource scheme://lo.ca.ti.on/pa/th?qu_er#fragment! scheme: protocol in use loca)on: the hos)ng server path: path to the resource query + fragment: op)onal specifica)ons

Web Access URL manipula)on: urljoin(base_url_string,relative_url_string) from urllib import parse as urlparse urlparse.urljoin('http://somehost.com/some/path/here','../ other/path') # Result is: 'http://somehost.com/some/other/path! - urlsplit(url_string,default_scheme='', allow_fragments=true) urlparse.urlsplit('http://www.python.org:80/faq.cgi?src=fie') # Result is: ('http','www.python.org:80','/ faq.cgi','src=fie','')!

Web Access easy to use third party package requests hkp://docs.python-requests.org/en/master/api/ #requests.request support Python v2 and v3 three main classes: Request, Response, Session Request: models a HTTP request send to the server Response: models the HTTP response Session: if you need con)nuity (ignore by now)

Requests requests.request(method, url, **kwargs) - mandatory: method (delete, get, head, op)ons, patch, post, put) - mandatory: URL - op)onal parameters: too many to list here convenience fun)ons: - requests.get/post/...(url,[data=none],**kwargs) import requests req = requests.request('get', 'http:// www.example.com/')!

Response useful akributes: status_code tells us about success or failure r.content: holds the response s content r.iter_content and r.iter_lines allow chunkwise reading of the response data, especially in a stream context or when handling huge responses