分布式系統(tǒng)-XMLppt課件_第1頁
分布式系統(tǒng)-XMLppt課件_第2頁
分布式系統(tǒng)-XMLppt課件_第3頁
分布式系統(tǒng)-XMLppt課件_第4頁
分布式系統(tǒng)-XMLppt課件_第5頁
已閱讀5頁,還剩241頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

1、XML,Steven Holzner, Sams Teach Yourself XML in 21 Days, Third Edition. 2003.,1,1. XML 基礎(chǔ),2,Markup Languages, Hello From HTML An HTML Document This is an HTML document! ,標(biāo)記是文檔中數(shù)據(jù)的描述和解釋,3,XML,eXtensible Markup Language 元語言,創(chuàng)建標(biāo)記語言的語言,4, Elements are nested Root element contains all others,Element (or t

2、ag) names,Example,elements,Root element,Empty element,attributes,declaration,5,More Terminology, John is a nice fellow 21 Main St. ,Opening tag,Closing tag: What is open must be closed,Nested element, child of Person,Parent of Address, Ancestor of number,“standalone” text, not useful as data,Child o

3、f Address, Descendant of Person,Content of Person,6,IE中瀏覽XML文檔,7,An XML Document Using a Style Sheet, John is a nice fellow 21 Main St. . . ,8,ch01_04.css,Person display: block; font-size:18pt; color: #0000ff; text-align:left,9,使用JavaScript抽取數(shù)據(jù), Hello From XML This is an XML document! ,10,使用JavaScri

4、pt抽取數(shù)據(jù), Retrieving data from an XML document function getData() xmldoc= document.all(firstXML).XMLDocument; nodeDoc = xmldoc.documentElement; nodeHeading = nodeDoc.firstChild; outputMessage = Heading: + nodeHeading.firstChild.nodeValue; message.innerHTML=outputMessage; ,11,使用JavaScript抽取數(shù)據(jù), Retrievi

5、ng data from an XML document ,12,使用JavaScript抽取數(shù)據(jù),13,使用Java從XML文檔中抽取數(shù)據(jù),import javax.xml.parsers.*; import org.w3c.dom.*; import java.io.*; public class ch01_06 static public void main(String argv) try DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = null; try d

6、b = dbf.newDocumentBuilder(); catch (ParserConfigurationException pce) Document doc = null; doc = db.parse(ch01_02.xml);,14,使用Java從XML文檔中抽取數(shù)據(jù),for (Node node = doc.getDocumentElement().getFirstChild(); node != null; node = node.getNextSibling() if (node instanceof Element) if (node.getNodeName().equa

7、ls(heading) StringBuffer buffer = new StringBuffer(); for (Node subnode = node.getFirstChild(); subnode != null; subnode = subnode. getNextSibling() if (subnode instanceof Text) buffer.append(subnode.getNodeValue(); System.out.println(buffer.toString(); catch (Exception e) e.printStackTrace(); ,15,使

8、用Java從XML文檔中抽取數(shù)據(jù),java ch01_06 Hello From XML,16,Well-formed XML Documents,Must have a root element Every opening tag must have matching closing tag Elements must be properly nested is a no-no An attribute name can occur at most once in an opening tag. It it occurs, It must have a value (boolean attr

9、s, like in HTML, are not allowed) The value must be quoted (with “ or ) XML processors are not supposed to try and fix ill-formed documents (unlike HTML browsers),17,Valid XML Documents, Hello From XML This is an XML document! ,18,Valid XML Document,A valid XML document is defined by the W3C as a we

10、ll-formed XML document which also conforms to the rules of a Document Type Definition (DTD) or an XML Schema/ski:m/ (XSD),19,XML應(yīng)用,XML用于存儲、傳輸、結(jié)構(gòu)化數(shù)據(jù) 純文本格式使它容易被在互聯(lián)網(wǎng)上傳輸并被不同平臺上的應(yīng)用所處理 過去5年中,已經(jīng)出現(xiàn)了上百種XML子語言,20,使用MathML 顯示4x2 5x + 6 = 0, 4 x + 6 = 0 ,21,在Amaya 瀏覽器中顯示MathML 文檔,22,XHTML,Extensible Hypertext M

11、arkup Language 更加嚴(yán)格 允許增加自己的標(biāo)記 HTML 4.01(當(dāng)前版本),23,An XHTML Document, An XHTML Page Welcome to XHTML! This is an XHTML document. Pretty cool, eh? ,24,在IE中顯示,25,An SVG Document, SVG Example ,26,練習(xí),valid XML 文檔一定是well-formed 嗎? well-formed XML 文檔一定是valid嗎?,27,編輯XML文檔,XML 編輯器 XML Spy Visual Studio XML De

12、signer XRay XML 瀏覽器 IE,Most powerful general Jumbo, CML browser,28,Jumbo,29,XML Validators,Make sure it is well formed and valid Scholarly Technology Groups validator Microsofts Visual Studio .NET,30,error.xml, Hello From XML This is an XML document! ,31,32,XML validation in Visual Studio .NET,33,建立

13、一個完整的XML文檔, Hello From XML This is an XML document! ,34,XML 文檔,Prologs XML declarations Processing instructions Elements and attributes Comments CDATA sections Entities,35,字符編碼問題,ASCII僅有256個字符 Chinese, Armenian, Hebrew, Thai, Tibetan 從數(shù)量上、通用上,ASCII不能在Web上使用 Unicode (), 65,536 個字

14、符 前256個對應(yīng)ASCII 但讓所有的軟件轉(zhuǎn)去支持Unicode太困難 UCS Transformation Format-8 (UTF-8),36,UTF-8,所有ASCII字符的編碼保持不變(8bit) 其它Unicode字符使用2字節(jié),直至6字節(jié)編碼 W3C requires all XML processors to support both UTF-8, UTF-16 大部分支持UTF-8,37,字符實體引用, Hello From XML This text is inside a element. ,38,字符實體引用,39,字符實體引用, Replaced with ,40,

15、實體,實體是一大段文本的別名 假如你為你的信件署名定義了一個實體lettersign,它代表下面這一大段文本: 張三 某網(wǎng)絡(luò)公司銷售部門 北京市海淀區(qū)中關(guān)村88號,100000,41,實體,郵件 收件人李四/收件人 主題hello/主題 正文晚上吃飯! overshadows old default,Redeclaration of cde; overshadows old declaration,54,Namespaces (續(xù)),xmlns=“ 并不意味著此URL上有一個文檔,這種格式僅僅是個約定俗成。 一個namespace 僅僅是個標(biāo)識符 一些前綴已經(jīng)成為 標(biāo)準(zhǔn)。 E.g., xsd

16、for /2001/XMLSchema xsl for /1999/XSL/Transform Etc.,55,Valid XML Schemas supports 44+ datatypes,121,XML Schemas特性,增強的數(shù)據(jù)類型 44+ versus 10 Can create your own datatypes Example: This is a new type based on the string type and elements of this type must follow this patte

17、rn: ddd-dddd, where d represents a digit. 與實例文檔的語法相同 less syntax to remember 面向?qū)ο?Can extend or restrict a type (derive new type definitions on the basis of old ones) 可以表達集合, i.e., can define the child elements to occur in any order ,122,BookStore.dtd, ,123,ATTLIST,ELEMENT,ID,#PCDATA,NMTOKEN,ENTITY,CDATA,BookStore,Book,Title,Author,Date,ISBN,Publisher,This is the vocabulary that DTDs provide to define your new vocabulary,124,element,complexType,schema,sequence,http:/www

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論