Tove   Jani   Reminder   Don't forget me this weekend! ">   Tove   Jani   Reminder   Don't forget me this weekend! ">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

2017, Fall Pusan National University Ki-Joune Li

Similar presentations


Presentation on theme: "2017, Fall Pusan National University Ki-Joune Li"— Presentation transcript:

1 2017, Fall Pusan National University Ki-Joune Li
XML 2017, Fall Pusan National University Ki-Joune Li

2 XML – Basic Concepts XML (eXtensible Markup Language
A variation of HTML (Not only presentation but also description) A standard language for contents Designed to store and transport data Self-Descriptive using Tags (like HTML) W3C standard Syntax is very similar with HTML <?xml version="1.0" encoding="UTF-8"?> <note>   <to>Tove</to>   <from>Jani</from>   <heading>Reminder</heading>   <body>Don't forget me this weekend!</body> </note>

3 XML, HTML, Databases, and Java Instances
System A Representing and Storing Data Display to Users via Web Browser Databases HTML document Conversion To HTML Conversion To DB XML document System B Exchange Data XML Serialization Instances from Java Class Objects from C++ Class

4 Nested – Tree Structure
Example <?xml version="1.0" encoding="UTF-8"?> <breakfast_menu> <food>     <name>Strawberry Belgian Waffles</name>     <price>$7.95</price>     <description>     Light Belgian waffles covered with strawberries and whipped cream     </description>     <calories>900</calories> </food> <food>     <name>French Toast</name>     <price>$4.50</price>     <description>     Thick slices made from our homemade sourdough bread     </description>     <calories>600</calories> </food> </breakfast_menu> Element Nested – Tree Structure

5 Syntax - basics Very simple and logical XML Prolog – like HTML Header
Data with Tags Must Contain one Root Element Open  Close Tag (case sensitive) May be nested No predefined tags Attribute of Elements XML Prolog – like HTML Header <note>   <date>     <year>2008</year>     <month>01</month>     <day>10</day>   </date>   <to>Tove</to>   <from>Jani</from> </note> <root>   <child>     <subchild>.....</subchild>   </child> </root> <note date="12/11/2007">   <to>Tove</to>   <from>Jani</from> </note> <?xml version="1.0" encoding="UTF-8"?>

6 Syntax - Elements Element: An XML element
everything from (including) the element's start tag to (including) the element's end tag. Contains text attributes other elements or a mix of the above <bookstore>   <book category="children">     <title>Harry Potter</title>     <author>J K. Rowling</author>     <year>2005</year>     <price>29.99</price>   </book>   <book category="web">     <title>Learning XML</title>     <author>Erik T. Ray</author>     <year>2003</year>     <price>39.95</price>   </book> </bookstore>

7 One Solution: use prefix
Name Conflicts Tags in XML – User-defined  may cause conflicts <table>   <tr>     <td>Apples</td>     <td>Bananas</td>   </tr> </table> <table>   <name>African Coffee Table</name>   <width>80</width>   <length>120</length> </table> XML XML (HTML) <h:table>   <h:tr>     <h:td>Apples</h:td>     <h:td>Bananas</h:td>   </h:tr> </h:table> <f:table>   <f:name>African Coffee Table</f:name>   <f:width>80</f:width>   <f:length>120</f:length> </f:table> One Solution: use prefix

8 Name Conflicts – Namespaces (xmlns)
When using prefixes, a namespace for the prefix must be defined. The namespace can be defined by an xmlns attribute in the start tag The namespace declaration has the following syntax. xmlns:prefix="URI". <root xmlns:h=" xmlns:f=" <h:table>   <h:tr>     <h:td>Apples</h:td>     <h:td>Bananas</h:td>   </h:tr> </h:table> <f:table>   <f:name>African Coffee Table</f:name>   <f:width>80</f:width>   <f:length>120</f:length> </f:table> </root> Another Solution: xmlns

9 XML Schema Definition of XML Structures that are frequently used
It is a XML document Like class definition <?xml version="1.0"?> <xs:schema xmlns:xs=" <xs:element name="note"> <xs:complexType>   <xs:sequence>     <xs:element name="to" type="xs:string"/>     <xs:element name="from" type="xs:string"/>     <xs:element name="heading" type="xs:string"/>     <xs:element name="body" type="xs:string"/>   </xs:sequence> </xs:complexType> </xs:element> </xs:schema> Complex Element Type Simple Element Type Instance document <?xml version="1.0"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>

10 Xlink XLink is used to create hyperlinks in XML documents
no browser support but can be converted to <a href=“…”> of HTML <?xml version="1.0" encoding="UTF-8"?> <bookstore xmlns:xlink=" <book title="Harry Potter">   <description   xlink:type="simple“ xlink:href="/images/HPotter.gif" xlink:show="new">   As his fifth year at Hogwarts School of Witchcraft and   </description> </book> <book title="XQuery Kick Start">   <description   xlink:type="simple“ xlink:href="/images/XQuery.gif" xlink:show="new">   XQuery Kick Start delivers a concise introduction   </description> </book> </bookstore>


Download ppt "2017, Fall Pusan National University Ki-Joune Li"

Similar presentations


Ads by Google