the fundamentals of xml and its applications

48
The Fundamentals of XML and its Applications Speaker: 呂呂呂 朝朝朝朝朝朝朝朝朝朝朝朝 朝朝朝朝朝朝朝 Email: [email protected] URL: http://www.cyut.edu.tw/~ jlu

Upload: orinda

Post on 12-Jan-2016

48 views

Category:

Documents


0 download

DESCRIPTION

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

TRANSCRIPT

Page 1: The Fundamentals of  XML and its Applications

The Fundamentals of XML and its Applications

Speaker: 呂瑞麟 朝陽科技大學資管系副教授 兼電算中心主任

Email: [email protected]: http://www.cyut.edu.tw/~jlu

Page 2: The Fundamentals of  XML and its Applications

Outline

Why XML? XML DTD XML Related Technologies Challenges References

Page 3: The Fundamentals of  XML and its Applications

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

Page 4: The Fundamentals of  XML and its Applications

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

Page 5: The Fundamentals of  XML and its Applications

XML

eXtensible Markup Language 1996 年底由 W3C 提出, 1998 年初正式發展 XML

1.0 SGML 的子集合,把其中較複雜和不常使用的部分

去除,且針對網路傳輸做了最佳化設計 為了補足 HTML 不適用於發展資訊系統使用的情況

下,提出的另一套“ Meta-Language”

Page 6: The Fundamentals of  XML and its Applications

XML 一份 XML 文件分為兩個主要部分

a prolog provides information about the interpretation of the document inst

ance, 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

Page 7: The Fundamentals of  XML and its Applications

XML

<?xml version=“1.0”?> <person> <last>Lu</last> <first>Eric</first></person> XML is case sensitive. The 1st char of tag na

mes 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>

Page 8: The Fundamentals of  XML and its Applications

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)

Page 9: The Fundamentals of  XML and its Applications

XML 符合規定 (Well-formed) 的 XML 文件規則

屬性一律上引號 <td width=“100”> (O) <td width=‘100’> (O) <td width=100> (X)

屬性名不可落單 <table border=“1”> (O) <table border> (X)

Page 10: The Fundamentals of  XML and its Applications

XML XML 文件範例

Page 11: The Fundamentals of  XML and its Applications

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 …….

Page 12: The Fundamentals of  XML and its Applications

XML 有效 (Valid) 的 XML 文件規則

符合格式的文件並不一定是有效的文件如: < 材料 >

< 數量 單位 =“ 盒” >1</ 數量 > < 數量 單位 =“ 公克” >50</ 數量>

< 項目 > 萊姆 </ 項目 ></ 材料 >

用 DTD 來確認其正確性,才稱為有效的 XML 文件

Page 13: The Fundamentals of  XML and its Applications

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

Page 14: The Fundamentals of  XML and its Applications

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”>

Page 15: The Fundamentals of  XML and its Applications

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”>< 食譜 >………</ 食譜 >

Page 16: The Fundamentals of  XML and its Applications

XML Mixed DTD declaration

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

< 食譜 >………</ 食譜 >

Page 17: The Fundamentals of  XML and its Applications

XML Demo of XML Documents

IE 5.x with/without DTD

Netscape 6 with/without DTD

Apache’s Xalan and Xerces

Page 18: The Fundamentals of  XML and its Applications

XML XML 的特性

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

Page 19: The Fundamentals of  XML and its Applications

XML

XML家族─資料呈現 CSS (Cascading Style Sheets)

目前分為 CSS1 及 CSS2 ,是一種簡單的描述語言,可利用多種排版樣式來控制網頁的內容格式,適用於HTML 及 XML 文件。

XSL (Extensible Stylesheet Language)根據 DSSSL 和 CSS 發展而來,除可設定外觀式樣,還可轉換 XML 文件至任何格式的文件,如 HTML、 RTF..等。

Page 20: The Fundamentals of  XML and its Applications

XML CSS 及 XSL比較

  CSS XSL

可否在 HTML 中使用 可 否

可否在 XML 中使用 可 可

是否為轉換語言 否 是

所用語法 CSS XML

Page 21: The Fundamentals of  XML and its Applications

XML XSL 範例及結果

Page 22: The Fundamentals of  XML and its Applications

XML XML家族─連結

XML連結語言 (XML Linking Language, Xlink) 提供文件連結用,除了基本超連結功能外,還提供: 多向連結 、多目標連結,將連結的內容置入文件中、將連結內容覆置於文件中及以資料庫方式來儲存連結的位址。

XML指標語言 (XML Pointer Language, Xpointer) 以定址的方式來連結文件中的某個元件或某個部分,而

不必事先定義它。

Page 23: The Fundamentals of  XML and its Applications

XML XML家族─應用程式介面 (API)

DOM (Document Object Model) 以階層式的樹狀架構來表示文件的架構,模組化的文

件除了包含文件結構外,也包含物件的處理方法。

Page 24: The Fundamentals of  XML and its Applications

XML SAX (Simple API for XML)

具有簡單特性的事件結構 API 視每個起始標籤及結束標籤為一個“事件” 以連續的線性方式來排列文件中的所有“事件”,以便使用者存取

相較於 DOM ,不會產生額外的樹狀文件 適用於結構簡單且內容龐大的文件

Page 25: The Fundamentals of  XML and its Applications

XML XML家族─資料庫管理系統

XML-QL: from database camp also Lorel (proposed by Stanford) and YATL (from I

NRIA) XQL: from document camp “XML Query Languages: Experiences and Exe

mplars” published in the proceedings of QL’98. Available at http://www-db.research.bell-labs.com/user/simeon/xquery.ps

Page 26: The Fundamentals of  XML and its Applications

XML XML 家族─其他

XML Schema Namespace WML RDF、 Dublin Core (Meta-data) more …...

Page 27: The Fundamentals of  XML and its Applications

HTML/XHTML SGML application HTML XML application XHTML 由 W3W 於 01/2000 制定完成 XHTML1.0 為什麼需要 XHTML?

HTML 的隱憂:愈來愈大,造成瀏覽問題 模組化:一個 DTD負責一部分的定義 擴充性:視需要套用不同的 DTD 標準,如 MathM

L XML 不會完全取代 HTML ,所以要 XHTML 來加強

Page 28: The Fundamentals of  XML and its Applications

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>

Page 29: The Fundamentals of  XML and its Applications

Challenges

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

Page 30: The Fundamentals of  XML and its Applications

電子商務的演變 EDI ( 電子資料交換 )

磁帶 加值網路 (VAN) 網際網路 (Internet)

郵購、電視購物、網路商店

Page 31: The Fundamentals of  XML and its Applications

電子商務的定義 Electronic Exchange of Data to Suppo

rt Business Transaction ( 依據 European Workshop on Open System‘s Technical Guide 的定義 )

常見的分類︰ B2B B2C

Page 32: The Fundamentals of  XML and its Applications

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

Page 33: The Fundamentals of  XML and its Applications

解決方案 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)

Page 34: The Fundamentals of  XML and its Applications

XML/EDI 小組 成立於 1997 年 7 月 網站在 http://www.xmledi.net 目標︰

期望 XML/EDI 能讓任何企業使用更聰明、更經濟、且更易於維護的電子資料交換系統與全球任一貿易夥伴進行交易。

Page 35: The Fundamentals of  XML and its Applications

XML/EDI 的組成元件 (I) EDI XML (eXtensible Markup Language)

W3C Recommendation (02/1998) 適用於結構化文件處理與 WWW 以電子型錄為例︰ 搜尋單價介於 500 與

1000 元的產品 <unitprice>750</unitprice>

Page 36: The Fundamentals of  XML and its Applications

ANSI X12 與 XMLQty Part No. Description Unit Price Total

100 CO633 Fuzzy Dice $1.23 $123.00

PO1**100*EA*1.23*WE*MG*CO633

<Item>

<Quantity>100</Quantity>

<PriceBase Code=“WE”/>

<IDQualifier Code=“MG”/>

<ID Description=“Fuzzy Dice”>CO633</ID>

</Item>

資料來源︰ Uche Ogbuji, “XML: The Future of EDI?”, SunWorld, February 1999.

Page 37: The Fundamentals of  XML and its Applications

XML/EDI 的組成元件 (II) Templates ( 處理規則 )

資料處理的邏輯與呈現方式 可隨資料傳送或參考標準倉儲之物件 相關的標準有

XSL (eXtensible Stylesheet Language) CSS (Cascading Style Sheet) ECMAscript ( 即 JavaScript)

Page 38: The Fundamentals of  XML and its Applications

XML/EDI 的組成元件 (III) Agents ( 代理程式 )

依照 XML/EDI 處理或轉換資料 與現有資訊系統整合 相關的標準有

DOM (Document Object Model) SAX (Simple API for XML) Java 或 ActiveX 元件

Page 39: The Fundamentals of  XML and its Applications

XML/EDI 的組成元件 (IV) Global Repository ( 標準倉儲 )

儲存已被業界所共同接受的 DTDs 、 Templates 、 Agents 等。

相關的標準有 XMI (XML Metadata Interchange) BSR (ISO’s Basic Semantic Repository)

Page 40: The Fundamentals of  XML and its Applications

XML/EDI 典型架構

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

Page 41: The Fundamentals of  XML and its Applications

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

Page 42: The Fundamentals of  XML and its Applications

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

Page 43: The Fundamentals of  XML and its Applications

XML/EDI 的發展現狀 CEN/ISSS European XML/EDI Pilot Pro

jects RosettaNet 於 4/1999 完成第一階段測試

Dell 宣佈將採用 XML 於其採購系統 幾乎所有電腦大廠皆投入 XML 的開發

Page 44: The Fundamentals of  XML and its Applications

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

Page 45: The Fundamentals of  XML and its Applications

其他 XML 的應用 ERP 、 CALS 、 Workflow 等 其他大型專案

ebXML CommerceOne Ariba cXML Microsoft’s Biztalk NII’s XML Repository

Page 46: The Fundamentals of  XML and its Applications

未來可嘗試的方向 提供一個像 VAN 的 WWW 伺服器

國內廠商 EDI 服務 政府機關採購窗口 保險業 EDI 服務

本國的標準倉儲

Page 47: The Fundamentals of  XML and its Applications

參考資料 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/

Page 48: The Fundamentals of  XML and its Applications

References

W3C at http://www.w3c.org 陳錦輝、江鈞,“精通:從 HTML 到 XML

” ,文魁資訊, 2000。 Charles Goldfarb and Paul Frescod, “The

XML Handbook”, Prentice Hall, 1998.