Friday, 22 October 2010

AWT- Validity of XML

How to test the validity of XML Document?

#  XML document must be well-formed, and also valid in most cases. There are many online tool provided to facilitate developers to verify and validate candidate documents. Such as XML Blueprint can validate any XML Document against a DTD, Relax NG Schema, Schematron Schema or XML Schema:
Open your XML Document in the XML Editor.
Click XML > Validate.
When we click the Validate button in the output, validation is successfully carried out for the input file against the .dtd and the text “Document is Valid!” is displayed as shown in the Figure 


Validation is the process of enforcing rules on the XML content either by means of a Document Type Definition (DTD) or a schema. The ValidationType property indicates the type of validation to be performed on the XML document. If you set the property to ValidationType.None, then it is equivalent to a non-validating reader.  
Values
Description
Auto
XmlValidatingReader validates if DTD or schema information is found. No validation if non-DTD or schema declared. (Default)
DTD
DTD validation.
None
Creates an XML 1.0 compliant non-validating parser. No validation errors are thrown.
Schema
Validate according to XSD schemas.
XDR
Validate according to XDR schemas.
                                                                                                                                         
Validation of XML documents help to ensure the information is structured in a way that is sensible for applications which use it.

AWT- Well formed XML document

How to define and measure well-formed XML document?

# A well formed XML document does not need a DTD (Document Type Definition), but is must conform to the XML syntax rules. If all tags in a document are developed with no any errors and follow the XML guidelines, then a document is considered as well formed.

It has to pursue several rules that most other markup languages also follow. These are generic rules that must be followed for a document to be well-formed, as well as valid. The rules are as follows:

  • One Root Element - The XML document may only have one root element. 
  • Proper Nesting - XML elements must be closed in the order they are opened.
  • Well-Formed Entities - Any entities that are referenced in the document must also be well-formed. http://www.tizag.com/xmlTutorial/xmlvalidwellformed.php
  • All the entity must be well-formed if it is externally parsed, it must be well-formed.
  • Parsed entities may not be recursive, meaning that a parsed entity may not refer to itself.
  • Parameter entity references can only be in the DTD, but nowhere else.
  • There is a specified structure for the external subset of a DTD.




Well- formed XML

A well formed XML document defines that the document does not have any error or it has followed proper XML syntax. In other word, if the tags in a document are created accurately or build in correct formed and follow the XML guideline, then a document is considered as well formed. In order to do pass the document to the application it should be in well formed otherwise XML parser stops it from doing application. In order to be well formed, it should contain a prolog (optional), a document element and a miscellaneous section (optional). There are few different points that need to be fulfilled to achieve well formed XML document like XML is case sensitive so the tags used should be similar in case, every opening tags should have its closing tags, etc.

Wednesday, 20 October 2010

Question related to XML

1. How important is <?xml version="1.0"?>?
# It is very important but not necessary. Because the statement declares the document as an XML document, which means it complies with XML syntax rules - that is it is well formed. XML protocol versioning is not a topic limited to real-time communication systems, however. Rather, it is a topic of importance to any two communicating systems that might make use of XML as the protocol signaling syntax and which may be using different versions of the protocol at any given time.

2. When do you choose element and attribute?
#XML is a markup language that is used to store data in a comprehensible manner. Making the data “comprehensible " comes about by holding the information in elements. If a piece of text is a title then it will be contained within a "title" element.If an element has no content at all, you can use a single tag finishing />
Like this:
<myEle myAttribute=”specialData”/>
Means the same as:
<myEle myAttribute=”specialData”></ myEle>
Attributes are used to indicate additional information about the element. An attribute for an element appears within the opening tag. External entity references can’t be attribute values. Internal entity references can. If there are multiple values an attribute may have, then the value of the attribute must be specified. For example, if a tag had a color attribute then the value would be: red, blue, green, etc. The syntax for including an attribute in an element is: <element attributeName="value">http://www.tizag.com/xmlTutorial/xmlelement.php
3. What is AJAX?
AJAX is a combination of organized web development techniques used on the client-side to create interactive web applications. AJAX stands for Asynchronous JavaScript and XML. With the help of AJAX, web applications can retrieve data from the server in the background without interfering with the display of the existing page. Basically, it makes the life developer life easier. It facilitates the web application. In traditional architecture, the user must wait for the entire Web page to reload to see new results from the server in an application that requires a lot of interactivity with the business layer sitting on the server; the user must reload the entire page many times. Basically in all the web applications, the user enters the data into the form and then clicks on the submit button to submit the request to the server. Server processes the request and returns the output in new page (by reloading the whole page). This process is really inefficient, time consuming, and a little frustrating if only the small amount of data exchange is required. For example in a user registration form, this can be frustrating thing for the user, as whole page is reloaded only to check the availability of the user name. So to prevent from these drawbacks, Ajax will help in making application more interactive. With the help of Ajax, we can confirm the availability of the username without refreshing the whole page.
http://en.wikipedia.org/wiki/Ajax_(programming)

Monday, 18 October 2010

Video link for XML turtorial

Tutorial for XML

Advanced Web Technologies (AWT)

  What was the first Browser to read XML????
The first browser to read XML was Microsoft IE4. It uses the external MSXML parser to break a document’s XML tags into an object tree. However, the next generation of browsers will natively recognize and parse XML documents. 
  

Saturday, 16 October 2010

Advanced Web Technologies & XML


1) What is the “X” in XML and what is its significance? Select one response and write the letter here [b]
a) Extended
b) Extensible
c) Extreme
d) Extendable
The “X” is significant because
# XML stands for Extensible Markup Language. As ‘M’ and ‘L’ stands same for HTML and XML: Markup Language. One “mark up” text for formatting; the other is an extensible markup language for data. By comparing, HTML is limited to the display functions. However, XML don’t not have limits to the type of data that can be marked up because of its extensible nature. It gives flexibility to use the same document in multiple platform and system. In simple words, by its extensible and flexible nature of XML, the same data or information can be represented in different ways.
      Both HTML and XML used tags to marks up the blocks of data. HTML marks up blocks of text to notify the browser how to display it whereas XML marks up blocks of data with tags that inform us what type of information or data is stored. In HTML, there are words and paragraphs and the tags to let browser know how to display the text as “marked up”. Such as:
      <html>
      <body>
      <p>
      My name is <b> Kshitij Munankami </b>
      </p>
      </body>
      <html>
      Similarly, there are tags in XML. Bu, these tags notify the reader or computer what type of information is between those tags. For example:
<html>
      <Student>
      <Name>
      Kshitij Munankami
      </Name>
      </Student>
      <html>

2) What is a markup language? Select one response and write the letter here [c]
a) A system of symbols to support the transmission of morse code.
b) A system to display website standards to which a website conforms,
c) A system of embedded codes to make an electronic document display on a web page as required
d) A system to only prepare documents for publication
Describe in your own words.
# Mark up Language is generally a text based language that is interpreted by a web browser to instruct the browser to access particular formatting for that particular mark-up language.
The formal way of describing a digital data using a tag around content to provide a information about how to display mark-up documents in a web page as required. Specially, it is designed for the processing, definition and presentation of text. The language specifies code for formatting, both the lay out and style, within a text file.
HTML is an example of a widely known mark up language; one of the documents formats of the World Wide Web. Though, it does not comply strictly with all the rules of SGML, HTML is mostly an instance of SGML and follows many of the marrkup conventions used in the publishing industry in the communication of printed work between authors, editors and printers.

3) What does SGML stand for? Select one response and write the letter here [a]
a) Standard Generalized Markup Language
b) Structured Generalized Markup Language
c) School of Global Management and Learning
d) Simplified Generic Machine Language
What is the significance of SGML?
# To be started, SGM L stands for Standard Generalized Markup Language. It emphasis on descriptive rather than procedural markup. It uses markup codes which simply give names to categorize different parts of a document; it introduces the concept of a document type definition (DTD) and finally independence of any one system for representing to script in which a text is written.Below are some advantages of documents based on SGML:
·         They can be created by thinking in terms of document structure rather than appearance characteristics (which may change over time).
·         They will be more portable because an SGML compiler can interpret any document by reference to its document type definition (DTD).
·         Documents originally intended for the print medium can easily be re-adapted for other media, such as the computer display screen.
Web browser uses HTML (Hypertext Markup Language), which is an example of an SGML-based language. There is a document type definition for HTML. In today's distributed networking environment, many documents are being described with the Extensible Markup Language, which is a data description language that uses SGML principles.

4) What is the relationship between SGML and XML? Select one response and write the letter here [d]
a) SGML is based on XML
b) SGML and XML are the basis for HTML
c) SGML is a slimmed-down, streamlined version of XML
d) XML is a slimmed-down, streamlined version of SGML
Why is this so?
# SGML (Standard Generalized Markup Language) is the standard for encoding paper documents into an electronic format. With the advancement of the internet, it became apparent that HTML is no longer able to provide the need for more dynamic content as it has reached its limitations. XML (Extensible Markup Language) is a language derived from SGML, which contains more limited features in order to make simpler for coders to use. As SGML is a complex and comprehensive language. However anything too complex will never be accepted. So in comes XML, as a subset of SGML. XML retains all the good points of SGML and it is also simpler to use. Since XML is simply a subset of SGML, SGML parsers are capable of reading and decoding valid XML files. The reverse is not necessarily true though as SGML files might have features that the XML parser does not understand.
Being a subset, there would be no feature in XML that does not exist in SGML

5) What is the relationship between SGML and HTML? Select one response and write the letter here [a]
a) HTML is a mark-up language derived from SGML
b) SGML is a mark-up language derived from HTML
c) Both are derived from XML
d) Both are derived from AJAX
Why is this so?
# Again, as SGML is a complex and comprehensive language. However anything too complex will never be accepted. So in comes HTML, derived from SGML. HTML retains the good points of SGML and it is also simpler to use. HTML is also known as the child or application of SGML. HTML is an example of a widely known mark up language; one of the documents formats of the World Wide Web. Though, it does not comply strictly with all the rules of SGML, HTML is mostly an instance of SGML and follows many of the marrkup conventions used in the publishing industry in the communication of printed work between authors, editors and printers.

6) Which of the following statements are true? Select one response and write the letter here [c]
a) Special-purpose packages have been derived from HTML
b) HTML is an application derived from XML
c) Special-purpose markup languages have been derived from XML
d) XML supports HTML
Give examples:
# Following is a simple example for XML in topic “Recipe Book”
<recipe>
<title> Peanut - butter on a spoon </title>
<ingredientlist>
<ingredient> Peanut - butter </ingredient>
</ingredientlist>
<preparation> Stick a spoon in a jar of peanut - butter,
                       Spoon and pull out some butter
</preparating>

7) Which of the following statements DOES NOT apply to XML?  Select one response and write the letter here [b]
a) XML is a set of rules for encoding documents electronically
b) XML is a predecessor of SGML
c) XML explicitly identifies the knowledge structure in the encoded document, so that software packages can use this structure
d) XML approach allow you to specify the presentation of the document, and the hypertext links
Explain your choice: 
# A system for organizing and tagging elements of a document. SGML was developed and standardized by the International Organization for Standards (ISO) in 1986. Due to lack of SGML support in mainstream web browsers, most applications that deliver SGML information over the web content the SGML to HTML. This down-translation removes much of the intelligence of the original SGML information. That lost intelligence virtually eliminates information flexibility and poses a significant barrier to reuse, interchange and automation. For this reason, XML (Extensible Markup Language) was developed in 1996. XML is highly functional subset of SGML. The purpose of XML is to specify an SGML subset that works very well for delivering SGML information over the web.

8) Which of the following statements DOES NOT apply to XML?  Select one response and write the letter here [d]
a)   XML underpins the www
b)   XML underpins office apps
c)   XML supports the creation new markup languages
d)   XML is written in Java
#Because XML and Java is a separate language and in additional XML is written in XML itself and java in itself. Therefore XML cannot be written in Java.

9) What is XIML? Select one response and write the letter here [c]
a) Extensible Intelligent Markup Language
b) Extended Invisible Markup Language
c) Extensible Interface Markup Language
d) Extraterrestrial Interactive Markup Language
Explain your answer:
# XIML is an innovative technology created purposefully to address the growing need for interactive multimedia user interface development. It is a simple markup language enabling functionality previously available only with complex programmed applications. XIML is a universal technology well suited for building full featured websites, mini-sites, widgets, web/mobile/PDA applications, GUI in desktop applications, touch screens, etc.

10) What is XIML? Select one response and write the letter here [a]
a) A Universal Language for User Interfaces
b) A Markup Language Intelligent Applications
c) A Language for Unseen Web Features
d) A Markup Language for Extraterrestrial Maps
Explain your answer:
#XIML is a technology developed purposefully for an interactive website/user interface development with flawless multimedia integration. It is a simple markup language enabling functionality previously available only with complex programmed applications. XIML is a universal known technology appropriate for creating full featured websites, mini-sites, widgets, GUI in desktop applications, touch screens, etc.
It is for support of functionality across the entire lifecycle of a user interface: design, development, operation, management, organization, and evaluation. It is also known to be as the easiest way to build interactive websites. XIML, markup language is so simple that everyone can easily understand and implement without limitations.

11) What is XUL? Select one response and write the letter here [b]
a) Extensible Unseen Markup Language
b) XML User Interface Language
c) Extensible Universal Language
d) Extreme UML
Explain your answer:
#  XUL (Extensible User-interface Language) is created in a standard way to exchange data that describes a program's user interface. Historically, user interfaces have been difficult to customize so they would work across various operating platforms such as Windows and Macintosh. Netscape and Mozilla, an open group that develops Netscape, have jointly developed XUL to solve this problem.
The splendour of XUL lies in its simplicity. It is easier to work in comparison to the interface programming tools of the past. A few lines of XUL can accomplish for the task where many lines of code were required previously. With a little knowledge, one can build a basic Web browser interface using XUL. This fact may ultimately translate into lower cost for the development of user interfaces. Also, another asset of XUL is its flexibility nature.
Basically, it is a standard way to swap the data that describes a program's user interface, or at least the portion of it that can be controlled by programming

12) What is XSL? Select one response and write the letter here [d]
a) As a standards language
b) An alternative to XML
c) Extensible Universal Language
d) As a stylesheet language
Explain your answer:
XSL stands for Extensible Stylesheet Language, but formerly it is also called as Extensible Style Language. It is a programming language that creates a stylesheets, which explains how data sent over the Web using the Extensible Markup Language is to be presented to the user.
Using XSL, XML documents can be created into different file formats (for instance, HTML, text, or PDF).
 XSL gives a developer the tools to describe exactly which data fields in an XML file to display and exactly where and how to display them. Like any style sheet language, XSL can be used to create a style definition for one XML document or reused for many other XML documents.
It is based on and extends the Document Style Semantics and Specification Language and the Cascading Style Sheet, level 1 standard.

13) Below is some XML. What is the last line? Select one response and write the letter here [b]
a) <end>
b) </note>
c) <note>
d) <note/>
 <?xml version="1.0"?>
<note>
    <to>Class</to>
    <from>Ray</from>
    <heading>Reminder</heading>
    <body>Don't forget to complete your Blog!</body>
Because in XML to be well formed there should always be end tag for any starting tag.

14) Below is some XML.  What is the missing line? Select one response and write the letter here [d]
a) <Header>
b) <Body>
c) <painting>
d) </caption>
<?xml version="1.0" encoding='UTF-8'?>
<painting>
  <img src="madonna.jpg" alt='Foligno Madonna, by Raphael'/>
  <caption>This is Raphael's "Foligno" Madonna, painted in
  <date>1511</date>-<date>1512</date>
</painting>
Because in XML to be well formed there should always be end tag for any starting tag.
15)  Write an XML document that contains the following information: your name. Your email address. Your student number. Your home town. Your date of birth. Choose appropriate tags. Use Attributes for the date of birth.
<?xml version="1.0"?>
<Identity  DOB="28/07/87" >
<title>Introduction</title>
<name>Kshitij Munankami</name>
<email>xitiz_16@hotmail.com</email>
<studentno>M00310873</studentno>
<hometown>Tansen, Palpa</hometown>
</Identity>
Element: It is everything from the element start tag to element end tag. For example: In above example <Identity> has element contents
Attribute: It provides additional information about element. For example: In above example DOB is an attribute.

16)  Have a look at the XML document below. Identify all the syntax errors.
<?xml version= “1.0” ?>
<!DOCTYPE countryCollection SYSTEM "countryList.dtd">
<CountryList>
<Nations TotalNations =”3”/>
<!--Data from CIA --Year Book -->
            <Country CountryCode=”1”>
                        <OfficialName>United States of America</officialName>
                        <Label>Common Names:</label>                
                        <CommonName>United States</commonName>
                        <CommonName>U.S.</commonName>
                        <Label>Capital:</capital>                  
                        <Capital cityNum=”1”>Washington, D.C. </label>
                        <2ndCity cityNum=”2”>New York </2ndCity>         
                        <Label>Major Cities:</label> 
                        <MajorCity cityNum=”3”>Los Angeles </majorCity>
                        <MajorCity cityNum=”4”>Chicago </majorCity>                  
                        <MajorCity cityNum=”5’>Dallas </majorCity>                      
                        <Label>Bordering Bodies of Water:</label>                                     
                        <BorderingBodyOfWater> Atlantic Ocean </borderingBodyOfWater>
                        <BorderingBodyOfWater> Pacific Ocean </borderingBodyOfWater>                    
                        <BorderingBodyOfWater> Gulf of Mexico </borderingBodyOfWater>       
                        <Label>Bordering Countries:</label>                        
                        <BorderingCountry CountryCode=”1”> Canada </borderingCountry>                                             
                        <BorderingCountry CountryCode =”52”> Mexico </borderingCountry>
</country>
            <Country CountryCode=”81”>
                        <OfficialName> Japan </officialName>
                        <Label>Common Names:</label>                                        
                        <CommonName> Japan </commonName>
                        <Label>Capital:</label>                     
                        <Capital>Tokyo</capital cityNum=”1”>
                        <2ndCity cityNum=”2”>Osaka </2ndCity>
                        <Label>Major Cities:</label>                                     
                        <MajorCity cityNum=”3”>Nagoya </majorCity>
                        <MajorCity cityNum=”4”>Osaka </majorCity>                    
                        <MajorCity cityNum=”5’>Kobe </majorCity>                       
                        <Label>Bordering Bodies of Water:</label>
                        <BorderingBodyOfWater>Sea of Japan </borderingBodyOfWater>
                        <BorderingBodyOfWater>Pacific Ocean </borderingBodyOfWater>                     
            </country>
            <Country CountryCode=”254”>
                        <OfficialName> Republic of Kenya </officialName>
                        <Label>Common Names:</label>                                        
                        <CommonName> Kenya </commonName>
                        <Label>Capital:</label>                     
                        <Capital cityNum=’1’>Nairobi </capital>
                        <2ndCity cityNum=’2’>Mombasa</2ndCity>
                        <Label>Major Cities:</label>                                     
                        <MajorCity cityNum=’3’>Mombasa </majorCity>
                        <MajorCity cityNum=’4’>Lamu </majorCity>
                        <MajorCity cityNum=’5’>Malindi </majorCity>                     
                        <MajorCity cityNum=’6’ cityNum=’7’>Kisumu-Kericho </majorCity>          
                        <Label>Bordering Bodies of Water:</label>
                        <BorderingBodyOfWater <!--Also Lake Victoria --> > Indian Ocean </borderingBodyOfWater>
            </country> 
# The above code marked with a red colour is a syntax error. Following are the errors:
1 In XML, it is illegal to omit the closing tag. All elements must have a closing tag.
2 XML tags are case sensitive. Opening and closing tags must be written with the same case.