• No results found

XML Technology

N/A
N/A
Protected

Academic year: 2020

Share "XML Technology"

Copied!
5
0
0

Loading.... (view fulltext now)

Full text

(1)

XML Technology

Khadija Abied Ali

Department of Computer/Faculty of Science Sebha University

[email protected]

Abstract-- XML, the eXtensible Markup Language is an open and flexible standard created by the World Wide Web Consortium (W3C) in early 1998 for storing, publishing and exchanging any kind of information. It has been amazing to see how quickly the XML standard has been developed, and how quickly a large number of software vendors have adopted the standard.

The XML has been recently understood as a new approach to data modelling. A well formed XML document or a set of documents is an XML database and the associated DTD or schema specified in the language XML Schema is its database schema. Implementation of a system enabling us to store and query XML documents efficiently (so called native XML databases) requires a development of new techniques and is of great importance in the world of information technologies today. In this work we briefly review XML; we include some basic knowledges that are required to understand the XML technology. We conclude that XML will be as important to the future of the Web as HTML has been to the foundation of the Web; XML is the future for all data transmission and data manipulation.

Index Term-- XML, XPath, XQuery, XML document, Parsing, DTD, XML schema, Application Programming Interfaces APIs, XML-enabled databases, Native XML databases NXDs.

1 INTRODUCTION

XML, the eXtensible Markup Language [1] is an open and flexible standard created by the World Wide Web Consortium (W3C) in early 1998 for storing, publishing and exchanging any kind of information. XML takes its major framework from the Standard Generalized Markup Language SGML [2]. XML is playing an increasingly important role in the exchange of a wide variety of data on the web and elsewhere. In this work we briefly review XML; we include some basic knowledges that are required to understand the XML technology.

This work is organized as follows: first in Section 2 we refer to the advantages of XML. In Section 3 we specify how XML can represent semi-structured data. The well-formedness and validity are two important concepts of XML document. We highlight these concepts in Section 4. In Section 5 we

introduce briefly manipulating XML. The issue of storing XML documents in a database is the subject of Section 6. Finally, in Section 7 we present our conclusions.

2 ADVANTAGES OF XML

XML brings a number of powerful capabilities to information modeling:

 Heterogeneity, where each “record“ can contain different data fields. There is a great advantage in being able to express information, as it exists, without restrictions.

 Extensibility, where new types of data can be added at will and do not need to be determined in advance.  Flexibility, where data fields can vary in size and

configuration from instance to instance; each data element can be as long or as short as necessary.  Internationalization: XML supports the

internationalization (Unicode).

We infer from the above that:

• Do not have to think too hard about the structure of the data before building a document.

• Do not have to define a schema.

• The documents are very flexible i.e. can add new things and change things in an ad hoc manner.

Despite of many advantages of XML, XML is not a replacement for HyperText Markup Language HTML [3]. XML and HTML are designed with different goals; XML was designed to focus on what data is, while HTML was designed to focus on how data looks. In other words, XML is about describing information, while HTML is about displaying information. Figure 1 represents an example of an HTML document.

<html>

<head><title>Example</title></head>

<body>

<h1>This is an example of a page.</h1>

<h2>Some information goes here.</h2>

</body>

</html>

(2)

<?xml version = “1.0” ?>

<address>

<name>

<first>Ali</first>

<last>Hassan</last>

</name>

<email>[email protected]</email>

<phone>092-315-6789</phone>

<birthday>

<year>1983</year>

<month>07</month>

<day>15</day>

</birthday>

</address>

Fig. 2. An example of an XML document

3. HOW DOES XML LOOK?

XML is the ideal way to represent semistructured data; it is a text-based language, where markup tags like <employee_number> can clearly specify what kind of information is enclosed in a tag. An XML document consists mainly of elements and attributes. If an element is not empty, it begins with a start-tag (e.g. <employee>), and ends with an end-tag (e.g. </employee>). The text between the start-tag and end-tag is called the element’s content. An element with no content is said to be empty. Attributes occur inside start-tag after the element name. For instance, <employee id=“111“> is an employee element with the attribute id having the value 111.

Beside of elements and attributes, Comments, Processing Instructions, Entity References, CDATA Sections can be added to an XML document. Additional information on XML is possible to find in [4,5,6]. Consider the XML document in Figure 2. The tree structure of XML document in Figure 2 is represented in Figure 3.

We infer from Figure 3:

• An XML document has a single root node (address). • The tree is a general ordered tree.

– A parent node may have any number of children.

– Child nodes are ordered, and may have siblings.

• Preorder traversals are usually used for getting information out of the tree.

4. THE WELL-FORMEDNESS AND VALIDITY

The well-formedness and validity are two important concepts of XML document. The former mainly deals with physical structure (e.g. matching and properly nested tags). In other words a well-formed document has a tree structure and obeys all the XML rules [8]. Here are some of these rules:

• Tags are enclosed in angle brackets.

• Documents must have a single root tag that begins the document.

• Tags come in pairs with start-tags and end-tags. • Tags must be properly nested.

– <name><email>…</name></email> is not allowed.

– <name><email>…</email><name> is.

The later i.e validity focuses on the logical structure of elements. DTD [9] is the standard schema language for XML, that can be used to define the syntax and structure of XML documents. DTDs were developed first, so they are not as comprehensive as schema;XML Schema [10] is a much more comprehensive schema language for XML.

4.1 Parsing

(3)

address

name email phone birthday

First last year month day

Fig. 3. Tree structure of XML document in Fig 2

Writes

is read by Displays to

Editor Document Browser User

Fig. 4. Life cycle of XML document

4.2 Sample DTD

Consider the XML document in Figure 5 which contains information about employees. The DTD of this XML document is shown in Figure 6.

The DTD in Figure 6 is interpreted as follows:

 !ELEMENT employees defines the employees element as having at least one element identified by employee; DTD allows to declare that the child element must occur one or more times (using +), zero or more times (using *), zero or one times (using ?),

inside the parent element.

 !ELEMENT employee defines the employee element as having child elements name and salary.

 ATTLIST id defines the id attribute of the employee element. This attribute is required for each employee element.

 !ELEMENT name defines the name element to be of the type PCDATA . Consequently, the element contains character data.

 !ELEMENT salary defines the salary element to be of the type PCDATA .

5. MANIPULATING XML

In context of databases, XML is also a new database model serving as a powerful tool for approaching semistructured data. XML provides many of the database-like capabilities needed for the task, including schema languages (DTDs [9], XML Schema [10]), query languages (XPath [11], XQuery [12, 13, 14]), application programming interfaces (SAX [15], DOM [16], JDOM [17]).

In the following sections, we introduce briefly Xpath, XQuery, application programming interfaces (API), and other XML technologies.

5.1 Xpath( navigate through XML tree)

(4)

<employees>

<employee id=“122“>

<name>Ahmed</name>

<salary>8000</salary>

</employee>

<employee id=“155“>

<name>Ali</name>

<salary>7000</salary>

</employee>

</employees>

Fig. 5. An XML document containing information about employees

<!ELEMENT employees (employee+)>

<!ELEMENT employee(name, salary)>

<ATTLIST employee id CDATA #REQUIRED>

<!ELEMENT name(#PCDATA)>

<!ELEMENT salary(#PCDATA)>

Fig. 6. DTD of the XML document in Fig. 5

employee//address/street, will select all “street“ elements being children of “address“ elements which have an ancestor element named “employee“. The double slash in subexpression “employee//address“ specifies that there must be a path leading from an “employee“ element to an “address“ element. In other words, double slash denotes an ancestor-descendant relationship. The single slash in “address/street“ denotes a parent-child relationship. The XPath defines a family of 13 axes. Among the supported axes are ancestor, descendant, parent, child, preceding-sibling or following-sibling.

5.2 XQuery ( the XML Query Language)

To obtain specified data from an XML database a number of special query languages have been developed, e.g. XML-QL, XQL, XQuery. XQuery[12, 13, 14] have been developed by the W3C XML Query Working Group. A subset of the XPath is a part of XQuery but more complex constructs are put into the language. XQuery can be implemented in many invironments, such as in traditional databases [18], and XML repositories. The XML Query Working Group published XQuery 3.0: an XML Query Language, along with XQueryX, an XML representation for XQuery, both as W3C Recommendation, as well as the XQuery 3.0 use cases and requirements as final working group notes. XQuery extends the XPath language to provide efficient search and manipulation of information represented as trees from a variety of sources [19].

Data retrieval in XML

In context of databases, XML is also a new database model serving as a powerful tool for approaching semistructured data. As XML is a tool for data representation in the web, its main query language, i.e. XQuery, can serve as the bridge between XML repositories and the web.

XQuery is a functional language where each query is denoted by an expression. There are seven types of expressions in XQuery: path expression, element constructors, FLWR (For Let Where Return) expressions, expressions involving operators and functions, conditional expressions, quantified expressions and expressions that test or modify data types. Various expressions can be used together both sequentially and nested. Although XQuery provides the most expressive power, the powerful support of updates is missing.

An example

Consider the previous XML document describing employees in Figure 5. Suppose we want to retrieve the names of employees having salaries more than 7000. This query can be expressed in XQuery as follows:

for $emp in //employee where $emp/salary > "7000“ return $emp/name

The output of the query will be as follows:

<name>Ahmed</name>

5.3 Application Programming Interfaces (APIs)

(5)

The Simple APIforXML SAX [15] is a simple API for event-based XML parsing. SAX does not create a data structure; instead, it scans an input document and generates events, such as the start of an element, the end of an element, and so on. A major advantage of this approach is that SAX can result in reduced memory overhead. In the negative side, SAX does not allow random access manipulation of the document.

The Java Document Object Model JDOM [17] is a simple productive API for XML parsing. It incorporates the best features of DOM and SAX; it provides a full document view with random access, but it does not require the entire document to be in memory.

5.4 Another XML Technologies

There are a lot of technologies related to the XML. In the following lines we describe briefly some of them. SOAP [20] is the Simple Object Access Protocol used for invoke code offered by Web services over the Internet using XML and HTTP. The XML Linking (XLink) [21] allows elements to be inserted into XML documents in order to create and describe links between resources. The XML Pointer Language (XPointer) [22] defines an addressing scheme for individual parts of an XML document. These addresses can be used by any application that needs to identify parts of or locations in an XML document . A standard approach to formatting XML documents is using XSL[23], the eXtensible Stylesheet Language. It consists of XSL Transformations (XSLT), a language for transforming XML, and XSL Formatting Objects (XSL-FO), an XML vocabulary for specifying formatting semantics.

6. XML-ENABLED DATABASES VS NATIVE XML DATABASES NXDS

There are two different ways to store XML documents in a database: XML-enabled databases and Native XML Databases (NXDs). The former map the data to existing (relational) database systems. The latter are XML-database systems whose inner data representation is XML-compliant [24]. NXDs are designed especially to store XML; NXDs preserve things like document order, processing instruction, comments, CDATA sections, and entity usage, while XML-enabled databases do not.

7. CONCLUSIONS

The amount of data available in XML has been rapidly increasing. In this work, we referred to positive features of XML. In context of databases, XML is also a new database model serving as a powerful tool for approaching semistructured data. We showed how XML is a suitable platform to represents a semistructured data. Manipulating data in XML is one of the most important issues. We have introduced briefly Xpath, XQuery , application programming interfaces (API), and some other XML technologies.

We have experimented with XPath and XQuery in the open source NXD (eXist) [25]. We have extended XQuery in “a logical way” to add time dimension to XML. The results has been published in [26]. Finally, we referred to the issue of storing XML.

We conclude that XML provides a flexible mechanism to represent complex data. XML can adequately handle rich data such as audio, video, nested data structures or complex documents.

REFERENCES

[1] W3C: Extensible Markup Language (XML) (fifth Edition), W3C Recommendation 26 November 2008. http://www.w3.org/TR/xml/

[2] Learning and using SGML www.w3.org/MarkUp/SGML

[3] HTML 4.01 Specification, W3C Recommendation 24 December 1999.

http://www.w3.org/TR/html4/

[4] Walsh, N. A technical introduction to XML.

http://www.xml.com/pub/a/98/10/guide0.html?page=1

[5] Holzner, S. Teach yourself XML in 21 Days.

http://www.informit.com/library/library.aspx?b=STY_XML_21days

[6] Database Resource Center. http://www.xml.com/databases/

[7] Bourret, R.: XML and Databases, 2005.

http://www.rpbourret.com/xml/XMLAndDatabases.htm

[8] Elliotte Rusty Harold , XML 1.1 Bible 3rd Edition , 2004. Pages: 146-166

[9] DTD tutorials. http:// www.w3schools.com/dtd

[10] XML Schema. http://www.w3.org/XML/Schema

[11] Clark, J., DeRose, S.: XML Path Language (XPath) Version 1.0, W3C Recommendation, 16 November 1999. http://www.w3.org/TR/xpath/. [12] XQuery Tutorial. http://www.w3schools.com/xquery/

[13] Bothner, P. What is XQuery.

http://www.xml.com/pub/a/2002/10/16/xquery.html?page=2

[14] Walmsley, P. Introduction to XQuery.

http://www.stylusstudio.com/doc/xquery_introduction.pdf

[15] The official website for SAX. http://www.saxproject.org/

[16] Document Object Model (DOM). http://www.w3.org/Dom

[17] JDOM v1.1. http://www.jdom.org/docs/apidocs/

[18] Brian Benz and John R. Durant. XML Programming Bible.(2003). Pages:430-470

[19] XQuery 3.0, XPath 3.0, XQueryX 3.0, XDM 3.0, Serialization 3.0, Functions and Operators 3.0 are now W3C Recommendations. 10 April 2014. http://www.w3.org/blog/news/archives/3773

[20] W3 Consortium. Simple Object Access Protocol (SOAP) version 1.2, W3C Recommendation, 27 April 2007.

http://www.w3.org/TR/soap12/.

[21] W3 Consortium. XML Linking Language (XLink) Version 1.1, W3C Recommendation, 14 September 2010. http://www.w3.org/TR/xlink/ [22] W3 Consortium. XML Pointer Language (XPointer) Version 1.0.

W3C Working Draft.16 August 2002. http://www.w3.org/TR/xptr/ [23] W3 Consortium. The Extensible Stylesheet Language Family

(XSL) . 12 April 2014. http://www.w3.org/Style/XSL/

[24] Kimbro Staken. Introduction to Native XML Databases.

www.xml.com/pub/a/2001/10/31/nativexmldb.html

[25] eXist Home page. http://exist.sourceforge.net/

[26] Abied K., Pokorný J.: Adding Time Dimension to XML, in Data Mining and Management, Nova Science Publishers, Inc., ISBN:

978-1-60741-289-2, pp. 81-117, 2010.

Figure

Fig. 4.  Life cycle of XML document

References

Related documents

We have chosen the I.C number of each students of 2DAA as we choose to collect a numeric data for the tasks. A numerical data is also known as quantitative data which consists

adapun tujuan dalam penelitian ini adalah untuk memberikan wawasan kepada kita tentang bahwa dalam Islam persoalan hak-hak perempuan telah secara dibahas secara luas para yuris

Similar to kenaf fiber study, noted by Li et al., (2004) that an optimum addition of natural hemp fiber increases the Compressive and flexural properties of natural hemp

To investigate whether subretinal fluid induces procoagulant activity, we added samples from 10 patients who underwent successful scleral buckling surgery for primary RRD to normal

As shown in Algorithm 1, this process comprises two different interleaved stages, an individual planning process by which agents devise refinements over a centralized base plan and

If the lead screw pitch = 5 mm, and the optical encoder emits 400 pulses per revolution, determine the rotational speed of the motor and the pulse rate of the encoder in order to

JUVENILE COURT PENGHULU.. The Judiciary hears and determines civil and criminal matters, and pronounces on the legality of legislative and executives acts. It may also interpret

Title II disability recipients (SSDI and Adult Disabled Child benefits) who appeal Social Security's determinations that they are no longer disabled also have 10 days in which to