可扩展标记语言,标准通用标记语言的子集,是一种用于标记电子文件使其具有结构性的标记语言。它可以用来标记数据、定义数据类型,是一种允许用户对自己的标记语言进行定义的源语言。 它非常适合万维网传输,提供统一的方法来描述和交换独立于应用程序或供应商的结构化数据。是Internet环境中跨平台的、依赖于内容的技术,也是当今处理分布式结构信息的有效工具。早在1998年,W3C就发布了XML1.0规范,使用它来简化Internet的文档信息传输。

注脚

展开查看详情

1.Chapter 12 6e Outline Structured, Semistructured,Unstruct Data XML Hierarchical (Tree) Data Model XML Documents and XML Schema Storing and Extracting XML Documents from Databases XML Languages Extracting XML Documents from Relational Databases XML Usage in Biomedical Informatics

2.What is XML? Standards and Usage of XML XML Used in Myriad of Context Modeling and Information Exchange (XML Schemas and Instances) Other XML Standards XACML – Access Control Markup Language OWL – Web Ontology Language HL7/CDA

3.What is XML? eXtensible Markup Language HTML on Steroids! Markup Language for Storing and Transporting Data Self-Descriptive Language Send/Receive/Store/Display Tutorial: http:// www.w3schools.com/xml/default.asp

4.XML Example

5.What is XML? Not HTML! XML was designed to carry data - with focus on what data is HTML was designed to display data - with focus on how data looks XML tags are not predefined like HTML tags are Common Standard to Exchange Info

6.Sample XML – Original Style – parts.xml

7.Sample XML – Original Style – parts.dtd

8.Sample XML Original– xmlpartstype.xml

9.Sample XML – Current – XML Schema < 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 >

10.Sample XML – XML Instance < 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 >

11.Sample XML - Schema < ?xml  version ="1.0"  encoding ="UTF-8"  ? > < xs:schema   xmlns:xs ="http://www.w3.org/2001/XMLSchema"> < xs:element  name =" shiporder ">    < xs:complexType >      < xs:sequence >        < xs:element  name =" orderperson "  type =" xs:string " / >        < xs:element  name =" shipto ">          < xs:complexType >            < xs:sequence >              < xs:element  name ="name"  type =" xs:string " / >              < xs:element  name ="address"  type =" xs:string " / >              < xs:element  name ="city"  type =" xs:string " / >              < xs:element  name ="country"  type =" xs:string " / >            < / xs:sequence >          < / xs:complexType >        < / xs:element >       

12.Sample XML - Schema        < xs:element  name ="item"   maxOccurs ="unbounded">          < xs:complexType >            < xs:sequence >              < xs:element  name ="title"  type =" xs:string " / >              < xs:element  name ="note"  type =" xs:string "  minOccurs ="0" / >              < xs:element  name ="quantity"  type =" xs:positiveInteger " / >              < xs:element  name ="price"  type =" xs:decimal " / >            < / xs:sequence >          < / xs:complexType >        < / xs:element >      < / xs:sequence >      < xs:attribute  name =" orderid "  type =" xs:string "  use ="required" / >    < / xs:complexType > < / xs:element > < / xs:schema >

13.Sample XML – Instance < ?xml  version ="1.0"  encoding ="UTF-8" ? > < shiporder   orderid ="889923" xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation ="shiporder.xsd">    < orderperson > John Smith < / orderperson >    < shipto >      < name > Ola Nordmann < /name >      < address > Langgt 23 < /address >      < city > 4000 Stavanger < /city >      < country > Norway < /country >    < / shipto >    < item >      < title > Empire Burlesque < /title >      < note > Special Edition < /note >      < quantity > 1 < /quantity >      < price > 10.90 < /price >    < /item >    < item >      < title > Hide your heart < /title >      < quantity > 1 < /quantity >      < price > 9.90 < /price >    < /item > < / shiporder >

14.Sample XML – XML to Relational

15.Usages of XML Data sources Database storing data for Internet applications Utilized to Store Information for Other Apps Emerging Standards across Domains Hypertext documents Common method of specifying contents and formatting of Web pages XML data model

16.Promotes Structured Data XML Schema Defines Structure Akin to Class or Relational table Labels or tags on directed edges represent: Schema names Names of attributes Object types (or entity types or classes) Relationships XML Instances are Validated Against Schema

17.XML tags XML tags may have an element field used to store information within the tag or Meta-data Plain text can be placed between tags and this text is not parsed CDATA is character data This means that any string of non- markup characters is legal as part of the attribute The ENTITY indicates that the attribute will represent an external entity in the document itself The ID attribute type if you want to specify a unique identifier for each element.

18.XML Schema The structure of an XML document is defined by its schema. Dozens of languages to define XML schema: DTD W3C (XSD) ‏ NG - Relax This file can validate any instance of an XML document against it self. This file, or schema also defines allowable tags.

19.XML Instances

20.Sample XML Structure XML employees a tree structure model for representing data (previous slide) ‏ shiporder orderperson shipto name address city country item title name quantity price orderid

21.Schema Example (XSD) ‏ <?xml version="1.0" encoding="ISO-8859-1" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="shiporder"> <xs:complexType> <xs:sequence> <xs:element name="orderperson" type="xs:string"/> <xs:element name="shipto"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="address" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="country" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="item" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> <xs:element name="note" type="xs:string" minOccurs="0"/> <xs:element name="quantity" type="xs:positiveInteger"/> <xs:element name="price" type="xs:decimal"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="orderid" type="xs:string" use="required"/> </xs:complexType> </xs:element> </xs:schema>

22.Contrasts with HTML HTML uses a large number of predefined tags HTML documents Do not include schema information about type of data Static HTML page All information to be displayed explicitly spelled out as fixed text in HTML file

23.

24.XML Hierarchical Data Model Elements and attributes Main structuring concepts used to construct an XML document Complex elements Constructed from other elements hierarchically Simple elements Contain data values XML tag names Describe the meaning of the data elements in the document

25.XML Hierarchical Data Model Elements and attributes Main structuring concepts used to construct an XML document Complex elements Constructed from other elements hierarchically Simple elements Contain data values XML tag names Describe the meaning of the data elements in the document

26.XML Hierarchical Data Model Tree model or hierarchical model Main types of XML documents Data-centric XML documents Document-centric XML documents Hybrid XML documents Schemaless XML documents Do not follow a predefined schema of element names and corresponding tree structure

27.XML Hierarchical Data Model XML attributes Describe properties and characteristics of the elements (tags) within which they appear May reference another element in another part of the XML document Common to use attribute values in one element as the references

28.XML Documents and Schema Well formed Has XML declaration Indicates version of XML being used as well as any other relevant attributes Every element must matching pair of start and end tags Within start and end tags of parent element

29.XML Documents and Schema Valid Document must be well formed Document must follow a particular schema Start and end tag pairs must follow structure specified in separate XML DTD (Document Type Definition) file or XML schema file DTD is Outmoded in Current Usage Show Examples … Schemas Now Dominate ..