Fsfs D Asd Asda
Fsfs D Asd Asda
Matthew Egbert
Outline of Talk
4XML Databases
Discuss XML in the context of Databases
Relational Databases vs. XML Databases
Databases
4A database is a collection of data that is
organized so that its contents can easily be
accessed, managed, and updated
4The most prevalent type of database is the
relational database, a tabular database in which
data is defined so that it can be reorganized and
accessed in a number of different ways
Microsoft Access
Oracle
Sybase
IBMs DB2
Xindice
4Xindice is a native XML-Database
4The benefit of a native solution is that you don't
have to worry about mapping your XML to some
other data structure. You just insert the data as
XML and retrieve it as XML[which is] especially
valuable when you have very complex XML
structures that would be difficult or impossible to
map to a more structured database. [2]
Xindice (cont.)
4Xindice stores and indexes compressed XML
documents
4It was not designed to store and manage single
monster sized documents, where one document
is treated as a set of mini documents. It was
specifically designed for managing many small to
medium sized documents. [8]
Interacting with an
XML Database
4Because native XML databases store data in a
different way from relational databases, there are
different languages used to query and update the
database
4Query
To retrieve a specified portion of a database
4Update
To add or modify a portion of a database
XLanguages
4For relational databases, the Structured Query
Language (SQL) is often used to perform both
queries and updates
4For Xindices (and other XML native databases):
queries are specified using the XPath language
updates are defined using the XUpdate language
XPath
Querying the
Database with XPath
4XPath is a (W3C-standard) language used to
address a section of an XML document
4XPath uses a compact, non-XML syntax to
facilitate use of XPath within URIs[6]
4A single string of XPath can address any section
of an XML document
4The next few slides show the basics of XPath by
giving some basic examples
11
12
<AAA>
<CCC>
<DDD>
<BBB/>
<EEE/>
<FFF/>
</DDD>
</CCC>
<CCC>
<BBB>
</BBB>
</CCC>
</AAA>
Example XPath[5]
4//DDD/BBB
Select all elements BBB
which are direct children of
DDD
<AAA>
<BBB/>
<CCC/>
<BBB/>
<DDD>
<BBB/>
</DDD>
<CCC>
<DDD>
<BBB/>
<BBB/>
</DDD>
</CCC>
</AAA>
Example XPath[5]
4/*/*/*/BBB
Select all elements BBB
which have exactly 3
ancestors
14
<AAA>
<XXX>
<DDD>
<BBB/>
<BBB/>
<EEE/>
</DDD>
</XXX>
<CCC>
<BBB>
<BBB>
<BBB/>
</BBB>
</BBB>
15
<AAA>
<BBB/>
<BBB/>
<BBB/>
<BBB/>
</AAA>
An example XPath
Function[5]
4/AAA/BBB[last()]
Select the last BBB child of
element AAA
This is an example of an
XPath function
16
<AAA>
<BBB/>
<BBB/>
<BBB/>
<BBB/>
</AAA>
An example XPath
Function[5]
4//*[count(BBB)=2]
Select elements which have
two children BBB
17
<AAA>
<CCC>
<BBB/>
<BBB/>
<BBB/>
</CCC>
<DDD>
<BBB/>
<BBB/>
</DDD>
<EEE>
<DDD/>
</EEE>
</AAA>
Combining XPath[5]
4| is used to combine
XPath queries
4//CCC | //BBB
Select all elements CCC and
all elements BBB
18
<AAA>
<CCC>
<BBB/>
<BBB/>
<BBB/>
</CCC>
<DDD>
<BBB/>
<BBB/>
</DDD>
<EEE>
<DDD/>
</EEE>
</AAA>
19
<AAA>
<BBB>
<DDD>
<CCC>
<DDD/>
<EEE/>
</CCC>
</DDD>
</BBB>
<CCC>
<DDD>
<EEE>
<DDD>
<FFF/>
20
<AAA>
<BBB>
<DDD>
<CCC>
<DDD/>
<EEE/>
</CCC>
</DDD>
</BBB>
<CCC>
<DDD>
<EEE>
<DDD>
<FFF/>
21
<AAA>
<BBB>
<DDD>
<CCC>
<DDD/>
<EEE/>
</CCC>
</DDD>
</BBB>
<CCC>
<DDD>
</DDD>
</CCC>
</AAA>
22
23
<AAA>
<BBB/>
<BBB/>
<BBB/>
<BBB/>
<BBB/>
<BBB/>
<BBB/>
<BBB/>
<CCC/>
<CCC/>
<CCC/>
</AAA>
XPathQueryService xp_service =
col.getService("XPathQueryService", "1.0");
ResourceSet resultSet = xp_service.query(xpath);
24
XUpdate
XUpdate Overview
4XUpdate is an XML-syntax that is used to specify
modifications of XML documents
4It is part of the XML:DB Project
(http://www.xmldb.org/xupdate/)
4XUpdate uses XPath expressions to select nodes
for processing
4Lets look at an example
26
28
29
Conclusion
4XPath and XUpdate are the XML-Database
languages which are supported by Xindice
4Performing XPath queries or XUpdate updates
using the Xindice API is easy
4XQuery is a developing XML alternative to XPath
(which has the non XML, path-like structure)
More SQL like database queries
Not yet supported by Xindice
32
References
4[2] Xindice homepage
http://xml.apache.org/xindice/
4[5] XPath Tutorial by Miloslav Nic and Jiri Jirat
http://www.zvon.org/xxl/XPathTutorial/General/ex
amples.html
4[6] XML Path Language (XPath) Version 1.0 W3C
Recommendation - 16 November 1999
http://www.w3.org/TR/xpath
33
References (cont.)
4[7] XUpdate Example Use Cases Page
http://www.xmldatabases.org/projects/XUpdateUseCases/
4[8] Xindice FAQ
http://xml.apache.org/xindice/FAQ
34