Processing Xpath/Xquery to Be Aware of Xlink Hyperlinks
Total Page:16
File Type:pdf, Size:1020Kb
2nd EUROPEAN COMPUTING CONFERENCE (ECC’08) Malta, September 11-13, 2008 Processing XPath/XQuery to be Aware of XLink Hyperlinks LULE AHMEDI MENTOR ARIFAJ University of Prishtina, Computer Engineering Kodra e diellit p.n. 10000 Prishtinë, Kosova {lule.ahmedi | mentor.arifaj}@fiek.uni-pr.edu Abstract: - XML Linking Language (XLink) as a W3C recommendation represents the standard way how to use links within XML documents. With these links, it is possible to select arbitrarily narrow content, and not restricted to selecting the whole document as it is the case with HTML hyperlinks. There are few implementations for XLink despite the fact that it is a recommendation since 2001. Most of these implementations are focused on how to handle XLink links while browsing rather then query them. There is an implementation using LDAP that uses other data model than XML and another one that is an extension of eXist a XML database system to support XLinks. We extended another well-known and widely used XPath/XQuery open source system named Saxon-B. The Saxon-B is an in-memory system and is capable to be used with programming languages to support the XML features implemented on it. We describe our extension in several steps and illustrate it with algorithms and samples. We complement the discussion by comparing our system with existing systems (eXist and LDAP), and confirm that our system is a complement and not a duplication of these systems. Keywords: - XML, Querying XML, XLink hyperlinks, XML Applications, LDAP. 1 Introduction 2 XLink Hyperlinks and Current Linking is an important feature of the Web, and with it Bottlenecks the web becomes the single and complex system [14]. Hyperlinks or links are very important part of the web XML Linking Language (XLink) is an XML based [6] and today they are very popular and widely used on language which specifies the standard way how to the Web. XLink presents the standard way of incorporate and use hyperlinks within XML documents. incorporating hyperlinks into XML documents. XLink These XML documents could be located into intranets links are incorporated at XML elements within XML and into the Internet. XLink is a World Wide Web documents. An XML element could be an XLink links Consortium (W3C) recommendation since year 2001 if it consists of the type attribute of the namespace xlink. [1]. Based on our investigation, there are few XLink presents two types of links, simple links with implementations of this recommendation when attribute xlink:type = “simple” and extended links with comparing with other W3C recommendations, attribute value xlink:type=”extended”[1]. especially XPath/XQuery [2][3]. For XLink these XLink simple links are similar with the Hypertext implementations could be partially dedicated only one Markup Language (HTML) hyperlinks. But at simple part of XLink or dedicated for browsers and from the links every element could be a link not only a querying point of view there are very few predefined “a” element as it is for HTML hyperlinks. implementations such as using eXist [5] and With XLink extended links is possible to create more Lightweight Directory Access Protocol (LDAP) [4]. complicated linking structure [1]. At extended links the On the section 2 we describe more details about XLinks XML element containing the attribute xlink:type = and the need for query XML documents that have “extended” serves as a container for other nested XLink links. Also we describe the similarities and elements which should have set the xlink:type attribute differences between our implementation and eXist and to one of these values “locator”, “resource”, “arc” or LDAP implementations. On the section 3 we describe “title”[1]. our steps towards the implementation. And at the end There are numerous systems implementating section 4, we discuss about related work and conclusion XPath/XQuery technology, whereas for XLink, there of our implementation that it is not a duplication of the are only few implementations [3, 2]. For XPath/XQuery existing implementations but a complementary there exists wide range of tools in different platforms implementation for query interlinking XML documents. and build with different programming languages. Based on [2] more of these implementations for XLink are for browsers and few regarding querying of the links. During our investigations we have found that there exist ISSN:1790-5109 217 ISBN: 978-960-474-002-4 2nd EUROPEAN COMPUTING CONFERENCE (ECC’08) Malta, September 11-13, 2008 two implementations for query XML documents in XPath defines 13 axis [17] and the mostly used axis are presence of XLink links. Extension of LDAP [4] to child, attribute, ancestor and descendent [8]. support XPath query at the XLink links is one of them. We base our implementation on the following logical This system is based on another data model than XML model: The XML model is not a tree, but rather a graph data model and it maps XPath query to that data model. with the major part of nodes inter-connected via And the other is extension of eXist system which is a child/attribute arcs, and an additional type of arc native XML database system [5]. The eXist extension is allowed referring into local or remote portions of graph based on a logical model proposed from Wolfgang May nodes. in [7]. From the query (or database) point of view there An XML element declared as XLink link can contain an are not any official drafts [7] or recommendation how to href attribute. This attribute in case of simple links handle interlinked XML documents and these could be specifies the location where the XML element points to, seen as an open issue from the XLink recommendations. and in general it has the form as in Expression 1. So based on facts that XPath/XQuery is widely used and Expression 1: href = uri-reference [4] the need to handle links into XML documents, on the The uri-reference could be expressed as in expression 2. other hand very few existences of the implementations Expression 2: uri-reference = uri#fragment [4] regarding querying these documents, we have Where uri represents the Internet resource and could be implemented an extension of “open-source”[10] system expressed with expression 3 and the fragment is express named Saxon-B. Saxon-B is an XPath 2.0, XQuery 1.0 with XPointer (a W3C recommendation [11]) pointers. and XSLT 2.0 [8], system developed in Java platform Expression 3: uri = sheme://host:port/path [4] and is a main memory XQuery processor or in-memory As our aim is to extend an existing XPath/XQuery processor [9]. For Saxon-B we can say that it is a native system this lead us to a condition that fragment is an XML processor together with eXist processor whereas XPath expression and we based this on the already LDAP is not native XML. The difference between LDAP extension [4]. LDAP and Saxon-B is more explicit as LDAP is based Condition 1: fragment = xpathexpression on another data model than XML based model. The Example 1: xpathexpression = //country/cities/city difference between Saxon-B and eXist could be seen as We have taken the saxon-resources9-0-0-1[10] and “how to use these tools”. Saxon-B can be use as an explore it using NetBeans 6.0.1[12]. extension to the application build with different Example 2: part of the adopted distributed mondial programming tools (Java, C#, etc.) whereas eXist is an database[13] from countries.xml file. XML database system. <country car_code="AL" area="28750"> First, we are aware of possibilities to use Saxon-B in <name>Albania</name> top of another application and then via the application … to execute XPath expressions. <capital xlink:type="simple" Second, simulate executions of XPath expressions and dbxlink:transparent="make-attribute insert-nodes" XPath functions as XQuery expressions [7] from the xlink:href="http://localhost/Mondial- new application. Distributed/Cities/cities- But, this approach could lead us to a more simulation of AL.xml#//cities/city[name='Tirane']"/> an implementation rather than a new extension of an <cities xlink:type="simple" existing XPath/XQuery system. dbxlink:transparent="drop-element insert-nodes" xlink:href="http://localhost/Mondial- Distributed/Cities/cities-AL.xml#//cities/city"/> 3 Extending XPath/XQuery to Model <encompassed xlink:type="simple" XLink Hyperlinks dbxlink:transparent="group-in-element insert-nodes" xlink:href="http://localhost/Mondial- 3.1 The XML Data Model with XLink Distributed/continents.xml#//continents/continent[name Our framework of extending XPath/XQuery bases on ='Europe']" modeling XML documents in presence of XLink links. percentage="100"/> XPath models the XML document [15] as a tree of <neighbor xlink:type="simple" nodes. In presence of links between XML documents, dbxlink:transparent="duplicate-element insert-bodies" the tree model expands to a graph model. In the graph xlink:href="http://localhost/Mondial- model, XPath expressions can still be used for Distributed//countries.xml#//countries/country[@car_co navigation [16], as also stated in the logical model de='GR']" introduced in [5]. borderlength="282"/> <neighbor xlink:type="simple" dbxlink:transparent="duplicate-element insert-bodies" ISSN:1790-5109 218 ISBN: 978-960-474-002-4 2nd EUROPEAN COMPUTING CONFERENCE (ECC’08) Malta, September 11-13, 2008 xlink:href="http://localhost/Mondial- B = False Distributed//countries.xml#//countries/country[@car_co de='MK']" If ( S contains (@xlink:href) ) borderlength="151"/> Let S1 = S (part before @xlink:href with <neighbor xlink:type="simple" added “/string(@xlink:href)” ) dbxlink:transparent="duplicate-element insert-bodies" Let S2 = S (part after @xlink:href) xlink:href="http://localhost/Mondial- Let B = True Distributed//countries.xml#//countries/country[@car_co Else de='YU']" // everything remains as in Saxon-B borderlength="287"/> End If-Else </country> If ( B == True ) First, in order to be handled elements’ attributes derived Let A be the array of results from processing of S1, from XLink recommendation the processors should which could have 0, 1 or more members with values recognize the xlink namespace which most of the time of @xlink:href attribute, in the XML documents it is declared at the beginning of /* the document with expression 4.