1 / 48

The Fundamentals of XML and its Applications

The Fundamentals of XML and its Applications. Speaker: 呂瑞麟 朝陽科技大學資管系副教授 兼電算中心主任 Email: jlu@cyut.edu.tw URL: http://www.cyut.edu.tw/~jlu. Outline. Why XML? XML DTD XML Related Technologies Challenges References. Why XML?. Documents Reusability

orinda
Download Presentation

The Fundamentals of XML and its Applications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Fundamentals of XML and its Applications Speaker: 呂瑞麟 朝陽科技大學資管系副教授 兼電算中心主任 Email: jlu@cyut.edu.tw URL: http://www.cyut.edu.tw/~jlu

  2. Outline • Why XML? • XML • DTD • XML Related Technologies • Challenges • References

  3. Why XML? • Documents Reusability • 提高文件的重新使用性及應用程式的互通性 • IBM’s GL --> SGML • Document-based Information Systems • Documents <--> Record (in RDBMS)? • HTML is too simple and SGML is too complex

  4. Why XML? • Separation of content and layout • same data can be presented in various formats • same layout can display different data • Semantics of content • <b>170</b> cm • <height>175</height> cm

  5. XML • eXtensible Markup Language • 1996年底由 W3C 提出,1998年初正式發展XML1.0 • SGML的子集合,把其中較複雜和不常使用的部分去除,且針對網路傳輸做了最佳化設計 • 為了補足HTML不適用於發展資訊系統使用的情況下,提出的另一套“Meta-Language”

  6. XML • 一份 XML 文件分為兩個主要部分 • a prolog • provides information about the interpretation of the document instance, such as the version of XML and the document type to which it conforms. • Ex. <?xml version=“1.0”?> • a document instance • contains the actual data organized as a hierarchy of elements • Ex. <name>Eric Lu</name> (called ‘element’) • contains only one single root element

  7. XML <?xml version=“1.0”?> <person> <last>Lu</last> <first>Eric</first> </person> • XML is case sensitive. • The 1st char of tag names can be letters, _, or :. • Other chars of tag names can be letters, _, :, -, or digits. <?xml version=“1.0”?> <phonebook> <person> <name>Eric Lu</name> <number>21234567</number> </person> <person> <name>Joseph Lin</name> <number>22135678</number> </person> </phonebook>

  8. XML • 符合規定(Well-formed)的XML文件規則 • 結束標籤不可省略 • <br> (X) • <p>a paragraph</p> (O) • end of a line<br/> (O) • 不可有糾纏不清的標籤 • <i>斜體字<b>粗體字</b></i> (O) • <i>斜體字<b>粗體字</i></b> (X)

  9. XML • 符合規定(Well-formed)的XML文件規則 • 屬性一律上引號 • <td width=“100”> (O) • <td width=‘100’> (O) • <td width=100> (X) • 屬性名不可落單 • <table border=“1”> (O) • <table border> (X)

  10. XML • XML文件範例

  11. XML • EBNF • element ::= EmptyElemTag | Stag content Etag • | : or • EmptyElemTag ::= ‘<‘ Name (S Attribute)* S? ‘/>’ • ?: optional (0 or 1 time) • *: optional and repeatable (0 or more times) • +: required and repeatable (1 or more times) • S ::= (#x20 | #x9 | #xD | #xA)+ • Name, Attribute …….

  12. XML • 有效(Valid)的XML文件規則 • 符合格式的文件並不一定是有效的文件 如: <材料> <數量 單位=“盒”>1</數量> <數量 單位=“公克”>50</數量> <項目>萊姆</項目> </材料> • 用DTD來確認其正確性,才稱為有效的XML文件

  13. XML • DTD 的宣告 <!ELEMENT 食譜 (材料)*> <!ELEMENT 材料 (數量, 項目)> <!ELEMENT 數量 (#PCDATA)> <!ATTLIST 數量 單位 CDATA#REQUIRED> <!ELEMENT 項目 (#PCDATA)> <!ATTLIST 項目 選項 CDATA"0"> • Content specs: EMPTY, ANY • Attribute types (ex. CDATA) or a list of allowed values (small | medium | large) • “0”: default value

  14. XML • DTD 的宣告 <!ATTLIST 數量 單位 CDATA #REQUIRED> • Default Constraints • #REQUIRED: 必要的 • #IMPLIED: 任意的 • #FIXED: 必要的且屬性值是固定的 • Examples • <!ATTLIST 數量 單位 CDATA #IMPLIED> • <!ATTLIST 數量 單位 (Box | Kg) #IMPLIED> • <!ATTLIST 數量 單位 (Box | Kg) #REQUIRED “Box”> • <!ATTLIST 數量 size CDATA #FIXED “Large”>

  15. XML • Internal DTD declaration <?xml version=“1.0” encoding=“Big5”?> <!DOCTYPE食譜 [ <!ELEMENT 食譜 (材料)*> <!ELEMENT 材料 (數量, 項目)> …….]> <食譜>………</食譜> • External DTD declaration <?xml version=“1.0” encoding=“Big5”?> <!DOCTYPE 食譜 SYSTEM “recipe.dtd”> <食譜>………</食譜>

  16. XML • Mixed DTD declaration <?xml version=“1.0” encoding=“Big5”?> <!DOCTYPE 食譜 SYSTEM “recipe.dtd” [ <!ATTLIST 數量 單位 (box | g | dash | ml) #REQUIRED “Box”>]> <食譜>………</食譜>

  17. XML • Demo of XML Documents • IE 5.x • with/without DTD • Netscape 6 • with/without DTD • Apache’s Xalan and Xerces

  18. XML • XML 的特性 • XML是簡單的,規格不超過25頁 • 具有彈性,可創造適合自己的標記 • 具有效率及重覆使用性 • 可立即顯示於瀏覽器上 • 比 SGML 更適於發展在電子商務上 • 文件表示的格式限制較多

  19. XML • XML家族─資料呈現 • CSS (Cascading Style Sheets) 目前分為CSS1及CSS2,是一種簡單的描述語言,可利用多種排版樣式來控制網頁的內容格式,適用於HTML及XML文件。 • XSL (Extensible Stylesheet Language) 根據DSSSL和CSS發展而來,除可設定外觀式樣,還可轉換XML文件至任何格式的文件,如HTML、RTF..等。

  20. CSS XSL 可否在HTML中使用 可 否 可否在XML中使用 可 可 是否為轉換語言 否 是 所用語法 CSS XML XML • CSS及XSL比較

  21. XML • XSL範例及結果

  22. XML • XML家族─連結 • XML連結語言 (XML Linking Language, Xlink) • 提供文件連結用,除了基本超連結功能外,還提供: • 多向連結 、多目標連結,將連結的內容置入文件中、將連結內容覆置於文件中及以資料庫方式來儲存連結的位址。 • XML指標語言 (XML Pointer Language, Xpointer) • 以定址的方式來連結文件中的某個元件或某個部分,而不必事先定義它。

  23. XML • XML家族─應用程式介面(API) • DOM (Document Object Model) • 以階層式的樹狀架構來表示文件的架構,模組化的文件除了包含文件結構外,也包含物件的處理方法。

  24. XML • SAX (Simple API for XML) • 具有簡單特性的事件結構API • 視每個起始標籤及結束標籤為一個“事件” • 以連續的線性方式來排列文件中的所有“事件”,以便使用者存取 • 相較於DOM,不會產生額外的樹狀文件 • 適用於結構簡單且內容龐大的文件

  25. XML • XML家族─資料庫管理系統 • XML-QL: from database camp • also Lorel (proposed by Stanford) and YATL (from INRIA) • XQL: from document camp • “XML Query Languages: Experiences and Exemplars” published in the proceedings of QL’98. Available at http://www-db.research.bell-labs.com/user/simeon/xquery.ps

  26. XML • XML 家族─其他 • XML Schema • Namespace • WML • RDF、Dublin Core (Meta-data) • more …...

  27. HTML/XHTML • SGML application  HTML • XML application  XHTML • 由W3W 於 01/2000 制定完成 XHTML1.0 • 為什麼需要XHTML? • HTML的隱憂:愈來愈大,造成瀏覽問題 • 模組化:一個DTD負責一部分的定義 • 擴充性:視需要套用不同的DTD標準,如MathML • XML不會完全取代HTML,所以要XHTML來加強

  28. HTML/XHTML • XHTML小範例 <!DOCUTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “xhtml1-strict.dtd”> <html xmlns=“http://www.w3.org/Profiles/xhtml1-strict”> <head> <title>Virtual Library</title> </head> <body> <p>Moved to <a href=“http://www.vlib.org/”>www.vlib.org</a></p> </body> </html>

  29. Challenges • Is it a feasible solution? • Standards are not finalized YET. • Where are the tools/utilities required? • Is the network infrastructure matured?

  30. 電子商務的演變 • EDI (電子資料交換) • 磁帶 • 加值網路 (VAN) • 網際網路 (Internet) • 郵購、電視購物、網路商店

  31. 電子商務的定義 • Electronic Exchange of Data to Support Business Transaction (依據 European Workshop on Open System‘s Technical Guide 的定義) • 常見的分類︰ • B2B • B2C

  32. EDI 的主要缺點 • EDI 的導入成本過高 • 導入 EDI 後對現有系統的影響過大 • EDI 標準的制定過程過於冗長

  33. 解決方案 • Open-EDI (1996, University of Melbourne) • SGML-EDI (Joint Electronic Document Interchange) • EDML (1998, Electronic Data Markup Language) • XML-EDI (1997, The XML/EDI Group)

  34. XML/EDI 小組 • 成立於 1997 年 7 月 • 網站在 http://www.xmledi.net • 目標︰ • 期望 XML/EDI 能讓任何企業使用更聰明、更經濟、且更易於維護的電子資料交換系統與全球任一貿易夥伴進行交易。

  35. XML/EDI 的組成元件 (I) • EDI • XML (eXtensible Markup Language) • W3C Recommendation (02/1998) • 適用於結構化文件處理與 WWW • 以電子型錄為例︰ 搜尋單價介於 500 與 1000 元的產品 • <unitprice>750</unitprice>

  36. ANSI X12 與 XML Qty Part No. Description Unit Price Total 100 CO633 Fuzzy Dice $1.23 $123.00 <Item> <Quantity>100</Quantity> <PriceBase Code=“WE”/> <IDQualifier Code=“MG”/> <ID Description=“Fuzzy Dice”>CO633</ID> </Item> PO1**100*EA*1.23*WE*MG*CO633 資料來源︰Uche Ogbuji, “XML: The Future of EDI?”, SunWorld, February 1999.

  37. XML/EDI 的組成元件 (II) • Templates (處理規則) • 資料處理的邏輯與呈現方式 • 可隨資料傳送或參考標準倉儲之物件 • 相關的標準有 • XSL (eXtensible Stylesheet Language) • CSS (Cascading Style Sheet) • ECMAscript (即 JavaScript)

  38. XML/EDI 的組成元件 (III) • Agents (代理程式) • 依照 XML/EDI 處理或轉換資料 • 與現有資訊系統整合 • 相關的標準有 • DOM (Document Object Model) • SAX (Simple API for XML) • Java 或 ActiveX 元件

  39. XML/EDI 的組成元件 (IV) • Global Repository (標準倉儲) • 儲存已被業界所共同接受的 DTDs、Templates、Agents 等。 • 相關的標準有 • XMI (XML Metadata Interchange) • BSR (ISO’s Basic Semantic Repository)

  40. XML/EDI 典型架構 * 資料來源︰ David RR Webber, “Introducing XML/EDI Frameworks”, Electronic Markets, vol. 8, no. 1, 1998, pp. 38--41.

  41. XML/EDI 的特色 • 100% 與傳統 EDI 相容 • 不需標準也能進行電子交易 • 提高商業交易之接觸面 • 比傳統 EDI可節省約 50% 的成本

  42. XML/EDI 的缺點 • 訊息的大小變大︰ 約增加 200% • 安全考量

  43. XML/EDI 的發展現狀 • CEN/ISSS European XML/EDI Pilot Projects • RosettaNet 於 4/1999 完成第一階段測試 • Dell 宣佈將採用 XML 於其採購系統 • 幾乎所有電腦大廠皆投入 XML 的開發

  44. XML/EDI 面對的挑戰 • 相關的標準未完成 • 瀏覽器尚未完全支援 • 已使用 EDI 的廠商投入意願 • 網際網路的頻寬不足

  45. 其他 XML 的應用 • ERP、CALS、Workflow 等 • 其他大型專案 • ebXML • CommerceOne • Ariba cXML • Microsoft’s Biztalk • NII’s XML Repository

  46. 未來可嘗試的方向 • 提供一個像 VAN 的 WWW 伺服器 • 國內廠商 EDI 服務 • 政府機關採購窗口 • 保險業 EDI 服務 • 本國的標準倉儲

  47. 參考資料 • David RR Webber, “Introducing XML/EDI Frameworks”, Electronic Markets, vol. 8, no. 1, 1998, pp. 38--41. • The XML/EDI Group, http://www.xmledi.net. • Http://www.cyut.edu.tw/~jlu/ecrg/

  48. References • W3C at http://www.w3c.org • 陳錦輝、江鈞,“精通:從 HTML 到 XML”,文魁資訊,2000。 • Charles Goldfarb and Paul Frescod, “The XML Handbook”, Prentice Hall, 1998.

More Related