XML
XML – Extensible Markup Language
Generic format for structured representation of data.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 1 / 34
XML Extensible Markup Language Generic format for structured - - PowerPoint PPT Presentation
XML XML Extensible Markup Language Generic format for structured representation of data. DD1335 (Lecture 9) Basic Internet Programming Spring 2010 1 / 34 XML XML Extensible Markup Language Generic format for structured
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 1 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 1 / 34
XML
◮ Web services, business transactions
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 1 / 34
XML
◮ Web services, business transactions ◮ XHTML – HTML on XML syntax
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 1 / 34
XML
◮ Web services, business transactions ◮ XHTML – HTML on XML syntax ◮ The graphics format SVG
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 1 / 34
XML
◮ Web services, business transactions ◮ XHTML – HTML on XML syntax ◮ The graphics format SVG ◮ Configuration files
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 1 / 34
XML
◮ Web services, business transactions ◮ XHTML – HTML on XML syntax ◮ The graphics format SVG ◮ Configuration files ◮ Much more . . .
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 1 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 2 / 34
XML
◮ Open standard from W3C
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 2 / 34
XML
◮ Open standard from W3C ◮ Simple text format, easy to parse
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 2 / 34
XML
◮ Open standard from W3C ◮ Simple text format, easy to parse ◮ Supported by numerous vendors and platforms
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 2 / 34
XML
◮ Open standard from W3C ◮ Simple text format, easy to parse ◮ Supported by numerous vendors and platforms ◮ Excellent for transactions between different systems
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 2 / 34
XML
◮ Open standard from W3C ◮ Simple text format, easy to parse ◮ Supported by numerous vendors and platforms ◮ Excellent for transactions between different systems ◮ Structure allows for search
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 2 / 34
XML
◮ Open standard from W3C ◮ Simple text format, easy to parse ◮ Supported by numerous vendors and platforms ◮ Excellent for transactions between different systems ◮ Structure allows for search ◮ Facilitates separation between content and presentation
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 2 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 3 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 4 / 34
XML
◮ The XML declaration first, perhaps stating the file encoding.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 4 / 34
XML
◮ The XML declaration first, perhaps stating the file encoding.
◮ More declarations may follow.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 4 / 34
XML
◮ The XML declaration first, perhaps stating the file encoding.
◮ More declarations may follow. ◮ Thereafter exactly one XML element on the outermost level. (Pricelist in
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 4 / 34
XML
◮ The XML declaration first, perhaps stating the file encoding.
◮ More declarations may follow. ◮ Thereafter exactly one XML element on the outermost level. (Pricelist in
◮ End tags required. (Compare with <p> in HTML.)
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 4 / 34
XML
◮ The XML declaration first, perhaps stating the file encoding.
◮ More declarations may follow. ◮ Thereafter exactly one XML element on the outermost level. (Pricelist in
◮ End tags required. (Compare with <p> in HTML.)
◮ Correct nesting required. <a><bbb></a></bbb> never allowed.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 4 / 34
XML
◮ The XML declaration first, perhaps stating the file encoding.
◮ More declarations may follow. ◮ Thereafter exactly one XML element on the outermost level. (Pricelist in
◮ End tags required. (Compare with <p> in HTML.)
◮ Correct nesting required. <a><bbb></a></bbb> never allowed. ◮ Attribute values must be between quote marks. Example (SVG):
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 4 / 34
XML
◮ The XML declaration first, perhaps stating the file encoding.
◮ More declarations may follow. ◮ Thereafter exactly one XML element on the outermost level. (Pricelist in
◮ End tags required. (Compare with <p> in HTML.)
◮ Correct nesting required. <a><bbb></a></bbb> never allowed. ◮ Attribute values must be between quote marks. Example (SVG):
◮ As in HTML, ”entities” are used for some characters. Example: < for <
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 4 / 34
XML
◮ The XML declaration first, perhaps stating the file encoding.
◮ More declarations may follow. ◮ Thereafter exactly one XML element on the outermost level. (Pricelist in
◮ End tags required. (Compare with <p> in HTML.)
◮ Correct nesting required. <a><bbb></a></bbb> never allowed. ◮ Attribute values must be between quote marks. Example (SVG):
◮ As in HTML, ”entities” are used for some characters. Example: < for <
◮ A well-formed document – follows the syntactic rules.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 4 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 5 / 34
XML
◮ DTD (document type definition). W3C’s first standard.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 5 / 34
XML
◮ DTD (document type definition). W3C’s first standard. ◮ XML schemas. W3C’s follow-up standard with data types and name
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 5 / 34
XML
◮ DTD (document type definition). W3C’s first standard. ◮ XML schemas. W3C’s follow-up standard with data types and name
◮ Several private initiatives, including well-supported Relax NG.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 5 / 34
XML
◮ DTD (document type definition). W3C’s first standard. ◮ XML schemas. W3C’s follow-up standard with data types and name
◮ Several private initiatives, including well-supported Relax NG. ◮ An instance document is valid if it satisfies a specification.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 5 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 6 / 34
XML
◮ A pricelist element contains any number of item elements.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 6 / 34
XML
◮ A pricelist element contains any number of item elements. ◮ An item element contains one name and one price element.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 6 / 34
XML
◮ A pricelist element contains any number of item elements. ◮ An item element contains one name and one price element. ◮ The name and price elements consist of parsed character data.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 6 / 34
XML
◮ A pricelist element contains any number of item elements. ◮ An item element contains one name and one price element. ◮ The name and price elements consist of parsed character data.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 6 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 7 / 34
XML
◮ String types ◮ Numeric types ◮ Types for date and time
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 7 / 34
XML
◮ String types ◮ Numeric types ◮ Types for date and time
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 7 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 8 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 8 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 8 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 8 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 9 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 9 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 9 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 10 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 11 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 12 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 13 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 13 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 13 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 14 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 14 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 14 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 15 / 34
XML
◮ work smoothly with other schemas
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 15 / 34
XML
◮ work smoothly with other schemas ◮ allow updating without making old instance document invalid
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 15 / 34
XML
◮ work smoothly with other schemas ◮ allow updating without making old instance document invalid ◮ allow instance documents to contain extra information
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 15 / 34
XML
◮ work smoothly with other schemas ◮ allow updating without making old instance document invalid ◮ allow instance documents to contain extra information
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 15 / 34
XML
◮ work smoothly with other schemas ◮ allow updating without making old instance document invalid ◮ allow instance documents to contain extra information
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 15 / 34
XML
◮ A simpler schema definition language than that from W3C.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 16 / 34
XML
◮ A simpler schema definition language than that from W3C. ◮ Has become an ISO standard (ISO/IEC 19757-2) in sept 2009.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 16 / 34
XML
◮ A simpler schema definition language than that from W3C. ◮ Has become an ISO standard (ISO/IEC 19757-2) in sept 2009. ◮ Two syntaxes: Compact Syntax and an XML syntax.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 16 / 34
XML
◮ A simpler schema definition language than that from W3C. ◮ Has become an ISO standard (ISO/IEC 19757-2) in sept 2009. ◮ Two syntaxes: Compact Syntax and an XML syntax. ◮ See links at the end of
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 16 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 17 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 17 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 18 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 19 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 19 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 19 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 19 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 19 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 20 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 20 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 21 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 21 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 21 / 34
XML
◮ XSLT (XSL Transformation) – selects elements in the XML file. Can sort, perform
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 21 / 34
XML
◮ XSLT (XSL Transformation) – selects elements in the XML file. Can sort, perform
◮ XPath – syntax for positioning in the XML tree. Similar to path notation in a file
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 21 / 34
XML
◮ XSLT (XSL Transformation) – selects elements in the XML file. Can sort, perform
◮ XPath – syntax for positioning in the XML tree. Similar to path notation in a file
◮ XSL-FO (XSL Formatting Objects) – Page formatting.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 21 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 22 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 23 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 23 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 23 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 24 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 24 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 25 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 25 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 25 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 26 / 34
XML
◮ W3C object oriented APIs for XML documents.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 26 / 34
XML
◮ W3C object oriented APIs for XML documents. ◮ Access and change a document via the DOM parse tree.
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 26 / 34
XML
◮ W3C object oriented APIs for XML documents. ◮ Access and change a document via the DOM parse tree. ◮ Methods such as
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 26 / 34
XML
◮ W3C object oriented APIs for XML documents. ◮ Access and change a document via the DOM parse tree. ◮ Methods such as
◮ documentElement – returns the root node DD1335 (Lecture 9) Basic Internet Programming Spring 2010 26 / 34
XML
◮ W3C object oriented APIs for XML documents. ◮ Access and change a document via the DOM parse tree. ◮ Methods such as
◮ documentElement – returns the root node ◮ childNodes – returns all children of a node DD1335 (Lecture 9) Basic Internet Programming Spring 2010 26 / 34
XML
◮ W3C object oriented APIs for XML documents. ◮ Access and change a document via the DOM parse tree. ◮ Methods such as
◮ documentElement – returns the root node ◮ childNodes – returns all children of a node ◮ attributes – returns all attributes of a node DD1335 (Lecture 9) Basic Internet Programming Spring 2010 26 / 34
XML
◮ W3C object oriented APIs for XML documents. ◮ Access and change a document via the DOM parse tree. ◮ Methods such as
◮ documentElement – returns the root node ◮ childNodes – returns all children of a node ◮ attributes – returns all attributes of a node ◮ nodeType, nodeValue, etc. DD1335 (Lecture 9) Basic Internet Programming Spring 2010 26 / 34
XML
◮ W3C object oriented APIs for XML documents. ◮ Access and change a document via the DOM parse tree. ◮ Methods such as
◮ documentElement – returns the root node ◮ childNodes – returns all children of a node ◮ attributes – returns all attributes of a node ◮ nodeType, nodeValue, etc. ◮ removeChild, appendChild, etc. DD1335 (Lecture 9) Basic Internet Programming Spring 2010 26 / 34
XML
◮ ”Simple” API for XML ◮ Processes an XML file while reading through it ◮ Fast, memory efficient ◮ More complicated than DOM
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 27 / 34
XML
◮ ”Simple” API for XML ◮ Processes an XML file while reading through it ◮ Fast, memory efficient ◮ More complicated than DOM
◮ JDOM, DOM4J – other DOM implementations ◮ JAXB – converts XML into classes, and vice versa ◮ JAXM, JAX-RPC for asynchronous and synchronous messaging
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 27 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 28 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 29 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 29 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 29 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 29 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 29 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 30 / 34
XML
◮ SOAP – encodes and transmits messages between programs on the
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 30 / 34
XML
◮ SOAP – encodes and transmits messages between programs on the
◮ WSDL (Web Services Description Language) XML format to describe
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 30 / 34
XML
◮ SOAP – encodes and transmits messages between programs on the
◮ WSDL (Web Services Description Language) XML format to describe
◮ UDDI (Universal Description Discovery and Integration) Protocol for
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 30 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 31 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 31 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 31 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 32 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 33 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 33 / 34
XML
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 33 / 34
XML
◮ the XML syntax ◮ Three ways to specify allowed elements: DTDs, XML schemas and Relax NG ◮ Name Spaces ◮ XSL for presentation ◮ XML support in Java ◮ SOAP
DD1335 (Lecture 9) Basic Internet Programming Spring 2010 34 / 34