Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on...

14
Working with XML Working with XML

description

What is XML? EXtensible Markup Language EXtensible Markup Language A markup language much like HTML A markup language much like HTML More precisely, a markup metalanguage that allows you to create your own markup language. More precisely, a markup metalanguage that allows you to create your own markup language. XML was designed to describe data XML was designed to describe data XML tags are not predefined. You must define your own tags XML tags are not predefined. You must define your own tags XML uses a Document Type Definition (DTD) or an XML Schema to describe the data XML uses a Document Type Definition (DTD) or an XML Schema to describe the data XML with a DTD or XML Schema is designed to be self-descriptive XML with a DTD or XML Schema is designed to be self-descriptive Whereas an XML document contains data, an associated XML Schema contains metadata describing the format and requirements for that data. Whereas an XML document contains data, an associated XML Schema contains metadata describing the format and requirements for that data.

Transcript of Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on...

Page 1: Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.

Working with XMLWorking with XML

Page 2: Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.

Markup LanguagesMarkup Languages Text-based languages based on SGMLText-based languages based on SGML SGML = Standard Generalized Markup SGML = Standard Generalized Markup

LanguageLanguage actually a actually a metalanguagemetalanguage…a set of rules for creating …a set of rules for creating

markup languagesmarkup languages Features of SGML-derived markup languagesFeatures of SGML-derived markup languages

Elements (expressed as tags delimited by < >)Elements (expressed as tags delimited by < >) Attributes – features of the elementsAttributes – features of the elements Documents – composed of elementsDocuments – composed of elements Document type definitions (schema definitions) – Document type definitions (schema definitions) –

provide the meaning for and structure of elements provide the meaning for and structure of elements and their attributesand their attributes

HTML and XML are both derivations of SGMLHTML and XML are both derivations of SGML

Page 3: Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.

What is XML?What is XML? EEXXtensible tensible MMarkup arkup LLanguage anguage A A markup languagemarkup language much like HTML much like HTML More precisely, a More precisely, a markup markup metalanguagemetalanguage that allows you that allows you

to create your own markup language. to create your own markup language. XML was designed to XML was designed to describe datadescribe data XML tags are not predefined. You must XML tags are not predefined. You must define your own define your own

tagstags XML uses a XML uses a Document Type DefinitionDocument Type Definition (DTD) or an (DTD) or an XML XML

SchemaSchema to describe the data to describe the data XML with a DTD or XML Schema is designed to be XML with a DTD or XML Schema is designed to be self-self-

descriptivedescriptive Whereas an XML document contains Whereas an XML document contains datadata, an associated , an associated

XML Schema contains XML Schema contains metadatametadata describing the format and describing the format and requirements for that data.requirements for that data.

Page 4: Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.

XML vs. HTMLXML vs. HTML Purpose of HTML: display information on a browserPurpose of HTML: display information on a browser

HTML is a language based on the SGML coding HTML is a language based on the SGML coding conventionsconventions

Purpose of XML: provide a structure for the Purpose of XML: provide a structure for the description of datadescription of data XML is a subset of SGMLXML is a subset of SGML It is a It is a metalanguagemetalanguage with no preconceived elements or with no preconceived elements or

attributesattributes You use XML to create your own “language” for describing You use XML to create your own “language” for describing

data by specifying elements and attributesdata by specifying elements and attributes NOTE: a major purpose of XML is to serve as a NOTE: a major purpose of XML is to serve as a

standardized protocol for transmitting data between two standardized protocol for transmitting data between two different applications communicating with each other over different applications communicating with each other over the Webthe Web

HTML is for B2C, XML is for B2B

Page 5: Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.

Features of Markup LanguagesFeatures of Markup Languages DocumentDocument ElementElement

Elements arranged within the document in hierarchical Elements arranged within the document in hierarchical order (tree structure)order (tree structure)

Each element has a Each element has a namename (first word in its begin tag) and a (first word in its begin tag) and a valuevalue (everything between its (everything between its begin tag begin tag and its end tag)and its end tag)

Syntax: Syntax: <name> value </name><name> value </name> AttributeAttribute

Each element can include attributes (properties)Each element can include attributes (properties) An attribute includes a name and a valueAn attribute includes a name and a value Syntax:Syntax: name=valuename=value

Page 6: Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.

Sample XML Document (no attributes)

XML representation is hierarchical: a TREE

Page 7: Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.

What is a tree?What is a tree? Data structure for representing conceptual or data

hierarchies A type of collection

Other collections? array, table (2-d array), stack, queue, linked list, hash table (also called dictionary),

Characteristics of a Tree Nodes Links (also called branches) Parent-child relationships between nodes Parent can have many children Child has only one parent Path = a route from one node to another in the tree (e.g.

from root to a leaf) Traversal in a tree

use RECURSION to implement tree traversaltraversal

Page 8: Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.
Page 9: Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.

Example XML DocumentsExample XML Documents From MS AccessFrom MS Access

Data from a table or query in a .XML Data from a table or query in a .XML documentdocument

Metadata in a .XSD document (XML Metadata in a .XSD document (XML Schema)Schema)

From Amazon Web Services (AWS)From Amazon Web Services (AWS) Result of XML book item search requestResult of XML book item search request

For Semantic WebFor Semantic Web Web Ontology Language (OWL)Web Ontology Language (OWL)

Page 10: Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.

XML version of Departments table of Employee database (created by MS Access)

Page 11: Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.

XSD (XML Schema Description) defines the metadata of an XML document.

XSD is also expressed in XML format.

Created by MS Access

Page 12: Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.

RSS (Really Simple Syndication) is a common XML format.

An RSS feed is composed of channels which contain items.

Page 13: Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.

Amazon Web Services (AWS) provides an XML-based communication protocol for interacting with applications over the internet.

Page 14: Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.

OWL (XML-based)Web Ontology Language

Semantic web may be the next major AI Web 2.0 breakthrough in the internet.

Semantic network is a form or knowledge representation.