Welcome

To my corner on the net... Warning, this is a techie blog! Non-techie people may suffer bouts of epilepsy on viewing this blog. The author cannot be held responsible.

XML Part 8

Saturday, 10 December 2011

Describe and discuss Graphical XML – SVG, giving examples.

SVG (Scalable Vector Graphics) is used to define vector-based graphics for use on the Web. Vector graphics are not bitmapped which means that they are actually a collection of coordinates or vectors that can be used to reproduce an artwork. This means that they are fully saleable. Since they are basically a list of numbers to draw an image with, they can of course be defined in XML format.  Since the vectors are stored as text in XML format, a range of tools are easily available to edit and read these files. This also means that the files, consisting of nothing more than text are very small and quick to load. Their text representation which complies with XSL and DOM standards also makes SVG files compatible with the Javascript scripting language.

SVG Files are supported by all browsers except Internet Explorer which requires the installation of a plugin to be able to display them.

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
<circle cx="100" cy="50" r="40" stroke="black" stroke-width="2" fill="red"/>
</svg>
As can be seen in the example above SVG has special attributes for the commons shapes such as “cx”, “cy” and “r” which refer to the coordinates of the circle center point followed by the radius.


What is the Document Object Model? Describe its purposes and its use, with examples.

What is the Document Object Model? Describe its purposes and its use, with examples.
The Document Object Model (DOM) is primarily an application programming interface (API) for HTML documents that are valid and well formed XML documents. The DOM looks at, and  defines a logical structure that can be used to access and manipulate a document by navigating through the attributes, elements and properties.

Developers can traverse through the structure of an XML document through the DOM and manipulate it by creating or adding data, modifying and deleting data. If the document is reasonably well formed it has the potential of being manipulated through the DOM.
The DOM was designed to be language independent and can in fact be used with any programming language. It was originally designed to be a standardized programming interface that would be supported across platforms and applications.

<book>
 <title>Patrick</ title >
 <author>12.11.1990</ author >
 <review>
  <line1>Flat A 163</ line1>
  < line2>The Burroughs</ line2>
  < line3>nw4 1rr</ line3>
 </ review >
</ book >

To illustrate how the DOM model looks at an XML document it is graphically represented below:


 
Evaluate SAX (the XML API, giving examples of usage.

SAX was designed as a simple event based API (Application Programming Interface) for XML. The paradigm that SAX uses to read XML has been implemented in various XML parsers such as like Crimson, Xeres,  Oracle XML and Parser for Java.

SAX is an event driven API rather than following the traditional tree based model. The developer can define and use various callback methods when an event occurs.

For example, when the sample XML document below is parsed, several events are being triggered, namely, “startDocument”, “startElement: book”, “startElement: title”, and “character: XML Starter”, and finally an “endDocument” event is also raised.

<?xml version=“1.0”>
<book>
<title>XML Stater</title>
</book>

As can be seen SAX events can be starting and ending of documents , element nodes, character or text nodes and other processing instructions as well as comments for the developer.

SAX supports that when these events are raised, XML attributes are provided to the application parsing the XML as a part of the data passed. This SAX paradigm strays away from the DOM model by looking for XML events rather than looking at the document as a tree structure. The advantage with this approach is that the XML document does not have to be read in its entirety for the application to make use of it as happens in the DOM model. This makes it a  less memory consuming system while at the same time giving it better performance on large files.


Why is the W3C XML schema important?  Give examples of its role.

XML already contains a mechanism to define the XML document structure and that are Document Type Definitions or DTDs. DTDs outline a set of rules that state which elements and attributes are allowed in an XML document as well as allowing for the inclusion of default values if any.  In this way XML already has the ability to define data structures or entities and meta data information.  DTDs serve their purpose well and widely supported, however many XML developers were finding that they needed more. This is when the W3C XML schema recommendation was born. The aim of this new recommendation was to create a new language that could describe XML document structures more accurately and to support XML namespaces as well as to use XML’s own established vocabulary to describe XML in the schema.

W3C came up with two recommendations, XML Schema Part 1, which deals with structures, and XML Schema Part 2 which deals with datatypes. W3C also released a “nonormative” recommendation, XML Schema Part 0 Primer was designed to support all these applications.

The XML Schema Part 0 Primer is non-normatived document that aims to provide a readable and understandable description of the XML Schema. The primer aims at lowering the learning curve for developer using the Schema.

XML Schema Part 1 deals with structures and a definition of schema components  that constrain and document the constituent parts meaning, usage and relationships occurring within datatypes and elements with content and attributes containing values. XML Schema Part 2 deals with Datatypes and provides validation, data binding, documentation and querying support.

Every schema documents start with the following :

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

The above code, the standard xs namespace is being used, and the line point to the URI which is associated with the Schema Language Definition.

And ends :

</xs:schema>


What is the value of XML in e-commerce?  Give examples of its usage.

Electronic Commerce or eCommerce has taken the world by storm and is fast taking over large quantities of customers from the traditional retail trade. The important need for cross-platform data has arisen because of the popularity of eCommerce and it is this requirement that makes XML the ideal solution. The inherent extensible nature of XML gives it advantages over traditional database systems such as MySQL and MS SQL servers. The extensible nature also offers developers the ability to create an enterprise wide vocabulary.

FpML.org has created an XML based markup language intended for use in the financial services sector. FpML is not an application for perfoming trade but rather it provides standardization in terms of data content and structure. This is a good example of XML being used in a wide range of eCommerce financial applications. FpML is used by dealers, asset managers, hedge funds, service providers, and technology companies.

Together with implantation such as FpML, other technologies such as XSLT and XPATH are also used in eCommerce. These raise the level of XML to the expected levels as in MySQL by providing familiar query functions that can be executed on XML data the same way as they would on traditional database platforms. These features provide the necessary mechanisms to allow queries to be performed in transparent language which has certainly had an impact on the acceptance of XML in eCommerce.

0 comments:

Post a Comment