Friday, 4 February 2011

Eighth Task

1. Describe and discuss Graphical XML - SVG


Scalable Vector Graphics


Images on the web began with static bitmap files, which are thousand of rectangles called pixels that make the image. Bitmap images although efficient, the introduction of vector images proved to be more efficient when it came to graphic images or animation on the web.  Using XML code it is possible to construct vector image graphics straight on to web pages. Bitmap, PNG and JPEG images are processed through the web browsers whilst SVG images require the web pages to have a plug in, and then they can be processed like the images mentioned.
SVG images are scriptable in which they can be manipulated and referenced by scripting languages. The graphics capabilities are outstanding and applications like Adobe Illustrator, CoralDraw and Photoshop have various editing features for such SVG images. SVG is a XML application created by the W3c, designed for the creation of vector graphics. Created by the W3c and a host of collaborators, a main one being Adobe.

Status
- SVG specification 1. 1
- Adobe Viewer Plug-in 3.0 (numerous updates to resolve issues have been released




SVG's key information


-They posses four different Document type definitions (DTD)


The DTD for version 1.1 is as follows:


<DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">


*The four differnt DTDs are not identical and should not be written as if they are


-To be able to use elements and attributes its a necessities to use a namespace, shown below the DTD


- SVG documents begin with a root element the svg element


- image/svg+xml is the MIME type (allows SVGs from a web-server to be placed on web browser)


- SVG drawing surface are non dimensional local units


- SVG use mathematics, coordinates and measurement's


-SVG documents can be created in an XML editor or an alternative text editor or graphics application


Three fundamental types of graphical objects
Vector Text
External Bitmap Images
Primitive Vector Shapes


Drawing a simple line in SVG


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">


<svg xmlns="http://www.w3.org/2000/svg">
<title>Simple Line</title>
<line x1="55" y1="55" x2="260" y2="140"
style="stroke:purple; stroke width:6"/>
</svg>


The above code would show a purple diagonal line with a fairly thick width


Related SVG
SVG Tiny (SVGT) and SVG Basic (SVGB) are W3c recommendations developed to allow SVG support to smaller, or basic processor devices, like model phones,  pda's, handheld games etc.


2. What is the Document Object Model? Describe its purpose and use

The Docuement Object Model was discussed  in another task, for this question and answer it will delve into information that may have been brief  or information that was not relevant to that task but relevant to this one.


A standard method for showing the elements in a document as a data structure/hierarchly tree developed by the W3c. This a standard method that can show data structures for various programming languages. Accessed is provided to show pieces and parts of a XML document or webpage by the DOM. The data structure is provided by the use of a DOM parser, a program that is able to read the XML document into a file and outputs the data structure

The DOM's Current Levels: 

DOM Level 0 : The original Netscape/ IE Functionalities
                           Not a W3C Recommendation, but was used as a basis

DOM Level 1 : (Latest edition September 2000) Fundamental DOM Objects (not fully
                           backward compatible with Level 0!)
DOM Level 2 : (November 2000) Access to stylesheets, handling namespaces; also
                           includes an event model

DOM Level 3 : (In preparation) Handling XML schemes (including on-the-fly validation),
                           X Path - based selections
 

The DOM is often described as being a collection of programming interfaces and that is just what it is. When discussing an XML document DOM represent this as a hierarchical tree, made up of various interfaces called node. Each of these interfaces have their own methods and properties.

DOM Interfaces
Each interface in a DOM is associated with a particular node from within the DOM tree. There are numerous types of interfaces, but I will only mention the common ones.

The Node Interface
All interfaces are actually derived from the node interface, if elements and attributes are shared by everything in a DOM tree they are shown by the node interface. The elements and attributes have to monitor the parents, siblings and children of the interface node. Attributes belong to nodes that contain the same name and value, they also have a pointer which points to the document associated with the node.

The Document Interface
The root node of the DOM tree, and one level above the root element of an XML document is the Document interface. Attributes in document nodes are associated with the document, reason why the XML document has one level less than the hierarchy in a DOM tree.

The Element Interface
All elements in an XML document are represented by the element interface, the tag name is the only attribute to be linked with an element node. The attribute of a standard node are whats inherited from the element node, which includes methods that allows the adding, removing and retrieving of attributes from the element interface.

The Attr Interface
This interface represents an attribute of an element, they are not nodes on a DOM tree but do inherit the node interface. They are part of an element and are not children of a element like some of the other nodes on the DOM tree. As they are attributes they do not contain methods and they are unable to fetch the parents, siblings and children of an attribute.


The NodeList Interface
The only interface that is different to the ones mentioned, simple terms it allows the DOM implementations to handle a collection of nodes. The attribute of this interface is the size of the collection, and this interface can perform plenty of repeative functions.


3. Evaluate SAX ( the XML API)
Simple API for XML

A programming interface for event driven parsing of XML files. Similar but different to the DOM as it takes a different parsing approach. The SAX parser however does nothing to data it has parserd unlike some other parsers, all it does is trigger events.

A SAX doc describes the standards a SAX parser must be written to and the events supported by the SAX parser. SAX 1.0 is the first version which has now been upgraded and somewhat replaced by SAX 2.0, athough some programs and applications still support SAX 1.0, its recommended to use 2.0 for new applications.

SAX 1.0
Concerned with the standard content in an XML document , it provides support for the triggered events. SAX 1.0 has the responsiblitity of managing the elements or attributes in which they provide through its interface at the startElement () method see below.

A Sax.10 parser must adhere to a set of methods that are automatically invoked during the parsing of a document and events occur during the parsing. Methods such as:

- characters () - returns all characters within an element
- ignorableWhitespace () - triggers an event when whitespace is found between elements
- processingInstruction () - triggers an event when processing instruction is found within a document         
- startElement () - triggers an event when an opening tag for an element is found
- endElemet () -  triggers an event when the closing tag of an element is found
- endDocument() - triggers an event when the the document parsing is finished

SAX 1.0 does not support namespaces

SAX 2.0

SAX 2.0 an extension of 1.o and provides support for namespaces unlike SAX 1.0. The parser within a SAX 2.0 program must adhere to the use of the following methods:

- startPrefixMapping () - triggers event when a prefix mapping is found
- skippedEntity () - triggers when a event discovers a skipped entity
- endPrefixMapping () - triggers event when a prefix mapping is closed

Example of the output of a SAX parser

start document.
Received processing instruction:
Target: xml-stylesheet
Data: href ="favmusic.xsl" type="text/xsl"
Start element: Cd's
Start element: Cd
Start element: Genre
Received characters: RnB
End of element: Genre
Start Element: Artist
Start Element: Language
Received characters: English
End of Elements: Language
......
......
End of Document reached.

 

3 comments:

  1. Great Posting for Programming in computer.

    http://www.owt-india.com/

    ReplyDelete
  2. Tegel Outlet
    Awesome post information Thanks for sharing

    ReplyDelete
  3. Thanks for shared this post information ..

    Buy personal lubes

    ReplyDelete