What is XLink? What is XPointer?

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

Dr. Alexandra I. Cristea CS 253: Topics in Database Systems: XPath, NameSpaces.
What is XML? a meta language that allows you to create and format your own document markups a method for putting structured data into a text file; these.
XQuery John Annechino Steven Pow. Agenda What is XQuery? Uses of XQuery XQuery vs. XSLT Syntax –Built-In Functions –FLWOR –if-then-else –User-Defined.
XQuery Or, what about REAL databases?. XQuery - its place in the XML team XLink XSLT XQuery XPath XPointer.
XQUERY. What is XQuery? XQuery is the language for querying XML data The best way to explain XQuery is to say that XQuery is to XML what SQL is to database.
1 XQuery Web and Database Management System. 2 XQuery XQuery is to XML what SQL is to database tables XQuery is designed to query XML data What is XQuery?
XLink & XPointer ShengWu. Contents Covered XLink –XLink Versus HTML links –Linking Elements –Simple Links –Link Behavior –Extended Links.
XQL (XML Query Language) Jonathan Robie (Software AG) Eduard Derksen (CSCIO) Peter Fankhauser (GMD-IPSI) Ed Howland (DEGA) Gerald Huck (GMD-IPSI) Ingo.
1 COS 425: Database and Information Management Systems XML and information exchange.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Introduction to XML This material is based heavily on the tutorial by the same name at
Overview of XPath Author: Dan McCreary Date: October, 2008 Version: 0.2 with TEI Examples M D.
PubMed/How to Search, Display, Download & (module 4.1)
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Pemrograman Berbasis WEB XML part 2 -Aurelio Rahmadian- Sumber: w3cschools.com.
Xpath Xlink Xpointer Xquery Sources:
IS432 Semi-Structured Data Lecture 5: XSLT Dr. Gamal Al-Shorbagy.
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
WORKING WITH XSLT AND XPATH
Session II Chapter 2 – Chapter 2 – XSLhttp://
Bare bones notes. Suggested organization for main folder. REQUIRED organization for the 115 folder.
Introduction to HTML. What is a HTML File?  HTML stands for Hyper Text Markup Language  An HTML file is a text file containing small markup tags  The.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Database Systems Part VII: XML Querying Software School of Hunan University
Submitted To: Ms. Poonam Saini, Asst. Prof., NITTTR Submitted By: Rohit Handa ME (Modular) CSE 2011 Batch.
XML Query: xQuery Reference: Xquery By Priscilla Walmsley, Published by O’Reilly.
Introducing XLink and XPointer ©NIITeXtensible Markup Language/Lesson 10/Slide 1 of 23 Objectives In this lesson, you will learn to: * Identify the types.
What is XLink? XLink is short for XML Linking Language XLink is used to create hyperlinks in XML documents Any element in an XML document can behave as.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Linking XML Documents Ellen Pearlman Eileen Mullin Programming the Web.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
CHAPTER TWO HTML TAGS. 1.Basic HTML Tags 1.1 HTML: Hypertext Markup Language  HTML stands for Hypertext Markup Language.  It is the markup language.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
Querying XML, Part II Zachary G. Ives University of Pennsylvania CIS 455 / 555 – Internet and Web Systems February 5, 2008.
1 Lesson 6 Introducing JavaScript HTML and JavaScript BASICS, 4 th Edition.
 XML derives its strength from a variety of supporting technologies.  Structure and data types: When using XML to exchange data among clients, partners,
Digital Multimedia, 2nd edition Nigel Chapman & Jenny Chapman Chapter 14 This presentation © 2004, MacAvon Media Productions XML.
XQUERY The contents of this slide are obtained from various sources including, Wikipedia, W3School, Stanford website etc. January 2011 Dr.Kwanchai Eurviriyanukul.
XML. What is XML? XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display data.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
Web Architecture & HTML
XML: Extensible Markup Language
XML University Of Benghazi IT Faculty Computer Networks and Communications Department Introduction to Internet Programming(CN281)
XML Parsers.
XML Related Technologies
XML and XPath.
Querying and Transforming XML Data
WORKING WITH NAMESPACES
Chapter Eight Interoperability How to Build a Digital Library
DHTML & XML.
Session IV Chapter 16 – XQuery
2017, Fall Pusan National University Ki-Joune Li
{ XML Technologies } BY: DR. M’HAMED MATAOUI
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
By HITESHWAR KUMAR AZAD Ph.D Scholar
WEBSITE DESIGN Chp 1
Basic HTML and Embed Codes
Session I Chapter 1 – Writing XML
PHP.
Session I Chapter 1 – Writing XML
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Understand basic HTML and CSS terminology, concepts, and basic operations. Objective 3.01.
XML: Introduction to XML
CSE591: Data Mining by H. Liu
Lesson 2: HTML5 Coding.
Session II Chapter 16 – XQuery
New Perspectives on XML
Presentation transcript:

What is XLink? What is XPointer? XLink is short for XML Linking Language XLink is used to create hyperlinks in XML documents Any element in an XML document can behave as a link. Xlink elements that specify linking information are called linking elements XLink supports simple links (like HTML) and extended links (for linking multiple resources together) With XLink, the links can be defined outside the linked files XLink is a W3C Recommendation XLink is capable of linking more than just documents; XLink links resources which includes documents,audio,video,database data,etc. Web Browsers will eventually support XLink. However,XLink is intended for a broader base of applications, not just Web browsers. What is XPointer? XPointer is short for XML Pointer Language XPointer allows the links to point to specific parts of an XML document XPointer uses XPath expressions to navigate in the XML document XPointer is a W3C Recommendation .

XLink Syntax In XML documents, you can use whatever element names you want - therefore it is impossible for browsers to predict what hyperlink elements will be called in XML documents. The solution for creating links in XML documents was to put a marker on elements that should act as hyperlinks. <?xml version="1.0"?> <homepages xmlns:xlink="http://www.w3.org/1999/xlink"> <homepage xlink:type="simple" xlink:href="http://www.w3schools.com">Visit W3Schools</homepage> <homepage xlink:type="simple" xlink:href="http://www.w3.org">Visit W3C</homepage> xlink:show="new"> </homepages> To get access to the XLink attributes and features we must declare the XLink namespace at the top of the document.The XLink namespace is: "http://www.w3.org/1999/xlink". The xlink:type and the xlink:href attributes in the <homepage> elements define that the type and href attributes come from the xlink namespace. The xlink:type="simple" creates a simple, two-ended link (means "click from here to go there"). The href attribute is required. We will look at multi-ended (multidirectional) links later.

XML Inclusions (XInclude) The xlink:show attribute is set to "new". This means that the link should open in a new window. We could have set the value of the xlink:show attribute to "embed". This means that the resource should be processed inline within the page. When you consider that this could be another XML document and not just an image, you could, for example, build a hierarchy of XML documents. With XLink, you can also specify WHEN the resource should appear. This is handled by the xlink:actuate attribute. xlink:actuate="onLoad" specifies that the resource should be loaded and shown when the document loads. However, xlink:actuate="onRequest" means that the resource is not read or shown before the link is clicked. This is very handy for low-bandwidth(infornation carrying capacity of a line) settings. XML Inclusions (XInclude) Concept was introduced to add one XML document inside another , an include element is used. An include element is any XML element that has particular attributes from the namespace http://www.w3.org/1999/XML/xinclude. <includer xmlns : xinclude = “http : // www.w3.org/1999/XML/xinclude” xinclude : href = “test.xml” xinclude : parse = “xml”/> Includes the XML document test.xml in the current XML document .Element includer is an include element , with the required XInclude href attribute for referencing an XML document.To include portions of another XML document,Xpointer can be used in the xinclude attribute href .The optional xinclude attribute parse can have value xml or text . The default value ,xml parses the XML document as XML for inclusion ; thus any entities,include elements and other parsable items are processed before being embedded into xml document .Using the value text in the parse attribute incorporates the document referenced as plain –text character data ,which is not parsed. Xinclude differs from xlink : show = “ embed” in that it merges the tree structures of the two documents into a single tree.

Pointer Syntax Sometimes it is more useful to point to more specific content. For example, let's say that we want to link to the third item in a particular list, or to the second sentence of the fifth paragraph. This is easy with XPointer. If the hyperlink points to an XML document, we can add an XPointer part after the URL in the xlink:href attribute,to navigate (with an XPath expression) to a specific place in the document. For example, in the example below we use XPointer to point to the fifth item in a list with a unique id of "rock": href=http://www.example.com/cdlist.xml#id('rock').child(5,item)

XPointer Example <?xml version="1.0" encoding="ISO-8859-1"?> <dogbreeds> <dog breed="Rottweiler" id="Rottweiler">   <picture url="http://dog.com/rottweiler.gif" />   <temperament>Confident, bold, alert and imposing, the Rottweiler   is a popular choice for its ability to protect....</temperament> </dog> </dogbreeds> <?xml version="1.0" encoding="ISO-8859-1"?> <mydogs xmlns:xlink="http://www.w3.org/1999/xlink"> <mydog xlink:type="simple"   xlink:href="http://dog.com/dogbreeds.xml#Rottweiler">   <description xlink:type="simple"   xlink:href="http://myweb.com/mydogs/anton.gif">   Anton is my favorite dog. He has won a lot of.....   </description> </mydog> So the xlink:href attribute would look like this: xlink:href="http://dog.com/dogbreeds.xml#xpointer(id('Rottweiler'))" However, XPointer allows a shorthand form when linking to an element with an id. You can use the value of the id directly, like this: xlink:href="http://dog.com/dogbreeds.xml#Rottweiler"

<?xml version = “1.0”?> <!- - contacts.xml contact list document This is a comment in XML. - - > <contacts> <contact id = “author01”>Dietel ,Harvery</contact> <contact id = “author02”>Dietel , Paul </contact> </contacts> With XLink , we can refer the entire contact list with the URI xlink : href = “ /contacts.xml ” We can use Xpointer expression xlink:href = “/contacts.xml#xpointer(//contact[@id = ‘author02’])” The name xpointer called a scheme expresses the full Xpointer form. To reference the contact element with an id of author02 Xpointer also provides abbreviations for expressions that use attribute id. For example , if a documents unique identifier is referenced in any expression such as xlink : href = “/contacts.xml#xpointer(id(‘author01’])” The expression can be simplified by writing :- xlink : href = “/contacts.xml#author01” which is a bare name Xpointer address.

XQuery XQuery is to XML what SQL is to database tables. XQuery was designed to query XML data.,XQuery is built on XPath expressions XQuery is supported by all major databases,XQuery is a W3C Recommendation XQuery is a language for finding and extracting elements and attributes from XML documents XQuery is case sensitive .SQL keywords are not case sensitive. XQuery can be used to:- Extract information to use in a Web Service ,Generate summary reports Transform XML data to XHTML, Search Web documents for relevant information When the data is measured in gigabytes , creating an in-memory DOM becomes impractical in many situations

We will use the following XML document in the examples below "books.xml": <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING">   <title lang="en">Everyday Italian</title>   <author>Giada De Laurentiis</author>   <year>2005</year>   <price>30.00</price> </book> <book category="CHILDREN">   <title lang="en">Harry Potter</title>   <author>J K. Rowling</author>   <year>2005</year>   <price>29.99</price> </book> <book category="WEB">   <title lang="en">Learning XML</title>   <author>Erik T. Ray</author>   <year>2003</year>   <price>39.95</price> </book> </bookstore>

The doc( ) function is used to open the "books.xml" file: doc("books.xml")/bookstore/book/title(/bookstore selects the bookstore element, /book selects all the book elements under the bookstore element, and /title selects all the title elements under each book element) The XQuery above will extract the following: <title lang="en">Everyday Italian</title> <title lang="en">Harry Potter</title> <title lang="en">XQuery Kick Start</title> <title lang="en">Learning XML</title> The following predicate is used to select all the book elements under the bookstore element that have a price element with a value that is less than 30: doc("books.xml")/bookstore/book[price<30] <book category="CHILDREN">   <title lang="en">Harry Potter</title>   <author>J K. Rowling</author>   <year>2005</year>   <price>29.99</price> </book>

XQuery FLWOR Expressions They are power of XQuery. It owes much to the SELECT statement in SQL. doc("books.xml")/bookstore/book[price>30]/title The following FLWOR expression will select exactly the same as the path expression above: for $x in doc("books.xml")/bookstore/book where $x/price>30 return $x/title The result will be: <title lang="en">Learning XML</title> With FLWOR you can sort the result: for $x in doc("books.xml")/bookstore/book where $x/price>30 order by $x/title return $x/title FLWOR is an acronym for "For, Let, Where, Order by, Return". The for clause selects all book elements under the bookstore element  into a variable called $x. The where clause selects only book elements with a price element with a value greater than 30. The order by clause defines the sort-order. Will be sort by the title element. The return clause specifies what should be returned. Here it returns the title elements. The result of the XQuery expression above will be:

</ul>The result will be (an HTML list): Now we want to list all the book-titles in our bookstore in an HTML list. We add <ul> and <li> tags to the FLWOR expression: <ul> { for $x in doc("books.xml")/bookstore/book/title order by $x return <li>{$x}</li> } </ul>The result of the above will be: <ul> <li><title lang="en">Everyday Italian</title></li> <li><title lang="en">Harry Potter</title></li> <li><title lang="en">Learning XML</title></li> </ul>Now we want to eliminate the title element, and show only the data inside the title element: <ul> { for $x in doc("books.xml")/bookstore/book/title order by $x return <li>{data($x)}</li> } </ul>The result will be (an HTML list): <ul> <li>Everyday Italian</li> <li>Harry Potter</li> <li>Learning XML</li> </ul>

XQuery Conditional Expressions "If-Then-Else" expressions are allowed in XQuery. Look at the following example: for $x in doc("books.xml")/bookstore/book return if ($x/@category="CHILDREN") then <child>{data($x/title)}</child> else <adult>{data($x/title)}</adult> Notes on the "if-then-else" syntax: parentheses around the if expression are required. else is required, but it can be just else ( ). The result of the example above will be:---- <adult>Everyday Italian</adult> <child>Harry Potter</child> <adult>Learning XML</adult>

XQuery Adding Elements <html> <body> <h1>Bookstore</h1> <ul> { for $x in doc("books.xml")/bookstore/book order by $x/title return <li>{data($x/title)}. Category: {data($x/@category)}</li> } </ul> </body> </html> <html> <body> <h1>Bookstore</h1> <ul> <li>Everyday Italian. Category: COOKING</li> <li>Harry Potter. Category: CHILDREN</li> <li>Learning XML. Category: WEB</li> <li>XQuery Kick Start. Category: WEB</li> </ul> </body>

XQuery Adding Attributes Next, we want to use the category attribute as a class attribute in the HTML list: <html> <body> <h1>Bookstore</h1> <ul> { for $x in doc("books.xml")/bookstore/book order by $x/title return <li class="{data($x/@category)}">{data($x/title)}</li> } </ul> </body> </html>The XQuery expression above will generate the following result: <html> <body> <h1>Bookstore</h1> <ul> <li class="COOKING">Everyday Italian</li> <li class="CHILDREN">Harry Potter</li> <li class="WEB">Learning XML</li> <li class="WEB">XQuery Kick Start</li> </ul> </body> </html>

for $x in (1 to 5) return <test>{$x}</test> Selecting and Filtering Elements As we have seen in the previous chapters, we are selecting and filtering elements with either a Path expression or with a FLWOR expression. Look at the following FLWOR expression: for $x in doc("books.xml")/bookstore/book where $x/price>30 order by $x/title return $x/title for - (optional) binds a variable to each item returned by the in expression let - (optional) where - (optional) specifies a criteria order by - (optional) specifies the sort-order of the result return - specifies what to return in the result The for Clause The for clause binds a variable to each item returned by the in expression. The for clause results in iteration. There can be multiple for clauses in the same FLWOR expression. To loop a specific number of times in a for clause, you may use the to keyword: for $x in (1 to 5) return <test>{$x}</test> Result:- <test>1</test> <test>2</test> <test>3</test> <test>4</test> <test>5</test>

The at keyword can be used to count the iteration: for $x at $i in doc("books.xml")/bookstore/book/title return <book>{$i}. {data($x)}</book>Result: <book>1. Everyday Italian</book> <book>2. Harry Potter</book> <book>3. Learning XML</book>It is also allowed with more than one in expression in the for clause. Use comma to separate each in expression: for $x in (10,20), $y in (100,200) return <test>x={$x} and y={$y}</test> Result: <test>x=10 and y=100</test> <test>x=10 and y=200</test> <test>x=20 and y=100</test> <test>x=20 and y=200</test> The let clause allows variable assignments and it avoids repeating the same expression many times. The let clause does not result in iteration. let $x := (1 to 5) return <test>{$x}</test>Result: <test>1 2 3 4 5</test> The where Clause The where clause is used to specify one or more criteria for the result: where $x/price>30 and $x/price<100The order by Clause

The order by clause is used to specify the sort order of the result The order by clause is used to specify the sort order of the result. Here we want to order the result by category and title: for $x in doc("books.xml")/bookstore/book order by $x/@category, $x/title return $x/title <title lang="en">Harry Potter</title> <title lang="en">Everyday Italian</title> <title lang="en">Learning XML</title> <title lang="en">XQuery Kick Start</title> The return Clause The return clause specifies what is to be returned. for $x in doc("books.xml")/bookstore/book return $x/title <title lang="en">Everyday Italian</title> <title lang="en">Harry Potter</title> <title lang="en">XQuery Kick Start</title> <title lang="en">Learning XML</title>

Examples of Function Calls XQuery Functions XQuery includes over 100 built-in functions. There are functions for string values, numeric values, date and time comparison, node and QName manipulation, sequence manipulation, Boolean values, and more. You can also define your own functions in XQuery. Examples of Function Calls A call to a function can appear where an expression may appear. Look at the examples below: Example 1: In an element <name>{uppercase($booktitle)}</name> Example 2: In the predicate of a path expression doc("books.xml")/bookstore/book[substring(title,1,5)='Harry'] Example 3: In a let clause let $name := (substring($booktitle,1,4))

The concat( ) function <?xml version = ‘1.0’?> <Parts> <Part>To be or not to be , </Part> <Part> that is the question !</Part> </Parts> The saying Asaying.xquery , is shown here <Asaying> { for $a in doc(“Parts.xml”)/Parts/Part[1] for $b in doc(“Parts.xml”)/Parts/Part[2] return concat($a , $b) } </Asaying>

XQuery User-Defined Functions If you cannot find the XQuery function you need, you can write your own. User-defined functions can be defined in the query or in a separate library. Syntax declare function prefix:function_name($parameter AS datatype) AS returnDatatype {  ...function code here... } Notes on user-defined functions: Use the declare function keyword The name of the function must be prefixed The data type of the parameters are mostly the same as the data types defined in XML Schema The body of the function must be surrounded by curly braces Example of a User-defined Function Declared in the Query declare function local:minPrice($p as xs:decimal?, $d as xs:decimal?) AS xs:decimal? { let $disc := ($p * $d) div 100 return ($p - $disc) } Below is an example of how to call the function above: <minPrice>{local:minPrice($book/price,$book/discount)}</minPrice>