Friday, December 17, 2010

Week9

This week's lesson was on XLinks & XPointers which are a richer form of hyperlinks with more properties (attributes) and can be bidirectional. Ordinary tags can point to another document (or within the same document) by using the 'name' anchor in the destination as follows:

the source link; <A href="www.....com/page1.html # location1">click</A>
the destination link; <A name="location1">destination text</A>

The above are 'simple links' but XML allows also 'extended' links which provide much more functionality.
  • outbound links have a local starting resource and a remote ending resource
  • inbound links have a remote starting resource and a local ending resource
  • third-party if starting and ending resource are both remote
Extended links;
  • can be bi-directional
  • may connect more than 2 documents
  • the specification of the link may be in either of the 2 documents or in another one
Some important atributes of extended links;
  • type: simple, extended, arc, locator
  • href: URL
  • label: identifier
  • to: destination location
  • from: source location
  • show: replace, new, embed
  • actuate: onRequest, onLoad
  • role: points to a description URL
  • title: a description

revised xml & css with these;
xml file:
<?xml version="1.0" ?>
<?xml-stylesheet href="t3.css" type="text/css"?>
<!--<!DOCTYPE legalDoc>-->
<legalDoc>
 <title>my title</title>
 <case>my case</case>
 <background>my background</background>
 <judjement>my judjement</judjement>
</legalDoc>

css file:
case {
color: #FF0000;
}
judjement {
color: #0000FF;
}


CMT3315  –  Lab Session 09

Quick question:

  1. Suppose that a CSS file is used to determine how an XML document will appear when viewed in a browser. Suppose that the CSS file contains two rules, one dictating that a particular piece of text will appear in bold type, the other dictating that it will not. What will happen?
       The latter rule (NOT bold) will be executed
  1. An XML document contains the sentence “The grand old Duke of York, he had 10000 men.” Would XPath be able to extract the piece of data “10000” from such a document?
       I think NO?


Longer question:
Provide XPath expressions which will do the following:
a)        Select all the elements subordinate to the root node.
//*
b)        Select all track elements that have a total attribute with the value of 5.
//track/[@total="5"]
c)        Select all elements that contain the word “Penderecki” in their title.
//CD[contains(title()=“Penderecki”)]
d)       Select any elements that have titles with greater than 11 characters.
//CD[string-length(title())>5]
e)        Select all the siblings of the first cd element.
//CD[1]/following-sibling::*

No comments:

Post a Comment