Saturday, December 4, 2010

Week8

Today we discussed XPath which is used to model/describe (and query) xml documents. We also discussed Onthology (ES Expert Systems) and how it is shown in a triangel with KB (Knowledge Base), IR (Inference Rules), WM (Working Memory) and ;
> Concept (class)
> Slots (Roles & Properties)
> Facts (Property Restrictions-cardinality,domain,range..)
>Instances of classes

At home I revised XPath and its 7 node types;
root,
element,
attribute,
text,
namespace,
processing-instruction,
comment


CMT3315  –  Lab Session 08 

Quick questions:

1.    You have a set of legal documents. Each has four sections: the title, the case, the background, and the judgement, in that order. Each has been made into an XML document by inserting a prolog and suitable tags. You want to write a CSS file that will display these documents using a suitable browser.
    1. Can you write the CSS file in such a way that it will display the title, then the judgement, then the background, then the case?
HTML file
<html>

  <head>
    <link rel="stylesheet" type="text/css" href="./t1.css" />
  </head>

  <body>
  
   <p class="p1">
      <atitle>my title</atitle>
   </p>
  
   <p class="p2">
      <acase>my case</acase>
   </p>
  
   <p class="p3">
      <abackground>my background</abackground>
   </p>
  
   <p class="p4">
      <ajudjement>my judjement</ajudjement>
   </p>
  
  </body>

</html>

CSS file
  .p1
  {
  position:absolute;
  top:10px;
  }

  .p4
  {
  position:absolute;
  top:40px;
  }

  .p3
  {
  position:absolute;
  top:70px;
  }

  .p2
  {
  position:absolute;
  top:100px;
  }


    1. Can you write the CSS file in such a way that it will display just the title, and the judgement?
  .p2
  {
  display:none;
  }

  .p3
  {
  display:none;
  }


    1. If the CSS file is called legalWrit.css, what processing instruction should you put in the prolog of the XML document(s)?
<?xml-stylesheet href="legalWrit.css" type="text/css"?>


  1. What is the difference between a URI and a URL?
A URI represents a name or identifier possibly with namespace etc. which may or may not really point to a real resource, while a URL identifies an actual resource location or path.


  1. Why does the XML language allow namespaces?
To identify tags that have the same name within an XML file but which refer to a different item of data example an xml file with students and tutors the tag “ID” could reference both a student or a tutor so we can use student:ID and tutor:ID to distinguish between the two.



Longer questions:

1.        Here is a short XML document. Type it out, as a new file in JCreator. Save it under the name memo1.xml in a suitable directory in your file system. Notice that the JCreator editor picks out the different components in different colours, to aid you in detecting errors.
<?xml version="1.0"?>
<?xml-stylesheet href="stylesheet01.css" type="text/css"?>
<!DOCTYPE memo>
<memo>
            <id>Message: 1334</id>
            <date>18 November 09</date>
            <time>09:30</time>
            <from>From: The Managing Director</from>
            <to>To: Heads of all Departments</to>
            <message>We must increase production. And increasing sales would be no bad thing either.</message>
</memo>
Now open another tab in JCreator and type the following style sheet out. Save it under the name stylesheet01.css in the same folder as memo1.xml. Notice that, this time, the editor does not pick out the different components in different colours.
memo {display: block; margin: 1em;}
id {display: block; margin: 1em; font-style: italic; font-size:200%}
date {display: block; margin: 1em;color: "dark blue"; text-align: left;}
time {display: block; margin: 1em;color: aqua; text-align: left;}
from, to {display: block; margin: 1em;color: green; text-align: left;}
message {display: block; margin: 1em;color: blue; text-align: left;}
Now use the Mozilla Firefox browser to view the file memo1.xml.
XML
<?xml version="1.0"?>
<?xml-stylesheet href="tt2.css" type="text/css"?>

<!-- this breaks it on IE8 -->
<!--<!DOCTYPE memo>-->

<html>
  <head>
  </head>

  <body>
    <memo>
      <id>Message: 1334</id>
      <date>18 November 09</date>
      <time>09:30</time>
      <from>From: The Managing Director</from>
      <to>To: Heads of all Departments</to>
      <message>We must increase production. And increasing sales would be no bad thing either.</message>
    </memo>
  </body>
</html>

CSS
memo {display: block; margin: 1em;}
id {display: block; margin: 1em; font-style: italic; font-size:200%}
date {display: block; margin: 1em;color: "dark blue"; text-align: left;}
time {display: block; margin: 1em;color: aqua; text-align: left;}
from, to {display: block; margin: 1em;color: green; text-align: left;}
message {display: block; margin: 1em;color: blue; text-align: left;}

What was the point of putting “display: block” into the CSS file in each of the 6 lines?
To format the way that each data item is displayed.



No comments:

Post a Comment