Quick Questions1. 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 Questionsa)
<?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 DOMDuring 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 Examplex.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