ch07 - ADB - Semi Structured Database
ch07 - ADB - Semi Structured Database
Chapter 07:
Semi structured database
PLAN
player.xml
article.xml
Prefix URI(URL)
Namespace declaration
<BOOK xmlns=“http://www.bookstuff.org/bookinfo”>
<TITLE> All About XML </TITLE>
<AUTHOR> Joe Developer </AUTHOR>
</BOOK>
defaultnamespace.xml
letter.dtd
Define the requirements for
the contact element
letter.xml
Two categories of types exist in XML Schema: simple types and complex
types
Simple types cannot contain attributes or child elements; complex types can
XML schema types: string , boolean, decimal, float, double, int, long, short,
date, time, …
book.xml
book.xsd
A SingleBookType element
has a title element, which
contains a string
<xsd:complexType name="BookType">
<xsd:sequence>
<xsd:element name="title“ type="xsd:string"/>
<xsd:element name="author“ type="PersonType“ minOccurs="1“ maxOccurs="unbounded"/>
<xsd:element name="publisher“ type="xsd:anyType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="PersonType">
<xsd:sequence>
<xsd:element name="first“ type="xsd:string"/>
<xsd:element name="last“ type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
• Vocabulary of Schema defined in special Namespace. Prefix "xsd" is commonly used
• ” Schema” Element is always the Root
<xsd:complexType name="BookType">
• User-defined type
• Defines a sequence of sub-elements
• Attribute "name" specifies name of Type
• This Type definition is global, BookType can be used in any other definition.
Example
• <xsd:element name="title“ type="xsd:string"/>
• Restrict domain
– minInclusive, maxInclusive are
"facets"
• XSLT convert XML into any text-based document, can be used to transform
XML into HTML before it is displayed by a browser
attributes in an
HTML document
Write the following HTML for each
game element in the sports element
that is contained in the root element
The xml-stylesheet
declaration points to an
XSL style sheet for this
document
sports.xml
/sports Matches all sports nodes that are child nodes of the
document root node.
/sports/game Matches all game nodes that are child nodes of sports,
which is a child of the document root.
/sports/game/name Matches all name nodes that are child nodes of game.
The game is a child of sports, which is a child of the
document root.
/sports/game/paragraph Matches all paragraph nodes that are child nodes of
game. The game is a child of sports, which is a child
of the document root.
/sports/game [@id=’239’] Matches the game node with the id number 239. The
game is a child of sports, which is a child of the
document root.
/sports/game [name='Cricket'] Matches all game nodes that contain a child element
whose name is Cricket. The game is a child of
sports, which is a child of the document root.
for $x in
doc("books.xml")/bookstore/book
where $x/price>30
order by $x/title
return $x/title
Example:
The following predicate is used to select all the book elements under the
bookstore element that have a price element with a value less than 30:
Property/Method Description
Property/Method Description
Property/Method Description
Text methods
Property Description
xpath.html
(1 of 3)
xpath.html
(1 of 3)
xpath.html
(2 of 3)
xpath.html
(3 of 3)
sports.xml