PSBD
DAFTAR ISI
Part 1: Dasar pembuatan dokumen XML
Part 2: Melakukan query pada dokumen XML
LATAR BELAKANG
An Extensible Markup Language (XML) document describes the
structure of data
XML and HTML have a similar syntax both derived from SGML
XML has no mechanism to specify the format for presenting data to
the user
An XML document resides in its own file with an .xml extension
ATURAN DASAR
XML is case sensitive
All start tags must have end tags
Elements must be properly nested
XML declaration is the first statement
Every document must contain a root element
Attribute values must have quotation marks
Certain characters are reserved for parsing
CONTOH PENGGUNAAN
Example 3: Elements with Children
To specify that an element must have a single child element, include the element name within the parenthesis.
<!ELEMENT House (Address)> <!A house has a single address-->
<House> <!Valid usage within XML file-->
<Address>1345 Preston Ave Charlottesville Va 22903</Address>
</House>
An element can have multiple children. A DTD describes multiple children using a sequence, or a list of elements separated by commas. The XML
file must contain one of each element in the specified order.
<!--DTD declaration of an element-->
<!ELEMENT address (person,street,city, zip)>
<!ELEMENT person (#PCDATA)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT city
(#PCDATA)>
<!ELEMENT zip
(#PCDATA)>
<!Valid usage within XML file-->
<address>
<person>John Doe</person>
<street>1234 Preston Ave.</street>
<city>Charlottesville, Va</city>
<zip>22903</zip>
</address>
XQL
XQL - XML Query Language
The name was an ad hoc selection, but seems like it has and will
survive for quite some time
:
:
:
:
:
:
Root context
Current context
Recursive descent from root
Recursive descent from current node
Attribute
Any element
SAMPLE DOCUMENT
<?xml version='1.0'?>
<!-- This file represents a fragment of a book store inventory database -->
<bookstore specialty='novel'>
<book style='autobiography'>
<title>Seven Years in Trenton</title>
<author>
<first-name>Joe</first-name>
<last-name>Bob</last-name>
<award>Trenton Literary Review Honorable Mention</award>
</author>
<price>12</price>
</book>
<my:book style='leather' price='29.50' xmlns:my='http://www.placeholder-name-here.com/schema/'>
<my:title>Who's Who in Trenton</my:title>
<my:author>Robert Bob</my:author>
</my:book>
</bookstore>
x/y[index() = 0] x/y[0]
(x/y)[0]
x[0]/y[0]
book[end()]
author[first-name][2]
price[@intl!value() = canada]
my:*
*:book
book/@my:style