數(shù)據(jù)庫教學(xué)課件:Viper-XML-Concepts_第1頁
數(shù)據(jù)庫教學(xué)課件:Viper-XML-Concepts_第2頁
數(shù)據(jù)庫教學(xué)課件:Viper-XML-Concepts_第3頁
數(shù)據(jù)庫教學(xué)課件:Viper-XML-Concepts_第4頁
數(shù)據(jù)庫教學(xué)課件:Viper-XML-Concepts_第5頁
已閱讀5頁,還剩34頁未讀 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

DB2ViperTechnology

XMLConceptsWorldwideInformationManagementTechnicalPresalesDisclaimer/TrademarksInformationconcerningnon-IBMproductswasobtainedfromthesuppliersofthoseproducts,theirpublishedannouncements,orotherpubliclyavailablesources.IBMhasnottestedthoseproductsandcannotconfirmtheaccuracyofperformance,compatibility,oranyotherclaimsrelatedtonon-IBMproducts.Questionsonthecapabilitiesofnon-IBMproductsshouldbeaddressedtothesuppliersofthoseproducts.AllstatementsregardingIBM'sfuturedirectionorintentaresubjecttochangeorwithdrawalwithoutnotice,andrepresentgoalsandobjectivesonly.Thisinformationmaycontainexamplesofdataandreportsusedindailybusinessoperations.Toillustratethemascompletelyaspossible,theexamplesincludethenamesofindividuals,companies,brands,andproducts.Allofthesenamesarefictitious,andanysimilaritytothenamesandaddressesusedbyanactualbusinessenterpriseisentirelycoincidental.TrademarksThefollowingtermsaretrademarksorregisteredtrademarksofothercompaniesandhavebeenusedinatleastoneofthepagesofthepresentation:ThefollowingtermsaretrademarksofInternationalBusinessMachinesCorporationintheUnitedStates,othercountries,orboth:AIX,AS/400,DataJoiner,DataPropagator,DB2,DB2Connect,DB2Extenders,DB2OLAPServer,DB2UniversalDatabase,DistributedRelationalDatabaseArchitecture,DRDA,eServer,IBM,IMS,iSeries,MVS,Net.Data,OS/390,OS/400,PowerPC,pSeries,RS/6000,SQL/400,SQL/DS,Tivoli,VisualAge,VM/ESA,VSE/ESA,WebSphere,z/OS,zSeriesMicrosoft,Windows,WindowsNT,andtheWindowslogoaretrademarksofMicrosoftCorporationintheUnitedStates,othercountries,orboth.

IntelandPentiumaretrademarksofIntelCorporationintheUnitedStates,othercountries,orboth.

UNIXisaregisteredtrademarkofTheOpenGroupintheUnitedStatesandothercountries.

JavaandallJava-basedtrademarksaretrademarksofSunMicrosystems,IheUnitedStates,othercountries,orboth.

Othercompany,product,orservicenamesmaybetrademarksorservicemarksofothers.XMLFeaturesinDB2ViperCanstore,indexandquery……well-formedXMLdocumentsonly…...handlesvalidandnon-validdocuments……withorwithoutnamespaces……supportsXPath2.0……butalsoXQuery&SQL/XML……supportsXMLSchemabutnoDTDvalidation……usesSAXinsteadofDOMparsing……andstillincludestheXSLTfunctionsfromV8.?Readyto“talkXML”?WhatisXML:eXtensible

MarkupLanguage<book><authors><authorid=“47”>JohnDoe</author><authorid=“58”>PeterPan</author></authors><title>Databasesystems</title><price>29</price><keywords><keyword>SQL</keyword><keyword>relational</keyword></keywords></book>XML:DescribesdataHTML:DescribesdisplayXMLis"self-describingdata"WhatisXML:eXtensibleMarkupLanguage<book><authors><authorid=“47”>JohnDoe</author><authorid=“58”>PeterPan</author></authors><title>Databasesystems</title><price>29</price><keywords><keyword>SQL</keyword><keyword>relational</keyword></keywords></book>StartTagDataEndTagElementAttributeXML:DescribesdataHTML:DescribesdisplayEndTagStartTagTheXMLDocumentTree<book><authors><authorid=“47”>JohnDoe</author><authorid=“58”>PeterPan</author></authors><title>Databasesystems</title><price>29</price><keywords><keyword>SQL</keyword><keyword>relational</keyword></keywords></book>XMLParsing

booktitlepriceauthorauthorsauthorkeywordskeywordkeywordid=47id=58SQLrelationalDatabase

Systems29JohnDoePeterPanSerializationAnswer1:eXtensible

MarkupLanguageAnswer2:Ahierarchicaldatamodel!Adatamodel,consistingofnodesofseveraltypeslinkedthroughorderedparent/childrelationshipstoformahierarchy.Onlyonerepresentationofthatdatamodelistextual,thereareothersthatarenottextWhatisXML?<book><authors><authorid=“47”>JohnDoe</author><authorid=“58”>PeterPan</author></authors><title>Databasesystems</title><price>29</price><keywords><keyword>SQL</keyword><keyword>relational</keyword></keywords></book>Text Tree TwodifferentrepresentationsofthesamehierarchicalXMLdata:Otherrepresentations:Eventstreams,BinaryXML,etc.booktitlepriceauthorauthorsauthorkeywordskeywordkeywordid=47id=58SQLrelationalDatabase

Systems29JohnDoePeterPan1XMLDocument-2Representations<a><b>bla</b></a><a><b>bla</a>Eachopeningtagismatchedbyaclosingtag<a>3<5</a><a>3<5</a>Doesnotusedisallowedcharactersintagsorvalues<aid=“15”></a><aid=15></a>Attributevaluesmustbequoted<a><b>bla</b></a><a><b>bla</a></b>Allelementsareproperlynested<a><b>bla</b><c>blub</c></a><b>bla</b><c>blub</c>HasexactlyonerootelementWell-formednotwell-formedWell-formedXMLDocumentsAnXMLdocumentiswell-formed,if:Note:xmlheader<?xmlversion=“1.0”?>isNOTrequiredforwellformedness.See/TR/REC-xmlforfulldefinition.“Well-formed”or“valid”?AnXMLdocumentiswell-formed,if……itcomplieswiththerulesonthepreviouspagei.e.itcanbeparsedbyanXMLparserwithouterrorAnXMLdocumentisvalid,if……itiswell-formedAND…itcomplieswithaspecificDTDorXMLSchemaXMLParserscanoptionallyperform“validation”DTDs(DocumentTypeDefinitions)andXMLSchemadefineaspecificXMLdocumentstructureXMLElementNodesvs.TextNodes<customerinfo>

<name>Matt

Foreman</name><phone>905-555-4789</phone></customerinfo>customerinfophonename905-555-4789MattForemanTextNodesElement

NodesNote:Onlyelementshavetextnodes.Attributesdon’t.Don’tputdataintagnames!Feweruniqueelementnamesisbetter.EasiertodefineDTDorXMLSchema.<customer_by_zipcode><95123><customerid=“1289”><name>Bob</name>(...)</customer>:<customerid=“2317”>(...)</customer></95123><95141><customerid=“4903”>(...)</customer>:</95141>(...)</customer_by_zipcode><customer_by_zipcode><zipcodevalue=“95123”><customerid=“1289”><name>Bob</name>(...)</customer>:<customerid=“2317”>(...)</customer></zipcode><zipcodevalue=“95141”><customerid=“4903”>(...)</customer>:</zipcode>(...)</customer_by_zipcode>Well-formed,butbadstyle!Problem:NameCollisionThreedifferentXMLelements:

<title>DatabaseAdministrator</title>

<title>Mr</title>

<title>Gonewiththewind</title>Sameelementname,butdifferentmeaning!Canresultinprocessing/applicationerrors.Needtodistinguishbetweendifferentdomains.Solution:NamespacesAprefixidentifiesthedomain(“namespace”),anddistinguishesbetweenduplicateelementnames <job:title>DatabaseAdministrator</job:title> <person:title>Mr</person:title> <movies:title>Gonewiththewind</movies:title>Namespacesneedtobeuniquelyidentified….->URIsURI=UniversalResourceIdentifierURIExamples:

/db2xml http://abcdefghijklmn.xyzURIsuniquelyidentifyanamespaceURIstypicallylooklikeaURLURIsarejustanidentifier,theymaytopointtoawebpage,butdon’thaveto!FormoredetailsonURIssee/rfc/rfc2396.txtNamespaceDeclarationandURIsExample:elementname:person

namespaceURI:http://

namespaceprefix:foo

<foo:person

xmlns:foo="http://"><foo:name>JohnDoe</foo:name><foo:person>Thenamespaceappliestothecurrentelementandallsub-elementsandattributesthatitcontains.Thereservedattribute“xmlns”definesnamespaces,and(optionally)assignsthemtoanamespaceprefixMultipleNamespaces<cust:person

xmlns:cust=“/customer”><cust:name>JohnDoe</cust:name><prod:productxmlns:prod=“/product”> <prod:name>ThinkpadT40</prod:name> <prod:orderdate>2004-11-18</prod:orderdate></prod:product></cust:person>Thenamespaceappliestothecurrentelementandallsub-elementsandattributesthatitcontains–unlessit’soverridden!Scopeofthenamespace“prod”DefaultNamespaces<personxmlns=“http://”><age>45</age><name> <first>John</first> <last>Doe</last></name></person>Anamespacedeclarationwithoutprefixdefinesadefaultnamespace.Thenamespaceisimplicitforallelements/attributesinscope,withoutusingaprefix.Thedefaultnamespaceappliestothecurrentelementandallsub-elementsandattributesthatitcontains.PathExpressionsProvidenavigationinXMLDocumentsthroughthefollowingAxes:Child /employee/nameDescendants //firstnameParent /employee/name/../ageAttribute /@idSelf /employee/.andothers…Optionalpredicate/employee[@id="1234"]<customerinfo><name>

JohnSmith

</name><addrcountry="Canada">

<street> Fourth

</street><city>

Calgary</city><prov-state>

Alberta</prov-state><pcode-zip>

M1T2A9</pcode-zip></addr><phonetype="Work">

963-289-4136</phone></customerinfo>BeginElement(customerinfo)BeginElement(name)ElementValue(JohnSmith)

EndElement(name)BeginElement(addr)Attribute(country,Canada)BeginElement(street)ElementValue(Fourth)EndElement(street)BeginElement(city)ElementValue(Calgary)EndElement(city)BeginElement(prov-state)ElementValue(Alberta)EndElement(prov-state)BeginElement(pcode-zip)ElementValue(M1T2A9)EndElement(pcode-zip)EndElement(addr)BeginElement(phone)Attribute(type,work)ElementValue(963-289-4136)EndElement(phone)EndElement(customerinfo)Text Tree EventsThreedifferentrepresentationsofthesamehierarchicalXMLdata:customerinfoaddrphonenamecountry=Canada963-289-4136JohnSmithType=Workstreetcityprov-statepcode-zipValueCalgaryAlbertaValueOneXMLDocument-3Representations

XPath:SimpleXPathExpressionsUsefullyqualifiedpathstospecifyelements/attributes“@”isusedtospecifyanattributeuse“text()”tospecifythetextnodeunderanelementXPathResult/dept/@bldg101/dept/employee/@id901902/dept/employee/name<name>JohnDoe</name><name>PeterPan</name>/dept/employee/name/text()JohnDoePeterPan<deptbldg=“101”><employeeid=“901”><name>JohnDoe</name><phone>4085551212</phone><office>344</office></employee><employeeid=“902”><name>PeterPan</name><phone>4085559918</phone><office>216</office></employee></dept>XPATH<customerinfo> <name> JohnSmith</name><addrcountry="Canada"> <street> Fourth</street><city> Calgary</city><prov-state> Alberta</prov-state><pcode-zip> M1T2A9</pcode-zip></addr><phonetype="Work"> 963-289-4136</phone><name>FredDoe</name><addrcountry="USA"><prov-state> Iowa</prov-state><pcode-zip> 98765</pcode-zip></addr><phonetype="Mobile"> 244-775-3151</phone></customerinfo>/customerinfo<customerinfo> <name> JohnSmith</name><addrcountry="Canada"> <street> Fourth</street><city> Calgary</city><prov-state> Alberta</prov-state><pcode-zip> M1T2A9</pcode-zip></addr><phonetype="Work"> 963-289-4136</phone><name>FredDoe</name><addrcountry="USA"><prov-state> Iowa</prov-state><pcode-zip> 98765</pcode-zip></addr><phonetype="Mobile"> 244-775-3151</phone></customerinfo>XPATH<customerinfo> <name> JohnSmith</name><addrcountry="Canada"> <street> Fourth</street><city> Calgary</city><prov-state> Alberta</prov-state><pcode-zip> M1T2A9</pcode-zip></addr><phonetype="Work"> 963-289-4136</phone><name>FredDoe</name><addrcountry="USA"><prov-state> Iowa</prov-state><pcode-zip> 98765</pcode-zip></addr><phonetype="Mobile"> 244-775-3151</phone></customerinfo>/customerinfo/name<customerinfo> <name> JohnSmith</name><addrcountry="Canada"> <street> Fourth</street><city> Calgary</city><prov-state> Alberta</prov-state><pcode-zip> M1T2A9</pcode-zip></addr><phonetype="Work"> 963-289-4136</phone>

<name>FredDoe</name><addrcountry="USA"><prov-state> Iowa</prov-state><pcode-zip> 98765</pcode-zip></addr><phonetype="Mobile"> 244-775-3151</phone></customerinfo><name> JohnSmith</name><name>FredDoe</name>XPATH<customerinfo> <name> JohnSmith</name><addrcountry="Canada"> <street> Fourth</street><city> Calgary</city><prov-state> Alberta</prov-state><pcode-zip> M1T2A9</pcode-zip></addr><phonetype="Work"> 963-289-4136</phone><name>FredDoe</name><addrcountry="USA"><prov-state> Iowa</prov-state><pcode-zip> 98765</pcode-zip></addr><phonetype="Mobile"> 244-775-3151</phone></customerinfo>/customerinfo/addr<customerinfo> <name> JohnSmith</name>

<addrcountry="Canada"> <street> Fourth</street><city> Calgary</city><prov-state> Alberta</prov-state><pcode-zip> M1T2A9</pcode-zip></addr><phonetype="Work"> 963-289-4136</phone><name>FredDoe</name>

<addrcountry="USA"><prov-state> Iowa</prov-state><pcode-zip> 98765</pcode-zip></addr><phonetype="Mobile"> 244-775-3151</phone></customerinfo><addrcountry="Canada"> <street>Fourth</street><city>Calgary</city><prov-state>Alberta</prov-state><pcode-zip>M1T2A9</pcode-zip></addr><addrcountry="USA"><prov-state>Iowa</prov-state><pcode-zip>987653</pcode-zip></addr>XPATH<customerinfo> <name> JohnSmith</name><addrcountry="Canada"> <street> Fourth</street><city> Calgary</city><prov-state> Alberta</prov-state><pcode-zip> M1T2A9</pcode-zip></addr><phonetype="Work"> 963-289-4136</phone><name>FredDoe</name><addrcountry="USA"><prov-state> Iowa</prov-state><pcode-zip> 98765</pcode-zip></addr><phonetype="Mobile"> 244-775-3151</phone></customerinfo>/customerinfo/addr/prov-state<customerinfo> <name> JohnSmith</name><addrcountry="Canada"> <street> Fourth</street><city> Calgary</city>

<prov-state> Alberta</prov-state><pcode-zip> M1T2A9</pcode-zip></addr><phonetype="Work"> 963-289-4136</phone><name>FredDoe</name><addrcountry="USA">

<prov-state> Iowa</prov-state><pcode-zip> 98765</pcode-zip></addr><phonetype="Mobile"> 244-775-3151</phone></customerinfo><prov-state> Alberta</prov-state><prov-state> Iowa</prov-state>XPath:Wildcards*matchesanytagname//isthe“descendent-or-self”wildcardXPathResult/dept/employee/*/text()JohnDoe4085551212344PeterPan4085559918216/dept/*/@id901902//name/text()JohnDoePeterPan/dept//phone<phone>4085551212</phone><phone>4085559918</phone><deptbldg=“101”><employeeid=“901”><name>JohnDoe</name><phone>4085551212</phone><office>344</office></employee><employeeid=“902”><name>PeterPan</name><phone>4085559918</phone><office>216</office></employee></dept>XPath:PredicatesPredicatesareenclosedinsquarebrackets[…]CanhavemultiplepredicatesinoneXpathPositionalpredicates:[n]selectsthen-thchildXPathResult/dept/employee[@id="902"]/name<name>PeterPan</name>/dept[@bldg="101"]/employee[office>"300"]/name<name>JohnDoe</name>//employee[office="344"ORoffice="216"]/@id901902/dept/employee[2]/@id902<deptbldg=“101”><employeeid=“901”><name>JohnDoe</name><phone>4085551212</phone><office>344</office></employee><employeeid=“902”><name>PeterPan</name><phone>4085559918</phone><office>216</office></employee></dept>XPATH<customerinfo> <name> JohnSmith</name><addrcountry="Canada"> <street> Fourth</street><city> Calgary</city><prov-state> Alberta</prov-state><pcode-zip> M1T2A9</pcode-zip></addr><phonetype="Work"> 963-289-4136</phone><name>FredDoe</name><addrcountry="USA"><prov-state> Iowa</prov-state><pcode-zip> 98765</pcode-zip></addr><phonetype="Mobile"> 244-775-3151</phone></customerinfo>/customerinfo/addr[@country="Canada"]/prov-state<customerinfo> <name> JohnSmith</name><addrcountry="Canada"> <street> Fourth</street><city> Calgary</city>

<prov-state> Alberta</prov-state>

<pcode-zip> M1T2A9</pcode-zip></addr><phonetype="Work"> 963-289-4136</phone><name>FredDoe</name><addrcountry="USA"><prov-state> Iowa</prov-state><pcode-zip> 98765</pcode-zip></addr><phonetype="Mobile"> 244-775-3151</phone></customerinfo><prov-state> Alberta</prov-state>XPath:TheParentAxisCurrentcontext:"."Parentcontext:".."XPathResult/dept/employee/name[../@id="902"]<name>PeterPan</name>/dept/employee/office[.>"300"]<office>344</office>/dept/employee[office>"300"]/office<office>344</office>/dept/employee[name="JohnDoe"]/../@bldg101/dept/employee/name[.="JohnDoe"]/../../@bldg101<deptbldg=“101”><employeeid=“901”><name>JohnDoe</name><phone>4085551212</phone><office>344</office></employee><employeeid=“902”><name>PeterPan</name><phone>4085559918</phone><office>216</office></employee></dept>XPATH<customerinfo> <name> JohnSmith</name><addrcountry="Canada"> <street> Fourth</street><city> Calgary</city><prov-state> Alberta</prov-state><pcode-zip> M1T2A9</pcode-zip></addr><phonetype="Work"> 963-289-4136</phone><name>FredDoe</name><addrcountry="USA"><prov-state> Iowa</prov-state><pcode-zip> 98765</pcode-zip></addr><phonetype="Mobile"> 244-775-3151</phone></customerinfo>/customerinfo/addr/city[.="Calgary"]/../@country<customerinfo> <name> JohnSmith</name><addrcountry="Canada"> <street> Fourth</street><city> Calgary</city><prov-state> Alberta</prov-state>

<pcode-zip> M1T2A9</pcode-zip></addr><phonetype="Work"> 963-289-4136</phone><name>FredDoe</name><addrcountry="USA"><prov-state> Iowa</prov-state><pcode-zip> 98765</pcode-zip></addr><phonetype="Mobile"> 244-775-3151</phone></customerinfo>CanadaXPATH<customerinfo> <name> JohnSmith</name><addrcountry="Canada"> <street> Fourth</street><city> Calgary</city><prov-state> Alberta</prov-state><pcode-zip> M1T2A9</pcode-zip></addr><phonetype="Work"> 963-289-4136</phone><name>FredDoe</name><addrcountry="USA"><prov-state> Iowa</prov-state><pcode-zip> 98765</pcode-zip></addr><phonetype="Mobile"> 244-775-3151</phone></customerinfo>/customerinfo/addr[prov-state="Iowa"]/@country<customerinfo> <name> JohnSmith</name><addrcountry="Canada"> <street> Fourth</street><city> Calgary</city><prov-state> Alberta</prov-state>

<pcode-zip> M1T2A9</pcode-zip></addr><phonetype="Work"> 963-289-4136</phone><name>FredDoe</name><addrcountry="USA"><prov-state> Iowa</prov-state><pcode-zip> 98765</pcode-zip></addr><phonetype="Mobile"> 244-775-3151</phone></customerinfo>USAXPATH<customerinfo> <name> JohnSmith</name><addrcountry="Canada"> <street> Fourth</street><city> Calgary</city><prov-state> Alberta</prov-state><pcode-zip> M1T2A9</pcode-zip></addr><phonetype="Work"> 963-289-4136</phone><name>FredDoe</name><addrcountry="USA"><prov-state> Iowa</prov-state><pcode-zip> 98765</pcode-zip></addr><phonetype="Mobile"> 244-775-3151</phone></customerinfo>/customerinfo//text()<customerinfo> <name>

JohnSmith</name><addrcountry="Canada"> <street>

Fourth</street><city>

Calgary</city><prov-state>

Alberta</prov-state><pcode-zip>

M1T2A9</pcode-zip></addr><phonetype="Work">

963-289-4136</phone><name>

FredDoe</name><addrcountry="USA"><prov-state>

Iowa</prov-state><pcode-zip>

98765</pcode-zip></addr><phonetype="Mobile">

244-775-3151</phone></customerinfo>JohnSmithFourthCalgaryAlbertaM1T2A9963-289-4136FredDoeIowa98765244-775-3151WhatisanXMLSchema?Definesstructure,content,datatypesforXMLdocumentsConsistsof1ormoreschemadocumentsAschemadocumentcandefineanamespace(optionally)Example:1XMLSchema,3SchemaDocuments,2Namespaces

order.xsd

Order

Lineitemlineitem.xsd

parts.xsd

import

include

Namespace:Namespace:Orderschema/TR/xmlschema-0/AdvantagesofXMLSchemaoverDTDsCandefinedatatypesforelements/attributesBasictypes:i

溫馨提示

  • 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論