Martin Kruliš by Martin Kruliš (v1.1)1
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.1)2
Karel Novák Jane Doe by Martin Kruliš (v1.1)3
Document Structure ◦ 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.1)4
Document Schema ◦ DTD 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 by Martin Kruliš (v1.1)5
Simple API for XML (SAX) ◦ 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.1)6
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 by Martin Kruliš (v1.1)7 Selects elements bar, which are direct children of those elements foo, which have attribute id
by Martin Kruliš (v1.1)8 self attributechild parent namespace ancestor descendant descendant-or-self following-sibling preceding-sibling preceding following
Extensible Stylesheet Language (XSL) ◦ XSL = XSLT + XSL-FO (+ XPath) XSLT – transformation language XSL-FO – set of formatted objects by Martin Kruliš (v1.1)9 XSLT XML document XSLT processor The result (XML, HTML, or plain text)
by Martin Kruliš (v1.1)10 plain text XML document XSLT processor XSLT šablona XSLT template XSL-FO document PDF TeX source code Browser TeXXSL formatter JSON data HTML document …
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 by Martin Kruliš (v1.1)11 Example 1
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.1)12
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.1)13 Example
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.1)14
by Martin Kruliš (v1.1)15