Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML in Web Technologies

Similar presentations


Presentation on theme: "XML in Web Technologies"— Presentation transcript:

1 XML in Web Technologies
Martin Kruliš by Martin Kruliš (v1.2)

2 XML eXtensible Markup Language
Universal format for semistructured data Plain text interleaved with XML markup Designed for structural (tree-like) data The structure of a document can be specified By a grammar (schema) designed by the author of the application Tools and libraries for XML processing Parsing and construction (SAX, DOM) Searching (XPath, XQuery) Transformations by Martin Kruliš (v1.2)

3 XML Sample <?xml version="1.0" encoding="utf-8"?> <addressbook> <person id="1"> <name>Karel</name> <surname>Novák</surname> </person> <person id="2"> <name>Jane</name> <surname>Doe</surname> </addressbook> Note that XML syntax is similar to HTML as they both origin from SGML. However, XML format is more strict (case sensitive, all tags must be paired, attribute values must be quoted, …). by Martin Kruliš (v1.2)

4 XML Validation Document Structure Document Semantics
XML document is well formed if it conforms to XML specification (tag syntax) Well formed documents can be parsed correctly Document Semantics XML document is valid (with respect to given schema) if its structure can be derived from the grammar specified in the schema Validation can be performed by existing tools, which are also integrated in parsers by Martin Kruliš (v1.2)

5 XML Validation Document Schema DTD XML Schema
Simple schema syntax embedded in XML specification Defines only the document (elements) structure No constraints for textual data Could be included in XML document XML Schema More robust language, more features Schema definition is also a XML document Supported by most parsers There are also other languages for specifying XML schema (Relax, Relax NG, Schematron, …); however, they are not widely used (at least not on the web). Example 1 by Martin Kruliš (v1.2)

6 Parsing Simple API for XML (SAX) Document Object Model (DOM)
Processes document sequentially Reports important events in sequential processing Opening and closing tags, found attributes, text, … For one-way or streaming processing Document Object Model (DOM) Similar API to HTML DOM Entire object is loaded in a object tree structure For modifications, transformations, … by Martin Kruliš (v1.2)

7 XPath XPath Query language for XML documents
Reflects the tree-based structure of the data and operates on sets of nodes Each query is a sequence of steps, each step takes set of nodes and produces another set Also contains filtering predicates and basic set of functions (arithmetics, logical and string fncs, …) /descendant::foo[attribute::id]/child::bar Selects elements bar, which are direct children of those elements foo, which have attribute id by Martin Kruliš (v1.2)

8 XPath Axes preceding ancestor parent following-sibling
preceding-sibling self following namespace child attribute descendant descendant-or-self by Martin Kruliš (v1.2)

9 (XML, HTML, or plain text)
Presenting XML Extensible Stylesheet Language (XSL) XSL = XSLT + XSL-FO (+ XPath) XSLT – transformation language XSL-FO – set of formatted objects XSLT XML document XSLT processor The result (XML, HTML, or plain text) by Martin Kruliš (v1.2)

10 Presenting XML plain text JSON data … HTML document XML document
Browser XSL-FO document XSLT processor XSL formatter PDF XSLT šablona XSLT template TeX source code TeX by Martin Kruliš (v1.2)

11 XSLT XSL Transformations
Language that specifies transformation templates The template is also an XML The templates… Use XPath to select parts of the transformed XML document Each part is then transformed using given rules The result of an XML transformation is either XML document, HTML document, or plain text The language is Turing complete Example 2 by Martin Kruliš (v1.2)

12 AJAX Asynchronous Javascript and XML
XML is used as universal format for transferring data (usually from server to client) Can be parsed using DOM API in Javascript Has been replaced by JSON in most cases XML advantages over JSON Document validation XPath searching XSLT transformations by Martin Kruliš (v1.2)

13 Web Services Web Services
Set of standards for remote method invocation Simple Object Access Protocol (SOAP) XML based protocol for data marshaling SOAP messages are transferred via HTTP Web Service Description Language (WSDL) Interface definition language that specifies the details of a web service (operations, message format, …) Universal Description, Discovery & Integration (UDDI) Registry for web services Operates also as a web service by Martin Kruliš (v1.2)

14 XML Applications XML Applications on the Web
Data exchange and application integration Universal nature of the XML makes it perfect candidate for situations, when separate subjects need to exchange data or integrate functionality Simple storage for tree-shaped data If a relational database does not fit your problem XML data can be easily visualized by XSLT Special cases Application configuration by Martin Kruliš (v1.2)

15 Discussion by Martin Kruliš (v1.2)


Download ppt "XML in Web Technologies"

Similar presentations


Ads by Google