The Concept of Document Object Model Coursework

Exclusively available on IvyPanda Available only on IvyPanda
Updated: Mar 31st, 2024

Introduction to DOM

DOM, short form of Document Object Model, “is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents” (W3C 1).

We will write a custom essay on your topic a custom Coursework on The Concept of Document Object Model
808 writers online

DOM can represent a document (such as HTML or XML document) and can allow access to various elements of that document for examination and manipulation purposes. The standard DOM, standardized by the World Wide Web Consortium, uses a tree structure to represent any HTML or XML document, and provides a wide range of methods and properties to support critical tree operations, such as, navigation, examination, and modification. As a result, the standard DOM is implemented by most of the today’s well known browsers, such as, Netscape, Internet Explorer, Google Chrome, and etc (Flanagan).

The data of document, represented by tree nodes and entities, is defined in a logical structure by DOM. The structured format of a document provides great flexibility to enable developers to perform useful operations on the document’s data, such as addition, deletion, modification, and navigation. In DOM, the document has a tree structure with a root node, branches and leaves. The nodes in the document are defined as an interface objects that provides access to documents objects for manipulation. Some of the major nodes and node contents of XML document in DOM are: Document, DocumentType, Element, Attr, ProcessingInstruction, Comment, Text, and Entity (Chand).

There are currently four levels of specifications of DOM: DOM Level 0, DOM Level 1, DOM Level 2, and DOM Level 3. (Yang 1)

Operations Implemented

In this assignment, I have implemented the following operations:

Adding a new record

This operation allows the user to add a new record of either a book or an article. If the user wishes to add a book, then she must provide the title, first name and surname of all the authors (optional), name of the publisher, and the year of publication. In case if the user opts for adding an article, then she must provide the title, first name and surnames of all the authors (optional), name of the journal, an issue number, page number of beginning, page number of ending, and the year of publication.

Searching records

This operation allows the user to search for particular records. There are two options available to user; either to search records containing the search string in their titles, or to search records containing the search string in their any of the author’s surname. For example, if the user chooses the latter option and provides a search string ‘Moeller’, then all the records of books and articles that contains the search string ‘Moeller’ in any of their author’s surname will be retrieved.

1 hour!
The minimum time our certified writers need to deliver a 100% original paper

Creating reports

This operation allows the user to create a report. The user may choose to generate a report in which the nodes are grouped either by type (book and article) or by author names.

Problems encountered

Although I had heard about Python many times, but I never got an opportunity to learn or work on this language before this assignment. Despite the fact that I have practical experience with popular programming language like C and Java, working on this assignment was not easy because the syntax of Python language is totally different from C and Java and is also too much confusing. To do this assignment, I was compelled to read tons of tutorials on Internet and books in library to learn Python which made this assignment even more challenging and time-consuming. As I was learning Python and working on this assignment in parallel, I was stuck at many points during implementing the program. Some of the major issues that I faced while working on this assignment were:

Unawareness with Python syntax

As already mentioned above, this was the most major problem for me in doing this assignment. Before starting to work on this assignment, I was under the impression that I would be able to complete the assignment without any problem as I have good knowledge of C and Java language. But as soon I started to work on this assignment, I realized that Python is considerably different from C and Java. Most of the keywords and operators that are available in C and Java were missing in Python. Also, the syntax of Python is not user-friendly. I was facing lot of problem in understanding the syntax and most of my valuable time was consumed in just learning the language.

Record searching

Adding a new record was not too hard because there is abundant of help available on Internet related to this subject. However, I had a very tough time in implementing the search operation especially due to the use of XPath expressions. Although XPath expressions are very powerful and provide flexible way to search or traverse the nodes in the document tree, writing the correct XPath expression is not an easy task.

Honestly speaking, implement this operation would not take too long if I would be using C or Java because the debugging is very easy in these language as the variables have strict data types. This is not the case with Python; it does not involve Data Types and the variable can store any type of data which makes debugging process very difficult because the developer then needs to check every method’s return value or evaluate the value stored in the variable on several occasions to know the exact type of an object.

Simple editor

I implemented the program in Python’s built-in editor, IDLE (Integrated Development Environment) version 2.6.6. This editor is pretty good for basic development purposes but it severely lacks strong debugging capabilities. Debugging the code is like a night mare in this editor – there is no menu for debugging. The user can only run the code but cannot debug to ensure the code’s accuracy.

Creating a report

The report for grouping the nodes by type was implemented too easily – just in 30 minutes. But the other report in which the nodes were to be grouped by author names was very tough. Honestly speaking, this report consumed lot of my time and energy, and at one moment I was so frustrated that I thought to quit and leave it as it is. The XPath expression was not easy and it took lot my time to write a correct XPath expression. After lot of efforts, I was soon able to write the correct XPath expression and I was happy thinking that soon I would be over with the coding. But I was wrong as the frustrating part was remaining.

Remember! This is just a sample
You can get your custom paper by one of our expert writers

At time of writing the contents to XML file, the nodes were not appearing under all the groups properly; means even if a particular book or article had several authors, the node representing that book or article was appearing only under one group which was not the desired output of course. I checked like hundreds of times that if the XPath expressions were returning the correct number of nodes, but to my surprise, there was no problem with the expressions and I could all the nodes under every group. But whenever I tried to write the contents of the node to the file, the contents were only appearing under one author.

I tried a lot to figure out the reason for the odd output but failed. Luckily when I was about to give up, I thought to give the final try and what I did was to create the copy of the node while writing to the file. Surprisingly, it worked. The solution that I applied as a chance worked and finally, all the desired operations were successfully implemented.

Works Cited

Chand, Mahesh. A programmer’s guide to ADO.NET in C#. New York: Apress, 2002. Print.

Flanagan, David. JavaScript: the definitive guide. California: O’Reilly Media, 2002. Print.

W3C. Document Object Model (DOM). 2005. Web.

Yang, Herong. . Web.

Print
Need an custom research paper on The Concept of Document Object Model written from scratch by a professional specifically for you?
808 writers online
Cite This paper
Select a referencing style:

Reference

IvyPanda. (2024, March 31). The Concept of Document Object Model. https://ivypanda.com/essays/the-concept-of-document-object-model/

Work Cited

"The Concept of Document Object Model." IvyPanda, 31 Mar. 2024, ivypanda.com/essays/the-concept-of-document-object-model/.

References

IvyPanda. (2024) 'The Concept of Document Object Model'. 31 March.

References

IvyPanda. 2024. "The Concept of Document Object Model." March 31, 2024. https://ivypanda.com/essays/the-concept-of-document-object-model/.

1. IvyPanda. "The Concept of Document Object Model." March 31, 2024. https://ivypanda.com/essays/the-concept-of-document-object-model/.


Bibliography


IvyPanda. "The Concept of Document Object Model." March 31, 2024. https://ivypanda.com/essays/the-concept-of-document-object-model/.

Powered by CiteTotal, best citation website
If you are the copyright owner of this paper and no longer wish to have your work published on IvyPanda. Request the removal
More related papers
Cite
Print
1 / 1