Wednesday 31 March 2010

CMT3315 – Laboratory 17 – 3 March ’10

Quick Questions

1. The reason is that CSS is much easier to use and learn, which makes it easier to maintain. CSS does have some
limitation which is why its sensible to use CSS when you can but use XSL when you need it.

2.They both work and are legitament syntax, so therefore it doesnt matter which one you chose.

Longer Question

1. The following is used to display pieces of data from the xml document:
//policies/policy/policyholder/
/policies/policy/@type
/policies/policy/claims/claim/year
/policies/policy/claims/claimdetail

Below are the more simple ways of doing it:
//policy-holder
//@type
//year
//details

Lecture Reflection-WEEK 17 – Function Elements of XSL

This is an extension of the past week where insights to the functional elements of XSL were looked at.

Here is a list of the functional elements of XSL that was discussed in class during week 17: -


1 <xsl:value-of> element can be used to extract the value of an XML element and add it to the output stream of the transformation.

2 <xsl:for-each> element can be used to select every XML element of a specified node-set.

3 <xsl:sort> element is used to sort the output.

4 <xsl:if> element is used to put a conditional test against the content of the XML file.

5 <xsl:choose> element is used in conjunction with <xsl:when> and <xsl:otherwise> to express multiple conditional tests.


The following code snippet example is from my coursework for this module which required XSL: -



<xsl:choose>

<xsl:when test="@malady = 'chest affections'">

<td bgcolor="#ff00ff">

<xsl:value-of select="@malady"/></td>

<xsl:otherwise>

<td>"no catagory"</td>




www.ronnysmarket.com
www.ronnysmarket.com/catalog/main

http://www.ronnysmarket.com
http://www.ronnysmarket.com/catalog/main

CMT3315 – Laboratory 16 – 23 February ’10

Quick Questions

1. The JDK package called JAXP contains classes that provides three XML parsers which are “DOM”,”SAX” AND “STAX”

2. A DOM parser is liable to cause problems as the XML document when parsed into a DOM object will become larger than the existing file. This will be stored into the computers primary memory such as the “RAM” which will hinder the performance. The computer could crash as a result. The alternative to using a DOM parser is an SAX parser which only views the content bit by bit.

Longer Questions

A) The “endElement” prints out the value of “”qualifiedName” which is passed into the method “endElement” as an argument.

B) The startElement has a “for loop” which gets the values from the array attribute“a”. In this case the values from the getQName() and getValue() method’s are being retrieved and the for loop is being used to access every position of the array.

C) The “characters()” method takes 3 arguments and one of which is an array called “ch”. This method first turns array or characters “ch” into string “claimString” and then prints out part of the string that we made.

Lecture Reflection-WEEK 16 – XML Transformation (XSL)

In this lecture we had a recap on XSL (studied first in week3).

XSL is able to:

1 Transform XML documents into new XML documents.
2 Generate web pages from XML documents as well as HTML or XHTML.
3 Generate PDF documents from XML documents.

During this lesson we looked at examples of XSL and XPATH and I found it so much easier to understand because of the greater knowledge I have on this subject as opposed to what I did in week 3 (when we first looked at and studied XSL).

http://www.ronnysmarket.com/
http://www.ronnysmarket.com/catalog/main

CMT3315 – Laboratory 15 – 10 February ’10

Quick Questions

1. A DOM is an interface that allows scripts and programs to dynamically access and update contents, style and the structure of documents. It defines the way in which a document is accessed by also defining the logical structure of documents.

2. XHTML is a stricter and cleaner version of HTML. With normal html you can have certain tags that do not have a closing tag but with XHTML closing tags are enforced and results in a much cleaner and tidier document.


Longer Questions

1.
a) The line bellow is an XML declaration used for XHTML documents

<?xml version="1.0"?>                

b) The line bellow indicates the DOCTYPE and states where to find the DTD file. This DOCTYPE is used to validate the document as correct XHTML.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"

"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">



c) The line bellow specifies the xml namespace for a document, and is required in XHTML documents

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">


2.The 10 lines on the next page are javascript code and the function of the code will in the end will output information obtained from the document using the “documentwrite()” function. The document write function is the equivalent of the “echo” function from the server side scripting language known as PHP in the sense that it is used to output information.

3. The line “<-- and a line //-->”, is a comment.


Lecture Reflection-WEEK 15 - SAX

In the mid 1998 XML parser was developed which is a type of SAX. This was developed before the DOM was published by the W3C organisation.
The benefits that SAX parsers have over DOM-style parsers such as the quantity of memory that a SAX parser must use in order to function is typically much smaller than that of a DOM parser. The Document Object Model must be built in the computer’s memory before any data is extracted which might be slow if used with a large XML document. This could result in exceeding the computer’s memory limit causing errors such as system crash. Sax is an event driven parser and works in a more linear format and responds to commands as they come.

The following shows how SAX handles code


XML document: -


<?xml version="1.0"?>

<doc><para>Hello, world! </para></doc>


SAX will break the structure down into a series of linear events: -

1 start document
2 start element: doc
3 start element: para
4 characters: Hello, world!
5 end element: para
6 end element: doc
7 end document

Following methods required for the program to use the parser: -

1 characters( ) :Receives notification of the character data inside an element.
2 startElement( ) :Receives notification of the start of an element.
3 endElement( ) :Receives notification of the end of an element.
4 startDocument( ) :Receives notification of the start of a document.
5 endDocument( ) :Receives notification of the end of a document.
6 processingInstruction( ) :Receives notification of a processing instruction.
http://www.ronnysmarket.com/
http://www.ronnysmarket.com/catalog/main

CMT3315 – Laboratory 14 – 27 January ’10

Quick Questions

1. The reason we would want to convert XML into a Document Object Model is so that we can access the nodes and manipulate their data. This can be done by using suitable languages such as javaScript as long as the document is a DOM. We can also see the document as a tree structure.

2.Object oriented programming ensures objects are a self contained portion of a program that possesses properties and methods. Therefore when an xml document is converted into a DOM object, you would expect it to possess the property that told you what the prior element in the document was.

3. Other languages will be able to able to access the content of a DOM but the characterisitics of these languages require object orientation. Languages such as Perl, python and java will be able to access DOM.


Longer Questions

a)

<?xml version="1.0"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

</xs:schema>



b)


c)

<xs:complex Type name=”electronice_payment_type”>

</xs:element>

<xs:element Type name”electronic_payment_type”/>

<xs:sequence>

<xs:element name”Sender”type=”institution_type”/>

<xs:element name”Reciever”type=”institution_type”/>

<xs:element name”Transaction”type=”institution_type”

maxOccurs=”unbounded”/>

</xs:sequence>



d)



e)


f)
xs:complexType name=”transection_type”

xs:all>

xs:slement name=”number” type=”xs:integer”/>

xs:element name=”amount”>

xs:simpleType>

xs:restrcition base=”xs:decimal”>

xs:fractionDigits value”2”>

/xs:restriction>



xs:element name=”date” type=”xs:”>

xs:element name=”recounciled” type=”xs:boolean”>

/xs:all>




g)


h)


xs:complex Type name=”Institution”

xs:all>

xs:slement name=”company” type=”xs:string”/>

xs:element name=”Account” type="xs:string">

xs:element name=”account number” type="xs:integer">

xs:element name=”address” type="xs:string">



/xs:all>



</xs:complexType>



i)


j)


<xs:element name="Address">

  <xs:complexType>



    <xs:sequence>

      <xs:element name="Line 1" type="string"/>

    <xs:element name="Line 2" type="string"/>

    <xs:element name="city" type="string"/>

    <xs:element name="Postcode" type="string"/>

    </xs:sequence>



  </xs:complexType>

</xs:element>



Lecture Reflection-WEEK 13 – 14 – XML DOM


During the two weeks of week 13 and week 14 we did studies on DOM. DOM provides a practical way for modification as well as the creation of XML documents. This works by creating objects that represent XML documents of components of the document, whereby allowing the DOM access to manipulate the properties contained within the object. The XML DOM defines a standard way for accessing and manipulating XML documents and it is a W3C standard, The DOM presents an XML document as a tree-structure.

DOM is separated into 3 different parts / levels:

1. Core DOM - standard model for any structured document.
2. XML DOM - standard model for XML documents.
3. HTML DOM - standard model for HTML documents.

Any computer can operate DOM, but the use of JavaScript would be ideal to use as it is simple, free to use and ALL modern web browsers support this. According to DOM, everything in an XML document is a node.

DOM States: -

• The DOM models an XML document as a hierarchy of nodes.
• In fact, everything in an XML document is a node.
• At the top of the tree is a document node.
• Every other node is a child node to some other node.
• The elements are element nodes
• Each piece of text is a text node
• Each attribute is an attribute node
• Each comment is a comment node

Here is an example of how to make an item a DOM object: -


function loadXMLDoc(docname)

{

   if (window.XMLHttpRequest)

   {

      xhttp=new XMLHttpRequest();

   }

   else

   {

      xhttp=new ActiveXObject("Microsoft.XMLHTTP");

   }

   xhttp.open("GET",docname,false);

   xhttp.send("");

   return xhttp.responseXML;

}


Once the XML document is loaded, we can direct the XML document by using a series of functions.

For Example

x.getElementsByTagName(name) - gets all elements with a specified tag name.
x.appendChild(node) - inserts a child node to x.
x.removeChild(node) - removes a child node from x.

http://www.ronnysmarket.com/
http://www.ronnysmarket.com/catalog/main

CMT3315 – Laboratory 13 – 20 January ’10

Quick Questions

1. A "complex type" Defines a complex type element whereas a "simple type" defines a simple type.
Simple type specifies the constraints and information about the values of attributes or text only elements, Whereas a complex type can contains elements and children’s.

2. XML schema's are defined as XML documents, can be checked by XML parser and edited by XML editor which is why it is advantageous.

3.Three random predefined data types within XML schema definition Language are as follows: -
1. String
2. Date
3. Double

Longer Questions: -
1.

xmlns:xs="http://www.w3.org/2001/XMLSchema"

The component above specifies the namespace "http://www.w3.org/2001/XMLSchema" where the data types and elements come from.The namespace is prefixed with xs.

<xs:=schema

The above component specifies the root element and as you can see is a start tag which will require an end tag at the end of the document



2. a)

<?xml version="1.0"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

</xs:schema>




b)


c)

<xs:complex Type name=”electronice_payment_type”>

</xs:element>

<xs:element Type name”electronic_payment_type”/>

<xs:sequence>

<xs:element name”Sender”type=”institution_type”/>

<xs:element name”Reciever”type=”institution_type”/>

<xs:element name”Transaction”type=”institution_type”

maxOccurs=”unbounded”/>

</xs:sequence>



d)

e)



f)

xs:complexType name=”transection_type”

xs:all>

xs:slement name=”number” type=”xs:integer”/>

xs:element name=”amount”>

xs:simpleType>

xs:restrcition base=”xs:decimal”>

xs:fractionDigits value”2”>

/xs:restriction>



xs:element name=”date” type=”xs:”>

xs:element name=”recounciled” type=”xs:boolean”>

/xs:all>



Lecture Reflection-WEEK 13 – 14 – XML DOM


The lecture reflection for this week is discussed in the blog for week 14
http://www.ronnysmarket.com/
http://www.ronnysmarket.com/catalog/main

CMT3315 – Laboratory 12 – 16 December 09

Quick Questions

1. The text “Croydon Tramlink” on firefox explorer will be underlined and most likely highlighted in a different colour to indicate that it is a link where as on explorer the link is not supported and is not even highlighted or underlined.

2. I would chose XML schema’s over DTD’S because DTD ‘s has limitation on the description it can give about the document structure and uses a strange archaic format. However xml schema uses xml therefore can be parsed through an xml parser. The xml schema addresses the shortcomings of DTD’S and has the ability to describe complex XML types. There are also other features such as the “minOccurs” and “maxOccurs” which gives information on the amount of times each element will appear within a certain document.

Longer Questions

Bellow is the required XML schema document that I had to create: -


<?xml version="1.0" encoding="ISO-8859-1" ?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="book">

  <xs:complexType>

    <xs:sequence>

    <xs:element name="title" type="xs:string"/>

<xs:element name="author" type="xs:string"/>

<xs:element name="character">

<xs:complexType>

<xs:sequence>

<xs:element name="name" type="xs:string"/>

<xs:element name="friend-of" type="xs:string" minOccurs="0"/>

<xs:element name="since" type="xs:string"/>

<xs:element name="qualified" type="xs:string"/>

</xs:sequence>

</xs:complexType>

</xs:element>

    </xs:sequence>

   <xs:attribute name="isbn" type="xs:string" use="required"/>

  </xs:complexType>

</xs:element>



</xs:schema>




Lecture Reflection-WEEK 11 – 12 – XML Schema


An XML Schema describes the structure of an XML document and it is an XML-based alternative to DTD. An advantage of an XML schema over a DTD is that the schema uses XML for its coding therefore ensures a better understanding for someone that already knows how to use XML. This also ensures that the schema is parsed using an XML parser. An XML schema also offers more description then a DTD.
XML Schema language is sometimes referred to as XML Schema Definition (XSD). XML Schema is a W3 recommendation and it is thought of as the successor of DTD since they are extensible to future additions, support data types and namespaces, and they are more powerful than DTD.

There are two types used in an XML schema: -

1.Simple Type= Simple types contain only text. They don’t have child types. The element concerned doesn’t have attributes.
2.Complex Type= the element has one or more attributes, or one or more child elements, or both.

Example

XML document: -

<?xml version="1.0"?>

<note>

  <to>Tove</to>

  <from>Jani</from>

  <heading>Reminder</heading>

  <body>Don't forget me this weekend!</body>

</note>



XML Schema for the above document: -


<?xml version="1.0"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

targetNamespace="http://www.w3schools.com"

xmlns="http://www.w3schools.com"

elementFormDefault="qualified">



<xs:element name="note">

  <xs:complexType>

    <xs:sequence>

      <xs:element name="to" type="xs:string"/>

      <xs:element name="from" type="xs:string"/>

      <xs:element name="heading" type="xs:string"/>

      <xs:element name="body" type="xs:string"/>

    </xs:sequence>

  </xs:complexType>

</xs:element>



</xs:schema>





http://www.ronnysmarket.com/
http://www.ronnysmarket.com/catalog/main

CMT3315 – Laboratory 11 – 9 December 09

Quick Questions

1. Its about centralising the code within a document so that if you wish to change the attributes of the links of one or more document, then you only need to edit the third party document. This is similar to css as css is a separate document used to style an html document. In this case a third party document in xlink is used to edit the attributes of links contained in other documents. The advantage is the ability to change attributes of links contained in many documents by editing only one document (third party document) therefore making the editing process a little simpler.

2. Show="embed" (The link replaces the element link)
Show="new" (This opens up a new window)
Show="replace" (The content is loaded up on the current window, this is also the default attribute value)


Longer Questions

1.
(a) The following creates a link for the words “this website” contained within the message tag.

<memo>xmlns:xlink = "http://www.w3.org/1999/xlink">

<message>i think we should be making wind-turbines. Have a look at <Link xlink:type = "simple" xlink:href = “http://engineering.suite101.com/article.cfm/wind_power”> this website.</Link> Tell me what you think.</message>

</memo>


(b) The following will make the hyperlink finish at a certain part of the document rather than the wind_power document as a whole.

<message>i think we should be making wind-turbines. Have a look at <A HREF=“= “http://engineering.suite101.com/article.cfm/wind_power#WE Elec Facts”> this website.</A> Tell me what you think.</message>

2. The following creates a link for the words “this website” contained within the message tag. This time however the link takes the user to www.google.com


<memo>xmlns:xlink = "http://www.w3.org/1999/xlink">

<message>i think we should be making wind-turbines. Have a look at <Link xlink:type = "simple" xlink:href = “www.google.com”> this website.</Link> Tell me what you think.</message>

</memo>




Lecture Reflection-WEEK 11 – 12 – XML Schema


The lecture reflection for this week is discussed in the blog for week 12
http://www.ronnysmarket.com/
http://www.ronnysmarket.com/catalog/main