Web Data Management XML Data Model 1 Semi-structured Data Model • A data model, based on graphs, for representing both regular and irregular data. • Basic ideas • Self-describing data. The content comes with its own description; – contrast with the relational model, where schema and content are represented separately. • Flexible typing. Data may be typed (i.e., “such nodes are integer values” or “this part of the graph complies to this description”); often no typing, or a very flexible one • Serialized form. The graph representation is associated to a serialized form, convenient for exchanges in an heterogeneous environment. 2 Self-describing data • Starting point: association lists, i.e., records of label-value pairs. {name: "Alan", tel: 2157786, email: "agb@abc.com"} • Natural extension: values may themselves be other structures: {name: {first: "Alan", last: "Black"}, tel: 2157786, email: "agb@abc.com"} • Further extension: allow duplicate labels. {name: “Alan’’, tel: 2157786, tel: 2498762 } 3 Tree-based representation • Data can be graphically represented as trees: label structure can be captured by tree edges, and values reside at leaves. 4 Tree-based representation: labels as nodes • Another choice is to represent both labels and values as vertices. • The XML data model adopts this latter representation. 5 Representation of regular data • The syntax makes it easy to describe sets of tuples as in: { person: {name: "alan", phone: 3127786, email: "alan@abc.com"}, person: {name: "sara", phone: 2136877, email: "sara@xyz.edu"}, person: {name: "fred", phone: 7786312, email: "fd@ac.uk"} } – relational data can be represented – for regular data, the semi-structure representation is highly redundant. 6 Representation of irregular data • Many possible variations in the structure: missing values, duplicates, changes, etc. { person: {name: "alan", phone: 3127786, email: "agg@abc.com"}, person: &314 { name: {first: "Sara", last: "Green" }, phone: 2136877, email: "sara@math.xyz.edu", spouse: &443 }, person: &443 { name: "fred", Phone: 7786312, Height: 183, spouse: &314 }} – Nodes can be identified, and referred to by their identity. Cycles and objects models can be described as well. 7 XML represents Semistructured Data • Do not care about the type of the data • Serialize the data by annotating each data item explicitly with its description (e.g. name, phone, etc.) • Such data is called self-describing • Serialization: convert data into a byte stream that can be easily transmitted and reconstructed at the receiver • Self-describing data wastes space but provides interoperability (required on the web) • Semistructured data models – XML, JSON (Javascript Object Notation) 8 XML as a Semi-structured Data Explained • Missing attributes: – <person> <name> John</name> <phone>1234</phone> </person> – <person><name>Joe</name></person> no phone ! • Repeated attributes – <person> <name> Mary</name> <phone>2345</phone> <phone>3456</phone> </person> 9 XML as a Semistructured Data Explained • Attributes with different types in different objects – <person> <name> <first> John </first> <last> Smith </last> </name> complex name ! <phone>1234</phone> </person> • Nested collections (no 1NF) • Heterogeneous collections: – <db> contains both <book>s and <publisher>s 10 XML in brief • XML is the World-Wide-Web Consortium (W3C) standard for Web data exchange. – XML documents can be serialized in a normalized encoding (typically iso-8859-1, or utf-8), and safely transmitted on the Internet. – XML is a generic format, which can be specialized in “dialects” for specific domain (e.g., XHTML) – The W3C promotes companion standards: DOM (object model), XSchema (typing), XPath (path expression), XSLT (restructuring), Xquery (query language), and many others. • XML is a simplified version of SGML, a long-term used language for technical documents. 11 XML documents • An XML document is a labeled, unranked, ordered tree: – Labeled means that some annotation, the label, is attached to each node. – Unranked means that there is no a priori bound on the number of children of a node. – Ordered means that there is an order between the children of each node. • XML specifies nothing more than a syntax: no meaning is attached to the labels. • A dialect, on the other hand, associates a meaning to labels (e.g., title in XHTML). 12 XML documents are trees XML: person name phone John 3634 row name “John” Sue 6343 Dick 6363 person row row phone name phone 3634 “Sue” name 6343 “Dick” phone 6363 <person> <row> <name>John</name> <phone> 3634</phone></row> <row> <name>Sue</name> <phone> 6343</phone> <row> <name>Dick</name> <phone> 6363</phone></row> </person> Serialized representation 13 XML and Semistructured Data: Similarities and Differences <person id=“o123”> <name> Alan </name> <age> 42 </age> <email> ab@com </email> </person> <person father=“o123”> … </person> father person { person: &o123 { name: “Alan”, age: 42, email: “ab@com” } } { person: { father: &o123 …} } person father name age email name Alan age 42 email ab@com Alan similar on trees, different on graphs 42 ab@com 14 XML describes structured content • Applications cannot interpret unstructured content: The book ‘‘Fundations of Databases’’, written by Serge Abiteboul, Rick Hull and Victor Vianu, published in 1995 by Addison-Wesley • XML provides a means to structure this content: <bibliography> <book> <title> Foundations of Databases </title> <author> Abiteboul </author> <author> Hull </author> <author> Vianu </author> <publisher> Addison Wesley </publisher> <year> 1995 </year> </book> <book>...</book> </bibliography> • Now, an application can access the XML tree, extract some parts, rename the labels, reorganize the content into another structure, etc. 15 Applications associate semantics to XML docs • Letter document <letter> <header> <author>...</author> <date>...</date> <recipient>...</recipient> <cc>...<cc> </header> <body> <text>...</text> <signature>...</signature> </body> </letter> 16 Applications associate semantics to XML docs • Letter style sheet if letter then ... if header then ... if author then ... if date then ... if recipient then ... if cc then ... if body then ... if text then ... if signature then ... • Some software then produces the actual letter to mail or email. 17 Serialized and tree-based forms • The serialized form is a textual, linear representation of the tree; it complies to a (sometimes complicated) syntax; • Tree-based forms implement in a specific context, object-oriented model, the abstract tree representation (Document Object Model) • Typically, an application gets a document in serialized form, parse it in tree form, and serializes it back at the end. 18 Serialized and tree-based forms: text and elements • The basic components of an XML document are element and text. • Here is an element, whose content is a text. • The tree form of the document, modeled in DOM: each node has a type, either Document or Text. <elt_name> Textual content </elt_name> 19 Serialized and tree-based forms: nesting elements • Serialized form: The • Tree-based form: the content of an element is subtree rooted at the the part between the corresponding Element opening and ending node (in DOM) tags <elt1> Textual content <elt2> Another content </elt2> </elt1> 20 Serialized and tree-based forms: attributes • Serialized form: Attributes are pairs of name/value attached to an element • The content of an attribute is always atomic text (no nesting) • Attributes are not ordered, and there cannot be two attributes with the same name in an element <elt1 att1=’12’ att2=’fr’> Textual content </elt1> • Tree-based form: Attributes are special child nodes of the Element node (in DOM) 21 Serialized and tree-based forms: the document root • Document content must always be enclosed in a single opening/ending tag, called the element root • The first line of the serialized form must always be the prologue if there is one: <?xml version="1.0"encoding="utf-8"?> • A document with its prologue, and element root <?xml version="1.0“ encoding="utf-8" ?> <elt> Document content. </elt> • In the DOM representation, the prologue appears as a Document node, called the root node. 22 Web Data Management with XML • Publishing – an XML document can easily be converted to another XML document (same content, but another structure) – Web publishing is the process of transforming XML documents to XHTML. • Integration – XML documents from many sources can be transformed in a common dialect, and constitute a collection. – Search engines, or portals, provide browsing and searching services on collections of XML documents. • Distributed Data Processing – many softwares can be adapted to consume/produce XMLrepresented data. – Web services provide remote services for XML data processing. 23 Web Publishing: restructuring to XHTML • The Web application produces some XML content, structured in some application-dependent dialect, on the server. • In a second phase, the XML content is transformed in an XHTML document that can be visualized by humans. • The transformation is typically expressed in XSLT, and can be processed either on the server or on the client. 24 Web publishing: content + presentation instructions • XML content <bibliography> <book> <title> Foundations of Databases </title> <author> Abiteboul </author> <author> Hull </author> <author> Vianu </author> <publisher> Addison Wesley </publisher> <year> 1995 </year> </book> <book>...</book> </bibliography> • Document in XHTML <h1> Bibliography </h1> <p> <i> Foundations of Databases </i> Abiteboul, Hull, Vianu <br/> Addison Wesley, 1995 </p> <p> <i> Data on the Web </i> Abiteoul, Buneman, Suciu <br/> Morgan Kaufmann, 1999 </p> 25 Web publishing • The same content may be published using different means: – Web publishing: XML XHTML – WAP (Wireless Application Protocol): XML WML 26 Web publishing • Data obtained from a relational database and from XML files • XSLT restructures the XML data • Produces XHTML pages for a browser 27 Web Integration: gluing together heterogeneous sources • The portal receives (possibly continuously) XMLstructured content, each source using its own dialect. • Each feed provides some content, extracted with XSLT or XQuery, or any convenient XML processing tool (e.g., SAX). 28 Data integration 29 Distributed Data Management with XML • XML encoding is used to exchange information between applications. • A specific dialect, WDSL, is used to describe Web Services Interfaces. 30 Exploiting XML documents 31 XML dialects • Dialects define specialized structures, constraints and vocabularies to construct ad hoc XML contents that can be used and exchanged in a specific application area • RSS is an XML dialect for describing content updates that is heavily used for blog entries, news headlines or podcasts. • WML (Wireless Mark-up Language) is used in Web sites by wireless applications based on the Wireless Application Protocol (WAP). • MathML (Mathematical Mark-up Language) is an XML dialect for describing mathematical notation and capturing both its structure and content. 32 XML dialects • Xlink (XML Linking Language) is an XML dialect for defining hyperlinks between XML documents. These links are expressed in XML and may be introduced inside XML documents. • SVG (Scalable Vector Graphics) is an XML dialect for describing two-dimensional vector graphics, both static and animated. With SVG, images may contain outbound hyperlinks in XLinks. 33 XML dialects – SVG example <?xml version="1.0" encoding="UTF-8" ?> <svg xmlns="http://www.w3.org/2000/svg"> <polygon points="0,0 50,0 25,50" style="stroke:#660000; fill:#cc3333;"/> Some SVG text <text x="20" y="40">Some SVG text</text> </svg> 34 XML standards • SAX (Simple API for XML) sees an XML document as a sequence of tokens (its serialization). • DOM (Document Object Model) is an object model for representing (HTML and) XML document independently of the programming language. • XPath (XML Path Language) that we will study, is a language for addressing portions of an XML document. 35 XML standards • XQuery (that we will study) is a flexible query language for extracting information from collections of XML documents. • XSLT (Extensible Stylesheet Language Transformations), that we will study, is a language for specifying the transformation of XML documents into other XML documents. • Web services provide interoperability between machines based on Web protocols. 36 Processing an XML Document with SAX and DOM • A SAX parser transforms an XML document into a flow of events. – Examples of events: start/end of a document, the start/end of an element, a text token, a comment, etc. • Example: Load data in XML format into a relational database 1. when document start is received, connect to the database; 2. when a Movie open tag is received, create a new Movie record; (a) when a text node is received, assign its content to X; (b) when a Title close tag is received, assign X to Movie.Title; (c) when a Year close tag is received, assign X to Movie.Year, etc. 3. when a Movie close tag is received, insert the Movie record in the database (and commit the transaction); 4. when document end is received, close the database connection. 37 Sax • SAX is a good choice when the content of a document needs to be examined once • SAX handler written in Java – It features methods that handle SAX events: opening and closing tags; character data – See next slide 38 import org.xml.sax.*; import org.xml.sax.helpers.LocatorImpl; public class SaxHandler implements ContentHandler { /** Constructor */ public SaxHandler() { super(); } /** Handler for the beginning and end of the document */ public void startDocument() throws SAXException { out.println("Start the parsing of document"); } public void endDocument() throws SAXException { out.println("End the parsing of document"); } /** Opening tag handler */ public void startElement(String nameSpaceURI, String localName, String rawName, Attributes attributes) throws SAXException { out.println("Opening tag: " + localName); // Show the attributes, if any if (attributes.getLength() > 0) { System.out.println(" Attributes: "); for (int index = 0; index < attributes.getLength(); index++) { out.println(" - " + attributes.getLocalName(index) + " = " + attributes.getValue(index)); } } } /** Closing tag handler */ public void endElement(String nameSpaceURI, String localName, String rawName) throws SAXException { out.print("Closing tag : " + localName); out.println(); } /** Character data handling */ public void characters(char[] ch, int start, int end) throws SAXException { out.println("#PCDATA: " + new String(ch, start, end)); }} 39 DOM (Document Object Model) • A DOM parser transforms an XML document into a tree and offers an object API for that tree. • A partial view of the Class hierarchy of DOM 40 Parsing XML Documents A parser checks XML documents for wellformedness or validates it against a schema So, what is parsing? well, in computer terminology.. ‘to analyze or separate (input, for example) into more easily processed components’ XML parsers load XML documents and provide access to it’s contents in the form of objects Parsing XML Documents A Validating Parser: can use a DTD or schema to verify that a document is properly constructed A Non-Validating Parser: only requires the document to be well formed; many free parsers on the Web are non-validating Stream-Based Parsers: read through the document and signal the application every time a new component appears Tree-Based Parsers: read the entire document and give the application a tree structure corresponding to the element structure of the document Parsing XML Documents DOM API: language & platform independent interfaces for accessing & manipulating info. in XML documents Document checked to see if it’s well formed and valid Parser then converts information into a tree of nodes A tree starts at one root node; in DOM terms, called a document object instance You can modify, delete and create leaves and branches on the tree using interfaces in API Parsing XML Documents Titles.xml; a sample XML document <?xml version="1.0" encoding="UTF-8"?> <BookList> <Book> <book_id>BU1111</book_id> <title>Cooking with Computers: Surreptitious Balance Sheets</title> <type>business</type> <pub_id>1389</pub_id> <price>11.95</price> <advance>5000</advance> <royalty>10</royalty> <ytd_sales>3876</ytd_sales> <notes>Helpful hints on how to use your electronic...</notes> <pubdate>1991-06-09T05:00:00</pubdate> </Book> <Book> <book_id>BU7832</book_id> <title>Straight Talk About Computers</title> <type>business</type> <pub_id>1389</pub_id> <price>19.99</price> <advance>5000</advance> <royalty>10</royalty> <ytd_sales>4095</ytd_sales> <notes>Annotated analysis of what computers can do for you</notes> <pubdate>1991-06-22T05:00:00</pubdate> </Book> </BookList> Parsing XML Documents DOM DOM provides interfaces in it’s hierarchy of Node objects Node: an XML Document object created after a DOM parser reads an XML file Inheritance relationship between important interfaces DOM A sample document object tree Methods of Node Object Method Description hasChildNodes() finds out if a Node has children, takes no parameters, returns a Boolean getNodeType() returns the type of a particular Node. The type is a constant integer used to identify different types of Nodes appendChild() adds a new child object, which is passed to the method, to the current Node cloneNode() returns a duplicate of the Node hasAttributes() returns a Boolean true if the Node has any attributes. This method was added in DOM Level 2 insertBefore() takes a new child Node and a reference child Node and inserts the new child Node before the reference Node isSupported() tests whether or not this implementation of the DOM supports a specific feature. This method was added in DOM Level 2 and takes a version number and a feature as parameters normalize() puts all text nodes in the full depth of the sub-tree underneath this Node removeChild() removes the specified child replaceChild() replaces the specified child with the new child passed Methods of Node Object Method Description getAttribute() retrieves the specified attribute. getAttributeNS() retrieves the specified attribute by local name and namespace. This method was added in Level 2. getAttributeNode() retrieves an Attr node by name. getAttributeNodeNS() retrieves an Attr node by local name and namespace. This method was added in Level 2. getElementsByTagName() returns a NodeList of all child elements of a given tag name in the order in which they are encountered. getElementsByTagNameNS() returns a NodeList of all child elements of a given tag by local name and namespace in the order in which they are encountered. This method was added in Level 2. hasAttribute() returns a Boolean true if the specified attribute is present. Returns Boolean false otherwise. hasAttributeNS() returns a Boolean true if the specified attribute, by local name and namespace, is present. Returns Boolean false otherwise. This method was added in Level 2. removeAttribute() removes the specified attribute. removeAttributeNS() removes the attribute specified by local name and namespace. This method was added in Level 2. Methods of Node Object Method Description removeAttributeNode() removes the specified Attr node. setAttribute() adds a new attribute. If an attribute of the same name exists, its value is changed to the specified value. setAttributeNS() adds a new attribute. If an attribute of the same local name and namespace exists, its value is changed to the specified value. This method was added in Level 2. setAttributeNode() adds a new Attr node. If an Attr node of the same name exists, its value is changed to the specified value. setAttributeNodeNS() adds a new Attr node. If an Attr node of the same local name and namespace exists, its value is changed to the specified value. This method was added in Level 2. DOM Node Interface: NodeList is an iterator for a Nodes list A DOM NodeList object NodeList has only a single method, item(); it returns the Node at the indexed position passed to the method SAX SAX Parser: stream in documents according to specific events SAX parser doesn't have a default object model SAX parser read in a XML document and start events based on the following: open or start of elements closing or end of documents #PCDATA and CDATA sections processing instructions, comments & entity declarations 3 steps to using SAX in your applications: creating a custom object model, like a Book class creating a SAX parser creating a document handler to turn your document into instances of your custom object model SAX Document Handler: is a listener for the various events fired by the SAX parser Events are fired based on all registered document event listeners and translated into method calls A SAX event order SAX parser exposes the document as a series of events that are translated into method calls DOM Vs SAX The following are DOM benefits you should focus on: it allows random access to the document complex searches can be easily implemented the DTD or schema is available the DOM is read/write The following list contains some of the most useful benefits of SAX: it can parse files of any size it is a fast processing method you can build your own data structure you can access only a small subset of info. if desired Example Parsers MSXML: first parser which can perform both SAX and DOM-based parsing, from Microsoft Xerces: available in three languages, from the Apache Group at http://xml.apache.org IBM's XML for Java: http:// www.alphaworks.ibm.com/ formula/xml Microstar's Ifred: http://home.pacbell.net/david-b/xml/ Sun's Java API for XML: http://java.sun.com/products/xml Oracle's XML Parser for Java: http://technet.oracle.com/ XPath • Language for expressing paths in an XML document – Navigation: child, descendant, parent, ancestor – Tests on the nature of the node – More complex selection predicates • Means to specify portions of a document • Basic tool for other XML languages: Xlink, XSLT, Xquery 56 XQuery • Query language: “SQL for XML” • Like SQL: select portions of the data and reconstruct a result • Query structure: FLW (pronounced "flower") FOR $p IN document("bib.xml")//publisher LET $b := document("bib.xml)//book[publisher = $p] WHERE count($b) > 100 RETURN $p • • • • $p : scans the sequence of publishers $b : scans the sequence of books for a publisher WHERE filters out some publishers RETURN constructs the result 57 XSLT • Transformation language: “Perl for XML” • An XSLT style sheet includes a set of transformation rules: pattern/template • Pattern: based on XPATH expressions; it specifies a structural context in the tree • Template: specifies what should be produced • Principle: when a pattern is matched in the source document, the corresponding templates produces some data 58 XLINK • XML Linking Language • Advanced hypertext primitives • Allows inserting in XML documents descriptions of links to external Web resources • Simple mono-directional links ala (HREF) HTML • Multidirectional links • XLink relies on XPath for addressing portions of XML documents 59 XLink • Generalizes HTML’s href • XLink links resources, which include documents, audio, video, database data, etc. • Many types: simple, extended, locator, arc, resource, or title <person xmlns:xlink=“http:///.w3.org/1999/xlink” required attributes xlink:type=“simple” xlink:href=http://a.b.c/myhomepage.html xlink:role="http://www.example.com/studentlist" xlink:title=“The Homepage” xlink:show=“replace” xlink:actuate=“onRequest”> optional attributes ..... </person> 60 XLink • The linking element (i.e., person) that references document2 is called a local resource. • The resource referenced is called the remote resource. • Traversal Path between the local and remote resources is to get from resource A to resource B by following the defined link. • Arc: how to traverse a pair of resources, including the direction of traversal and possibly application behavior information as well. • Outbound arc: An arc that has a local starting resource and a remote ending resource • Inbound arc: If an arc's ending resource is local but its starting resource is remote • Third party arc: If neither the starting resource nor the ending resource is local 61 XLink • show attribute specifies how to display a resource when it is loaded and can be – – – – “new”, to display in new window ”replace”, to replace current resource with the linked resource ”embed”, replace current element with the linked resource ”other”, XLink-aware application can decide how to display • actuate attribute specifies when the resource should be retrieved and can be – – – – “onLoad”, retrieve as soon as it is loaded ”onRequest”, retrieve resource by clicking on the link ”other”, XLink-aware applications can decide when to load ”none”, no information when to load the resource 62 XLink • The use of XLink elements and attributes requires declaration of the XLink namespace, <person xmlns:xlink=“http:///.w3.org/1999/xlink”….. • href attribute defines the remote resource's URI • Role attribute is a URI that references a resource that describes the link • Title attribute is a descriptive title for the link. 63 XLink • Extended Links – for linking multiple combinations of local and remote resources. – The figure shows two unidirectional links – With XLink, we can create multidirectional links for traversing between resources 64 XLink • Multidirectional links are not limited to just two resources, but can link any number of resources • The links need not be traversed sequentially. 65 1 <?xml version = "1.0"?> 2 3 <!-- Fig. 14.8 : booklinks.xml --> 4 <!-- XML document containing extended links --> 5 6 <books xmlns:xlink = "http://www.w3.org/1999/xlink" 7 xlink:type = "extended" 8 xlink:title = "Book Inventory"> 9 10 <author xlink:label = "authorDeitel" 11 xlink:type = "locator" 12 xlink:href = "/authors/deitel.xml" 13 xlink:role = "http://deitel.com/xlink/author" 14 xlink:title = "Deitel &amp; Associates, Inc."> 15 <persons id = "authors"> 16 <person>Deitel, Harvey</person> 17 <person>Deitel, Paul</person> 18 </persons> 19 </author> 20 21 <publisher xlink:label = "publisherPrenticeHall" 22 xlink:type = "locator" 23 xlink:href = "/publisher/prenticehall.xml" 24 xlink:role = "http://deitel.com/xlink/publisher" 25 xlink:title = "Prentice Hall"/> 26 27 <warehouse xlink:label = "warehouseXYZ" 28 xlink:type = "locator" 29 xlink:href = "/warehouse/xyz.xml" 30 xlink:role = "http://deitel.com/xlink/warehouse" 31 xlink:title = "X.Y.Z. Books"/> 32 Books – root element A link to the book's authors with information located at /authors/deitel.xml A label's value is used to link one resource to another type locator, which specifies a remote resource When either Deitel, Harvey or Deitel, Paul is selected, the document deitel.xml will be retrieved 66 Book - a local resource 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 <book xlink:label = "JavaBook" xlink:type = "resource" xlink:role = "http://deitel.com/xlink/author" xlink:title = "Textbook on Java"> Java How to Program: Third edition </book> <arcElement xlink:type = "arc" xlink:from = "JavaBook" xlink:arcrole = "http://deitel.com/xlink/info" xlink:to = "authorDeitel" xlink:show = "new" xlink:actuate = "onRequest" xlink:title = "About the author"/> <arcElement xlink:type = "arc" xlink:from = "JavaBook" xlink:arcrole = "http://deitel.com/xlink/info" xlink:to = "publisherPrenticeHall" xlink:show = "new" xlink:actuate = "onRequest" xlink:title = "About the publisher"/> <arcElement xlink:type = "arc" xlink:from = "warehouseXYZ" xlink:arcrole = "http://deitel.com/xlink/info" xlink:to = "JavaBook" xlink:show = "new" xlink:actuate = "onRequest" xlink:title = "Information about this book"/> can be linked to (or from) an author or publisher create an outbound arc between the book local resource and the author remote resource arcrole provides information about the book's author create an outbound arc between the book local resource and the publisher remote resource an inbound arc, that has a starting resource that is remote, i.e., warehouseXYZ and an ending resource that is 67 local,i.e. JavaBook XLink 64 <arcElement xlink:type = "arc" 65 xlink:from = "publisherPrenticeHall" 66 xlink:arcrole = "http://deitel.com/xlink/stock" 67 xlink:to = "warehouseXYZ" 68 xlink:show = "embed" 69 xlink:actuate = "onLoad" 70 xlink:title = "Publisher&apos;s inventory"/> 71 72 </books> - a third-party arc, that has starting and ending resources that are both remote - Attribute show has value embed, which indicates that the ending resource should replace the starting resource when the link is traversed - Attribute actuate has value onLoad, so upon loading the XML document, the link is traversed - Because we consider the relationship between the publisher and warehouse as being different than the previous three arcs, we provide a different arcrole value for this link 68 XPointer • An extension of XPath • Usage: – href=www.a.b.c/document.xml#xpointerExpr • XPointer can link to – specific locations (i.e., nodes in an XPath tree), or even – ranges of locations, in an XML document. • XPointer also adds the ability to search XML documents by using string matching. 69 XPointer • Pointing to a point (=XML element or character) 1 2 3 4 5 6 7 8 9 <?xml version = "1.0"?> <!-- Fig. 14.14 : contacts.xml --> <!-- contact list document --> <contacts> <contact id = "author01">Deitel, Harvey</contact> <contact id = "author02">Deitel, Paul</contact> <contact id = "author03">Nieto, Tem</contact> </contacts> • Full XPointer form xlink:href = "/contacts.xml#xpointer(//contact[@id = 'author02'])" • The name xpointer—called a scheme 70 XPointer • If a document's unique identifier is referenced in an expression such as xlink:href = "/contacts.xml#xpointer(id('author01‘))" • bare-name XPointer address – simplified expression xlink:href = "/contacts.xml#author01" • Child sequence: e.g. #xpointer( /1/3/2/5), #xpointer( /bib/book[3]) • Pointing to a range: e.g. #xpointer(id(3652 to 44)) • Most interesting examples use XPath 71