Download presentation
Presentation is loading. Please wait.
Published byEdwina O’Brien’ Modified over 8 years ago
1
XML: Extensible Markup Language Abeiku Duncan Leslie Salami Anthony Mensah-Kumah Michelle Amarteifio Joseph Owusu-Badu
2
Introduction XML has emerged as standard for structuring and exchanging data over the Web. XML emerged as a way to overcome the shortcomings of its two predecessors, SGML and HTML It’s a markup language that allows users to create customized tags Formatting for display aspects can be specified separately, for example through XSL
3
ADVANTAGES It is as easy as HTML. It is platform independent. Its very portable and can be used on handheld devices like PDA’s It can be deployed on any network if it is amicable for usage with the application in use While data is being exchanged using XML, there will be no loss of data even between systems that use totally different formats
4
XML is an extendable language, meaning that you can create your own tags, or use the tags which have already been created XML can also be stored in databases in XML format and human readable format.
5
DISADVANTAGES Lack of adequate processing applications.
6
-Generally begins with an XML declaration eg. -Syntactically follows guidelines of tree structure -Elements must have a pair of start and end tags and -The characters between the start and end tags are the elements content - API’s called DOM (Document Object Model) enable manipulation of resulting tree representation of XML document -SAX enables streamed processing of XML documents -Tags for XML can have any name Well-Formed XML Document
7
Valid XML Document The element names used in the start and end tag pairs must follow the structure specified in a separate XML DTD XML DTD (Document Type Definition) A DTD is an example of a schema or grammar.schema DTD typically indicates the constrain set of elements that may be used in a document, which attributes may be applied to them, the order in which they may appear, and the allowable parent/child relationships. A name is given to the root tag of the element, then the elements and their nested structure are specified.
8
Notations used in specifying elements in DTD (*) - means the element can be repeated zero or more times eg. (+) - means the element can be repeated one or more times eg. (?) – means an element can be repeated zero or one times eg. - An element without any of the preceding three symbols must appear exactly once in the document The element type is specified via parentheses following the element. If the name in the parenthesis is an element name, then it is a child of the outer element. If it is a data type then it is a leaf node. eg. where PCDATA means parsed character data which is similar to a string
9
XML Schema Language It is the standard for specifying the structure of XML documents It borrows concepts from database and object models such as keys, references and identifiers.
10
XML Schema concepts Schema descriptions and XML namespaces eg. Annotations, Documentation, and language used eg. Elements and types eg. Specifying element type and minimum and maximum occurrences eg. Specifying keys eg. Specifying the structures of complex elements via complex types eg.
11
XML Documents and Databases Approaches to storing xml documents Using a dbms to store documents as text Using a dbms to store document contents as data elements Designing a specialized system for storing native xml data…….(tamino by software AG, dynamic application platform of eXceleron) Customized xml documents from preexisting relational databases
12
Extracting XML Documents from Relational Databases Flat relational data model(graph model) Hierarchical model
13
course department instructor section student name ssn name class name number ssn name rank salary Qtr year number
15
Breaking cycles to convert graphs into trees student section instructor course department instructor course
16
Other steps for extracting xml documents from databases Create correct query in sql Structured from flat relational form to xml tree structure Query customized to select single objects
17
Standards for XML Querying XPath XQuery
18
XPath Returns a collection of element nodes that satisfy certain patterns specified in the expression. The name is generated from its use of a path notation for navigation through the tree-like structure of an XML document. Two main separators are used to specify a path 1.Single slash (/) 2.Double slash (//)
19
XPath Examples /school /school/library //employee[employeeSalary gt 60000]/employeeName //book/title | //book/price
20
XQuery Permits the specification of more general queries on one or more XML documents. Typical XQuery form is called FLWR expression and it stands for four main clauses; FOR LET WHERE RETURN
21
XQuery Examples FOR $x IN doc(www.school.com/info.xml)www.school.com/info.xml //employee [employeeSalary gt 40000]/employeeName RETURN $x/firstName, $x/lastName
22
XQuery Example (contd.) FOR $x IN doc(www.school.com/info.xml)/school/emplo yeewww.school.com/info.xml)/school/emplo yee WHERE $x/employeeSalary gt 40000) RETURN $x/employeeName/firstName,$x/employeeNa me/lastName
23
Reading XML PHP JAVA C #
24
PHP Tove Jani Reminder Don't forget me this weekend!
25
PHP Code getName(). " "; foreach($xml->children() as $child) { echo $child->getName(). ": ". $child. " "; } ?>
26
Output note to: Tove from: Jani heading: Reminder body: Don't forget me this weekend!
27
C # using System; using System.Xml; namespace ReadXMLfromFile { class Class1 { static void Main(string[] args) { XmlTextReader reader = new XmlTextReader ("books.xml"); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. Console.Write("<" + reader.Name); Console.WriteLine(">"); break; case XmlNodeType.Text: //Display the text in each element. Console.WriteLine (reader.Value); break; case XmlNodeType.EndElement: //Display the end of the element. Console.Write("</" + reader.Name); Console.WriteLine(">"); break; } Console.ReadLine(); }
28
Output The Autobiography of Benjamin Franklin Benjamin Franklin
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.