Your SlideShare is downloading. ×
0
XML Introduction XML http://yht4ever.blogspot.com [email_address] B070066 - NIIT Quang Trung 07/2007
Contents Exercises Application of XML Introduction to XML Why Is XML Important?  Markup languages
Markup languages <ul><li>A markup language must specify  </li></ul><ul><ul><li>What markup is allowed  </li></ul></ul><ul>...
SGML(ISO 8879) <ul><li>S tandard  G eneralized  M arkup  L anguage </li></ul><ul><li>The international standard for defini...
HTML(RFC 1866) <ul><li>H yper T ext  M arkup  L anguage </li></ul><ul><li>A small SGML application used on web (a DTD and ...
What Is XML?   <ul><li>e X tensible  M arkup  L anguage </li></ul><ul><li>A simplified version of SGML </li></ul><ul><li>M...
Difference between XML and HTML <ul><li>XML was designed to carry data, not displaying data </li></ul><ul><li>XML is not a...
An example of XML <ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><products> </li></ul><ul><li><product id=&quot...
Contents Exercises Application of XML Introduction to XML Why Is XML Important?  Markup languages
Why Is XML Important?  <ul><li>Plain Text  </li></ul><ul><ul><li>Easy to edit </li></ul></ul><ul><ul><li>Platform independ...
Why Is XML Important?  <ul><li>Stylability </li></ul><ul><ul><li>Inherently style-free  </li></ul></ul><ul><ul><li>XSL---E...
Why is XML important? <ul><li>Linkability -- XLink and XPointer </li></ul><ul><ul><li>Simple unidirectional hyperlinks  </...
Contents Exercises Application of XML Introduction to XML Why Is XML Important?  Markup languages
XML Building blocks <ul><li>PI (Processing Instruction) </li></ul><ul><li>Tags </li></ul><ul><li>Elements </li></ul><ul><l...
XML Building blocks--Prolog <ul><li>The part of an XML document that precedes the XML data </li></ul><ul><li>Includes </li...
Tags <ul><li>Tags  are used to specify a name for a given piece of information. </li></ul><ul><li>A tag consists of openin...
Elements <ul><li>Elements are represented using tags. </li></ul><ul><li>An XML document  must always  have a  root element...
Elements <ul><li>XML Elements are Extensible  </li></ul><ul><li>XML documents can be extended to carry more information </...
Content <ul><li>Content  refers to the information represented by the elements of an XML document. </li></ul><ul><ul><li>C...
Attributes <ul><li>Located in the start tag of elements </li></ul><ul><li>Provide additional information about elements </...
Entities <ul><li>An  entity  is a name that is associated with a block of data.. </li></ul><ul><ul><li>Internal Entities: ...
Comments <ul><li>Comments  are statements used to explain the XML code. </li></ul><ul><li>Example </li></ul><ul><ul><li><!...
XML Syntax <ul><li>All XML elements must have a closing tag  </li></ul><ul><li>XML tags are case sensitive </li></ul><ul><...
Anatomy of an element <p type=&quot;rule&quot;>Use a hyphen: ­.</p> Start-tag Content End-tag Element Element type Attribu...
XML Validation <ul><li>&quot;Well Formed&quot; XML document </li></ul><ul><li>-- correct XML syntax </li></ul><ul><li>&quo...
Displaying XML <ul><li>XML documents do not carry information about how to display the data </li></ul><ul><li>We can add d...
Contents Exercises Application of XML Introduction to XML Why Is XML Important?  Markup languages
XML Application1—Separate data <ul><li>XML can Separate Data from HTML </li></ul><ul><li>Store data in separate XML files ...
XML Application2—Exchange data <ul><li>XML is used to Exchange Data </li></ul><ul><li>Text format </li></ul><ul><li>Softwa...
XML Application3—Store Data <ul><li>XML can be used to Store Data  </li></ul><ul><li>Plain text file </li></ul><ul><li>Sto...
XML Application4—Create new language <ul><li>XML can be used to Create new Languages  </li></ul><ul><li>WML (Wireless Mark...
XML support in IE 5.0+ <ul><li>Internet Explorer 5.0 has the following XML support: </li></ul><ul><li>Viewing of XML docum...
Microsoft XML Parser <ul><li>Comes with IE 5.0 </li></ul><ul><li>The parser features a language-neutral programming model ...
Java APIs for XML <ul><li>JAXP: Java API for XML Processing  </li></ul><ul><li>JAXB: Java Architecture for XML Binding  </...
<ul><li>XML is a self-descriptive language </li></ul><ul><li>XML is a powerful language to describe structure data for web...
Reference <ul><li>http://www.w3.org </li></ul><ul><li>Teach Yourself XML in 21 Days, 3 rd  Edition </li></ul><ul><li>Learn...
Q&A <ul><li>Feel free to post questions at  http://yht4ever.blogspot.com . </li></ul><ul><li>or email to:  [email_address]...
http://yht4ever.blogspot.com Thank You !
Upcoming SlideShare
Loading in...5
×

Introduction to XML

4,583

Published on

Published in: Technology, News & Politics
0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,583
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
658
Comments
0
Likes
9
Embeds 0
No embeds

No notes for slide
  • Transcript of "Introduction to XML"

    1. 1. XML Introduction XML http://yht4ever.blogspot.com [email_address] B070066 - NIIT Quang Trung 07/2007
    2. 2. Contents Exercises Application of XML Introduction to XML Why Is XML Important? Markup languages
    3. 3. Markup languages <ul><li>A markup language must specify </li></ul><ul><ul><li>What markup is allowed </li></ul></ul><ul><ul><li>What markup is required </li></ul></ul><ul><ul><li>How markup is to be distinguished from text </li></ul></ul><ul><ul><li>What the markup means </li></ul></ul><ul><li>XML only specify the first three, the fourth is specified by DTD </li></ul>
    4. 4. SGML(ISO 8879) <ul><li>S tandard G eneralized M arkup L anguage </li></ul><ul><li>The international standard for defining descriptions of structure and content in text documents </li></ul><ul><li>Interchangeable: device-independent, system-independent </li></ul><ul><li>Tags are not predefined </li></ul><ul><li>Using DTD to validate the structure of the document </li></ul><ul><li>Large, powerful, and very complex </li></ul><ul><li>Heavily used in industrial and commercial for over a decade </li></ul>
    5. 5. HTML(RFC 1866) <ul><li>H yper T ext M arkup L anguage </li></ul><ul><li>A small SGML application used on web (a DTD and a set of processing conventions) </li></ul><ul><li>Can only use a predefined set of tags </li></ul>
    6. 6. What Is XML? <ul><li>e X tensible M arkup L anguage </li></ul><ul><li>A simplified version of SGML </li></ul><ul><li>Maintains the most useful parts of SGML </li></ul><ul><li>Designed so that SGML can be delivered over the Web </li></ul><ul><li>XHTML -- a reformulation of HTML 4 in XML 1.0 </li></ul>
    7. 7. Difference between XML and HTML <ul><li>XML was designed to carry data, not displaying data </li></ul><ul><li>XML is not a replacement for HTML. </li></ul><ul><li>Different goals: </li></ul><ul><li>XML was designed to describe data and to focus on what data is . HTML was designed to display data and to focus on how data looks . </li></ul><ul><li>HTML is about displaying information, XML is about describing information. </li></ul>
    8. 8. An example of XML <ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><products> </li></ul><ul><li><product id=&quot;PRO001&quot;> </li></ul><ul><li><name>Coca Cola</name> </li></ul><ul><li><price>5000</price> </li></ul><ul><li></product> </li></ul><ul><li><product id=&quot;PRO002&quot;> </li></ul><ul><li><name>Pepsi</name> </li></ul><ul><li><price>4500</price> </li></ul><ul><li></product> </li></ul><ul><li><product id=&quot;PRO003&quot;> </li></ul><ul><li><name>Number One</name> </li></ul><ul><li><price>5500</price> </li></ul><ul><li></product> </li></ul><ul><li></products> </li></ul>
    9. 9. Contents Exercises Application of XML Introduction to XML Why Is XML Important? Markup languages
    10. 10. Why Is XML Important? <ul><li>Plain Text </li></ul><ul><ul><li>Easy to edit </li></ul></ul><ul><ul><li>Platform independent </li></ul></ul><ul><li>Data Identification </li></ul><ul><ul><li>Tell you what kind of data you have </li></ul></ul><ul><ul><li>Can be used in different ways by different applications </li></ul></ul><ul><li>Easily Processed </li></ul><ul><ul><li>Vendor-neutral standard </li></ul></ul>
    11. 11. Why Is XML Important? <ul><li>Stylability </li></ul><ul><ul><li>Inherently style-free </li></ul></ul><ul><ul><li>XSL---Extensible Stylesheet Language </li></ul></ul><ul><ul><li>Different XSL formats can then be used to display the same data in different ways </li></ul></ul><ul><li>Inline Reusability </li></ul><ul><ul><li>Can be composed from separate entities </li></ul></ul><ul><ul><li>Modularize your documents </li></ul></ul>
    12. 12. Why is XML important? <ul><li>Linkability -- XLink and XPointer </li></ul><ul><ul><li>Simple unidirectional hyperlinks </li></ul></ul><ul><ul><li>Two-way links </li></ul></ul><ul><ul><li>Multiple-target links </li></ul></ul><ul><ul><li>“ Expanding” links </li></ul></ul><ul><li>Hierarchical </li></ul><ul><ul><li>Faster to access </li></ul></ul><ul><ul><li>Easier to rearrange </li></ul></ul>
    13. 13. Contents Exercises Application of XML Introduction to XML Why Is XML Important? Markup languages
    14. 14. XML Building blocks <ul><li>PI (Processing Instruction) </li></ul><ul><li>Tags </li></ul><ul><li>Elements </li></ul><ul><li>Content </li></ul><ul><li>Attributes </li></ul><ul><li>Entities </li></ul><ul><li>Comments </li></ul>
    15. 15. XML Building blocks--Prolog <ul><li>The part of an XML document that precedes the XML data </li></ul><ul><li>Includes </li></ul><ul><li>A declaration: version [, encoding, standalone] </li></ul><ul><li>An optional DTD (Document Type Definition ) </li></ul><ul><li>Example </li></ul><ul><li><?xml version=“1.0” encoding=“UTF-8” standalone=“yes”?> </li></ul>
    16. 16. Tags <ul><li>Tags are used to specify a name for a given piece of information. </li></ul><ul><li>A tag consists of opening and closing angular brackets (<>) that enclose the name of the tag. </li></ul><ul><li>Example </li></ul><ul><li><EMP_NAME>Nick Shaw</EMP_NAME> </li></ul>
    17. 17. Elements <ul><li>Elements are represented using tags. </li></ul><ul><li>An XML document must always have a root element . </li></ul><ul><li>General format: </li></ul><ul><li><element> … </element> </li></ul><ul><li>Empty element: </li></ul><ul><li><empty-Element /> </li></ul><ul><li>Example </li></ul><ul><li><Authorname>John Smith</Authorname> </li></ul>
    18. 18. Elements <ul><li>XML Elements are Extensible </li></ul><ul><li>XML documents can be extended to carry more information </li></ul><ul><li>XML Elements have Relationships </li></ul><ul><li>Elements are related as parents and children </li></ul><ul><li>Elements have Content </li></ul><ul><li>Elements can have different content types: element content, mixed content, simple content, or empty content and attributes </li></ul><ul><li>XML elements must follow the naming rules </li></ul>
    19. 19. Content <ul><li>Content refers to the information represented by the elements of an XML document. </li></ul><ul><ul><li>Character or data content </li></ul></ul><ul><ul><li>Element content </li></ul></ul><ul><ul><li>Combination or mixed content </li></ul></ul><ul><li>Example </li></ul><ul><li><BOOKNAME>The Painted House</BOOKNAME> </li></ul>
    20. 20. Attributes <ul><li>Located in the start tag of elements </li></ul><ul><li>Provide additional information about elements </li></ul><ul><li>Often provide information that is not a part of data </li></ul><ul><li>Must be enclosed in quotes </li></ul><ul><li>Should I use an element or an attribute? </li></ul><ul><li>metadata (data about data) should be stored as attributes, and that data itself should be stored as elements </li></ul>
    21. 21. Entities <ul><li>An entity is a name that is associated with a block of data.. </li></ul><ul><ul><li>Internal Entities: &lt; , &gt;… </li></ul></ul><ul><ul><li>General Entities </li></ul></ul><ul><ul><ul><li>General entities are declared in Document Type Definitions (DTD) </li></ul></ul></ul><ul><ul><ul><li>Example </li></ul></ul></ul><ul><ul><ul><ul><li><! ENTITY nyt &quot;The Times of India.&quot;> </li></ul></ul></ul></ul><ul><ul><ul><ul><li>For more information, please visit &nyt; Thank you! </li></ul></ul></ul></ul><ul><ul><li>Parameter Entities </li></ul></ul><ul><ul><ul><li>Are only declared and used in DTDs </li></ul></ul></ul><ul><ul><ul><ul><li><!ENTITY % bool (&quot;yes | no&quot;)> </li></ul></ul></ul></ul><ul><ul><ul><ul><li><ATTLIST membership (%bool;)> </li></ul></ul></ul></ul>
    22. 22. Comments <ul><li>Comments are statements used to explain the XML code. </li></ul><ul><li>Example </li></ul><ul><ul><li><!--PRODUCTDATA is the root element--> </li></ul></ul><ul><li>The text contained within a comment entry cannot have two consecutive hyphens </li></ul><ul><ul><li><!--PRODUCTDATA is the –-root element--> </li></ul></ul>
    23. 23. XML Syntax <ul><li>All XML elements must have a closing tag </li></ul><ul><li>XML tags are case sensitive </li></ul><ul><li>All XML elements must be properly nested </li></ul><ul><li>All XML documents must have a root tag </li></ul><ul><li>Attribute values must always be quoted </li></ul><ul><li>With XML, white space is preserved </li></ul><ul><li>With XML, a new line is always stored as LF </li></ul>
    24. 24. Anatomy of an element <p type=&quot;rule&quot;>Use a hyphen: ­.</p> Start-tag Content End-tag Element Element type Attribute name Attribute value (character) entity reference Element type Attribute
    25. 25. XML Validation <ul><li>&quot;Well Formed&quot; XML document </li></ul><ul><li>-- correct XML syntax </li></ul><ul><li>&quot;Valid&quot; XML document </li></ul><ul><ul><li>“ well formed” </li></ul></ul><ul><ul><li>Conforms to the rules of a DTD (Document Type Definition) </li></ul></ul><ul><li>XML DTD </li></ul><ul><ul><li>defines the legal building blocks of an XML document </li></ul></ul><ul><ul><li>Can be inline in XML or as an external reference </li></ul></ul><ul><li>XML Schema </li></ul><ul><ul><li>an XML based alternative to DTD, more powerful </li></ul></ul><ul><ul><li>Support namespace and data types </li></ul></ul>
    26. 26. Displaying XML <ul><li>XML documents do not carry information about how to display the data </li></ul><ul><li>We can add display information to XML with </li></ul><ul><ul><li>CSS (Cascading Style Sheets) </li></ul></ul><ul><ul><li>XSL (eXtensible Stylesheet Language) --- preferred </li></ul></ul>
    27. 27. Contents Exercises Application of XML Introduction to XML Why Is XML Important? Markup languages
    28. 28. XML Application1—Separate data <ul><li>XML can Separate Data from HTML </li></ul><ul><li>Store data in separate XML files </li></ul><ul><li>Using HTML for layout and display </li></ul><ul><li>Using Data Islands </li></ul><ul><li>Data Islands can be bound to HTML elements </li></ul><ul><li>Benefits: </li></ul><ul><li>Changes in the underlying data will not require any changes to your HTML </li></ul>
    29. 29. XML Application2—Exchange data <ul><li>XML is used to Exchange Data </li></ul><ul><li>Text format </li></ul><ul><li>Software-independent, hardware-independent </li></ul><ul><li>Exchange data between incompatible systems, given that they agree on the same tag definition. </li></ul><ul><li>Can be read by many different types of applications </li></ul><ul><li>Benefits: </li></ul><ul><li>Reduce the complexity of interpreting data </li></ul><ul><li>Easier to expand and upgrade a system </li></ul>
    30. 30. XML Application3—Store Data <ul><li>XML can be used to Store Data </li></ul><ul><li>Plain text file </li></ul><ul><li>Store data in files or databases </li></ul><ul><li>Application can be written to store and retrieve information from the store </li></ul><ul><li>Other clients and applications can access your XML files as data sources </li></ul><ul><li>Benefits: </li></ul><ul><li>Accessible to more applications </li></ul>
    31. 31. XML Application4—Create new language <ul><li>XML can be used to Create new Languages </li></ul><ul><li>WML (Wireless Markup Language) used to markup Internet applications for handheld devices like mobile phones (WAP) </li></ul><ul><li>MusicXML used to publishing musical scores </li></ul><ul><li>RSS. </li></ul><ul><li>MathML. </li></ul>
    32. 32. XML support in IE 5.0+ <ul><li>Internet Explorer 5.0 has the following XML support: </li></ul><ul><li>Viewing of XML documents </li></ul><ul><li>Full support for W3C DTD standards </li></ul><ul><li>XML embedded in HTML as Data Islands </li></ul><ul><li>Binding XML data to HTML elements </li></ul><ul><li>Transforming and displaying XML with XSL </li></ul><ul><li>Displaying XML with CSS </li></ul><ul><li>Access to the XML DOM (Document Object Model) </li></ul><ul><li>*Netscape 6.0 also have full XML support </li></ul>
    33. 33. Microsoft XML Parser <ul><li>Comes with IE 5.0 </li></ul><ul><li>The parser features a language-neutral programming model that supports: </li></ul><ul><ul><li>JavaScript, VBScript, Perl, VB, Java, C++ and more </li></ul></ul><ul><ul><li>W3C XML 1.0 and XML DOM </li></ul></ul><ul><ul><li>DTD and validation </li></ul></ul>
    34. 34. Java APIs for XML <ul><li>JAXP: Java API for XML Processing </li></ul><ul><li>JAXB: Java Architecture for XML Binding </li></ul><ul><li>JDOM: Java DOM </li></ul><ul><li>DOM4J: an alternative to JDOM </li></ul><ul><li>JAXM: Java API for XML Messaging (asynchronous) </li></ul><ul><li>JAX-RPC: Java API for XML-based Remote Process Communications (synchronous) </li></ul><ul><li>JAXR: Java API for XML Registries </li></ul>
    35. 35. <ul><li>XML is a self-descriptive language </li></ul><ul><li>XML is a powerful language to describe structure data for web application </li></ul><ul><li>XML is currently applied in many fields </li></ul><ul><li>Many vendors already supports or will support XML </li></ul>Conclusion
    36. 36. Reference <ul><li>http://www.w3.org </li></ul><ul><li>Teach Yourself XML in 21 Days, 3 rd Edition </li></ul><ul><li>Learning XML, 2 nd Edition </li></ul><ul><li>Hongming Yu presentation. </li></ul><ul><li>XML tutorial http://www.w3schools.com/w3c/ </li></ul>
    37. 37. Q&A <ul><li>Feel free to post questions at http://yht4ever.blogspot.com . </li></ul><ul><li>or email to: [email_address] or [email_address] </li></ul>
    38. 38. http://yht4ever.blogspot.com Thank You !
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×