XML pre programátorov 7. víkend s Linuxom 5. – 6. október 2002 Žilina Stanislav Meduna ETM Aktiengesellschaft

Slides:



Advertisements
Similar presentations
1 eXtensible Markup Language. XML is based on SGML: Standard Generalized Markup Language HTML and XML are both based on SGML 2 SGML HTMLXML.
Advertisements

J0 1 Marco Ronchetti - Web architectures – Laurea Specialistica in Informatica – Università di Trento Java XML parsing.
Open Office.Org What is the Open Office.org Source Project? Open source project through which Sun Microsystems is releasing the technology for the popular.
The eXtensible Markup Language (XML) An Applied Tutorial Kevin Thomas.
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, Uploading, Importing... Joshua Scotton.
XML & Data Structures for the Internet Yingcai Xiao.
Introduction XML Technologies Mark Graves. This presentation is Copyright 2001, 2002 by Mark Graves and contains material Copyright 2002 by Prentice Hall.
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.
31 Signs That Technology Has Taken Over Your Life: #6. When you go into a computer store, you eavesdrop on a salesperson talking with customers -- and.
XML DOM and SAX Parsers By Omar RABI. Introduction to parsers  The word parser comes from compilers  In a compiler, a parser is the module that reads.
XML Parser. Why Need a XML Parser ? Check XML syntax. ( is well-formed ? ) Validation. ( DTD and XML Schema ) Allow programmatic access to the document’s.
28-Jun-15 StAX Streaming API for XML. XML parser comparisons DOM is Memory intensive Read-write Typically used for documents smaller than 10 MB SAX is.
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.
CSE 6331 © Leonidas Fegaras XML Tools1 XML Tools Leonidas Fegaras.
XML Anisha K J Jerrin Thomas. Outline  Introduction  Structure of an XML Page  Well-formed & Valid XML Documents  DTD – Elements, Attributes, Entities.
Introduction to XML cs3505. References –I got most of this presentation from this site –O’reilly tutorials.
XML eXtensible Markup Language by Darrell Payne. Experience Logicon / Sterling Federal C, C++, JavaScript/Jscript, Shell Script, Perl XML Training XML.
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.
School of Computing and Management Sciences © Sheffield Hallam University To understand the Oracle XML notes you need to have an understanding of all these.
XML And Its UsesUPE Dearborn, 2/9/2004 ParsersCopyright 2004 by Blair Schneider McKaySlide 1 Agenda Introduction - "Why XML?" Section 1: XML Basics Section.
Extensible Markup and Beyond
XML 1 Enterprise Applications CE00465-M XML. 2 Enterprise Applications CE00465-M XML Overview Extensible Mark-up Language (XML) is a meta-language that.
SAX Parsing Presented by Clifford Lemoine CSC 436 Compiler Design.
These Questions are copied from
Advanced Java Session 9 New York University School of Continuing and Professional Studies.
CSE 6331 © Leonidas Fegaras XML Tools1 XML Tools.
 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.
XML Parsers Overview  Types of parsers  Using XML parsers  SAX  DOM  DOM versus SAX  Products  Conclusion.
XML – An Introduction Structured Data Mark-up James McCartney CSCE 590, Cluster and Grid Computing.
Softsmith Infotech XML. Softsmith Infotech XML EXtensible Markup Language XML is a markup language much like HTML Designed to carry data, not to display.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
Consuming eXtensible Markup Language (XML) feeds.
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.
XML Instructor: Charles Moen CSCI/CINF XML  Extensible Markup Language  A set of rules that allow you to create your own markup language  Designed.
1 Introduction to XML XML stands for Extensible Markup Language. Because it is extensible, XML has been used to create a wide variety of different markup.
XML Introduction. What is XML? XML stands for eXtensible Markup Language XML stands for eXtensible Markup Language XML is a markup language much like.
An Introduction to XML Paul Donohue May 8th 2002 Hotel Senator Zürich.
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.
CSE 6331 © Leonidas Fegaras XML Tools1 XML Tools.
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.
Using of XML for object store S. Linev, GSI Using of XML for object store. S.Linev2 Content XML and existing packages XML and existing packages.
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.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 4 1COMP9321, 15s2, Week.
XML A Language Presentation. Outline 1. Introduction 2. XML 2.1 Background 2.2 Structure 2.3 Advantages 3. Related Technologies 3.1 DTD 3.2 Schemas and.
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.
What is XML? eXtensible Markup Language eXtensible Markup Language A subset of SGML (Standard Generalized Markup Language) A subset of SGML (Standard Generalized.
XP Tutorial 9New Perspectives on HTML and XHTML, Comprehensive 1 Working with XHTML Creating a Well-Formed Valid Document Tutorial 9.
XML Tools (Chapter 4 of XML Book). What tools are needed for a complete XML application? n Fundamental components n Web infrasructure n XML development.
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.
Introduction to XML Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 7 Representing Web Data:
XML & JSON. Background XML and JSON are to standard, textual data formats for representing arbitrary data – XML stands for “eXtensible Markup Language”
XML 1.Introduction to XML 2.Document Type Definition (DTD) 3.XML Parser 4.Example: CGI Gateway to XML Middleware.
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.
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.
XML Parsers Overview Types of parsers Using XML parsers SAX DOM
Unit 4 Representing Web Data: XML
XML Related Technologies
Java XML IS
CHAPTER 9 JAVA AND XML.
Chapter 7 Representing Web Data: XML
XML Parsers Overview Types of parsers Using XML parsers SAX DOM
More Sample XML By Sadia Anjum.
XML Problems and Solutions
A parser for XML Documents
CSE591: Data Mining by H. Liu
Presentation transcript:

XML pre programátorov 7. víkend s Linuxom 5. – 6. október 2002 Žilina Stanislav Meduna ETM Aktiengesellschaft

Obsah Čo je to XML Základné princípy Oblasti využitia Príklad dokumentu Objektové a udalostné rozhrania libxml2 Príklad parsera

Čo je XML EXtensible Markup Language Jazyk pre popis informácií –pre ľudí –pre programy Sám o sebe nerobí vôbec nič Je na aplikácii dať dátam význam

Extensible XML definuje iba štruktúru Žiadne preddefinované značky Konkrétne značky sú vecou aplikácie Dokonalá rozšíriteľnosť

Markup Stromová štruktúra Značky –Elementy –Atribúty Obsah (vlastné informácie) Entity

Language Presne definované pravidlá –Správna syntax (well-formed) –Správna štruktúra (valid) - DTD, Xschema Možnosť automatickej kontroly Súvisiace štandardy –Namespaces, XSL, XLink, XPointer,...

Oblasti použitia Publikovanie dokumentov Uchovávanie štruktúrovaných údajov Protokoly pre výmenu informácií (napr. SOAP) Dobré pre profesný životopis :-)

Prečo používať XML? Formát čitateľný pre človeka aj stroj Netreba písať „zase ďalší parser“ Jednoduché rozširovanie Multiplatformný štandard Súvisiace štandardy riešia niektoré obvyklé aplikácie

Definícia typu dokumentu Aké elementy existujú Aké sú ich atribúty Aký je ich povolený obsah Kontrola správnosti štruktúry „Návod“ pre spracovanie Pomôcka pre čitateľa

Zoznam distribúcií – model FreeOnly DistList Distro Packaging VendorVersionCodeNamePackage File Name Version Release Free 0..n n

Zoznam distribúcií – DTD (1) <!ATTLIST Distro FreeOnly (%bool;) "false" Packaging (rpm|deb|tgz|other|none) "rpm" >

Zoznam distribúcií – DTD (2) <!ATTLIST Package Name CDATA #REQUIRED Version CDATA #REQUIRED Release CDATA "" Free (%bool;) "true" >

Zoznam distribúcií – dokument (1) Red Hat 7.3 Valhalla /usr/share/pixmaps/redhat/shadowman-32.png Debian Potato

Zoznam distribúcií – dokument (2)... Red Hat 7.3 Valhalla /usr/share/pixmaps/redhat/shadowman-32.png...

Parsery DOM (Document Object Model) –Strom v pamäti –Jednoduchá práca –Potrebuje viac pamäti –Jednoduchá modifikácia a zápis SAX (Simple API for XML) –Callbacky do používateľovho kódu –Stavy (a spotreba pamäti) sú vecou používateľa –Zložitejšia práca –Lepšia kontrola

libxml2 Linux / Unix / Windows MIT licencia Obyčajné C Objektové aj udalostné rozhranie Mnoho pohodlných vlastností

DOM FreeOnly Document DistList Packaging VendorCodeName Root element Distro children parent next prev children properties next content Valhalla rpm

SAX – stavový automat DistList Distro Vendor Version CodeName startElement endElement Package Vendor

SAX – callbacky <Distro FreeOnly="false" Packaging="rpm" > Red Hat startElement("Distro", { "FreeOnly", "false", "Packaging", "rpm", NULL }) startElement("DistList", { NULL }) startElement("Vendor", { NULL }) characters("Red Hat") endElement("Vendor“)

Libxml2 – DOM parser (1) #include int main(int argc, char **argv) { xmlDocPtr doc; xmlNodePtr distro, diEl; xmlAttrPtr attr; xmlKeepBlanksDefault(0); doc = xmlParseFile("distros.xml"); distro = xmlDocGetRootElement(doc)->children; Document DistList Root El Distro children

Libxml2 – DOM parser (2) while (distro) { if (!strcmp(distro->name, "Distro")) { diEl = distro->children; while (diEl) { if (! strcmp(diEl->name, "Vendor") || ! strcmp(diEl->name, "CodeName")) printf("%s ", diEl->children->content); diEl = diEl->next; } attr = distro->properties; while (attr) { if (! strcmp(attr->name, "Packaging")) printf("%s ", attr->children->content); attr = attr->next; } distro = distro->next; printf("\n"); } FreeOnly Vendor Distro next children properties

Libxml2 – DOM parser (3) diEl = distro->children; while (diEl) { if (! strcmp(diEl->name, "Vendor") || ! strcmp(diEl->name, "CodeName")) printf("%s ", diEl->children->content); diEl = diEl->next; } attr = distro->properties; while (attr) { if (! strcmp(attr->name, "Packaging")) printf("%s ", attr->children->content); attr = attr->next; } VendorCodeName next FreeOnlyPackaging next

Libxml2 – SAX parser (1) static enum { PARSER_START, PARSER_DISTLIST, PARSER_DISTRO, … } parserState = PARSER_START; …

Distro Vendor Version static void distStartElement(void *state, const xmlChar *name, const xmlChar **attrs) { switch (parserState) { … case PARSER_DISTRO: if (! strcmp(name, "Vendor")) { parserState = PARSER_VENDOR; } else if (! strcmp(name, "Version")) { parserState = PARSER_VERSION; … Libxml2 – SAX parser (2)

Distro Vendor Version static void distEndElement(void *state, const xmlChar *name) { switch (parserState) { … case PARSER_VENDOR: case PARSER_VERSION: parserState = PARSER_DISTRO; … } Libxml2 – SAX parser (3)

static xmlSAXHandler distListParser = { … 0, /* startDocument */ 0, /* endDocument */ (startElementSAXFunc) distStartElement, /*startEl*/ (endElementSAXFunc) distEndElement, /*endEl*/ 0, /* reference */ (charactersSAXFunc) distCharacters, /* characters */ … }; int main(int argc, char **argv) { xmlSAXParseFile(&distListParser, "distros.xml", 0); return 0; } Libxml2 – SAX parser (4)

Libxml2 Benoît Marchal: XML v příkladech, Computer Press 2000 ISBN , Prednáška –Fólie (HTML, PowerPoint) –Kompilovateľné príklady Zdroje

Stanislav Meduna ETM Aktiengesellschaft