introduction on xml

HTML is an abbreviation for HyperText Markup Language.
XML stands for eXtensible Markup Language.
HTML was designed to display data with focus on how data looks.
XML was designed to be a software and hardware independent tool used to transport and store data, with focus on what data is.
HTML is a markup language itself.
XML provides a framework for defining markup languages.
HTML is a presentation language.
XML is neither a programming language nor a presentation language.
HTML is case insensitive.
XML is case sensitive.
HTML is used for designing a web-page to be rendered on the client side.
XML is used basically to transport data between the application and the database.
HTML has it own predefined tags.
While what makes XML flexible is that custom tags can be defined and the tags are invented by the author of the XML document.
HTML is not strict if the user does not use the closing tags.
XML makes it mandatory for the user the close each tag that has been used.
HTML does not preserve white space.
XML preserves white space.
HTML is about displaying data,hence static.
XML is about carrying information,hence dynamic.

XML is a software- and hardware-independent tool for storing and transporting data.

What is XML?
  • XML stands for eXtensible Markup Language
  • XML is a markup language much like HTML
  • XML was designed to store and transport data
  • XML was designed to be self-descriptive
  • XML is a W3C Recommendation

XML Does Not DO Anything
Maybe it is a little hard to understand, but XML does not DO anything.
This note is a note to ram from shyam, stored as XML:
<body>Don't forget me this weekend!</body>

The XML above is quite self-descriptive:
  • It has sender information(ram).
  • It has receiver information(shyam).
  • It has a heading (Reminder).
  • It has a message body(Don't forget me this weekend!).

But still, the XML above does not DO anything. XML is just information wrapped in tags.

Define   xml  building blocks:

XML Building  Block:

Building block means which all element or part   that make a xml document .
These  element  are
  •  Element
  • Attributes
  • Entities

Element is one of main building block  of xml language and HTML language also.
Example of HTML element are " body" and "table ".
And example of xml elements "note" and "message". one element can contain text , of  other elements, or be empty also .
Example of empty Html element are " hr" and "br". 


<body>my first text in body part </body>

<message>my first text in message element </message>


Attributes makes more powerful to the element . because it is placed inside in element for this attributes capability of element get enhance.
It is always come in name and its value in a pair.


< img src="mycomputer.jpg"  />


Some character  work like a keyword that has a special meaning in xml. like the less than (<)  it is define the opening tag in xml .
There are 5 pre-defined entity references in XML:
&lt;<less than
&gt;>greater than
&quot;"quotation mark


PCDATA stands for parsed character data.
character data are written in between the start tag and the end tag of an XML element.
PCDATA is the text that is parsed by the parser. text  checked by the parser in for entities and markup. which all text written inside in the xml tag treated like a markup. parsed character data should not contain any contain any special character like & ,>,< etc.


CD DATA is also special type of  text in xml. that is not parsed by the parser. the text that is written inside the tag not treated  like a markup.

What is a DTD?
A DTD is a Document Type Definition.
A DTD defines the structure and the legal elements and attributes of an XML document.

Why Use a DTD?
With a DTD, independent groups of people can agree on a standard DTD for interchanging data.
An application can use a DTD to verify that XML data is valid.

An Internal DTD Declaration
If the DTD is declared inside the XML file, it must be wrapped inside the <!DOCTYPE> definition:
XML document with an internal DTD
<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)
<!ELEMENT heading (#PCDATA)>
<body>Don't forget me this weekend</body>

An External DTD Declaration

(1)write code for external.dtd file:

<!ELEMENT note (to,from,head,body)>

(2)write code for  demo.xml :

 <?xml version = "1.0" encoding = "UTF-8" standalone = "no" ?>
<!DOCTYPE note SYSTEM "external.dtd">
<heading>Reminder me</heading>
<body>Don't forget me this weekend!</body>

EXtensible Stylesheet Language Transformation commonly known as XSLT is a way to transform the XML document into other formats such as XHTML.
Before learning XSLT, we should first understand XSL which stands for EXtensible Stylesheet Language. It is similar to XML as CSS is to HTML.
Need for XSL
In case of HTML document, tags are predefined such as table, div, and span; and the browser knows how to add style to them and display those using CSS styles. But in case of XML documents, tags are not predefined. In order to understand and style an XML document, World Wide Web Consortium (W3C) developed XSL which can act as XML based Stylesheet Language. An XSL document specifies how a browser should render an XML document.
Following are the main parts of XSL −
·        XSLT − used to transform XML document into various other types of document.
·        XPath − used to navigate XML document.
·        XSL-FO − used to format XML document.

What is XSLT
XSLT, Extensible Stylesheet Language Transformations, provides the ability to transform XML data from one format to another automatically.
How XSLT Works
An XSLT stylesheet is used to define the transformation rules to be applied on the target XML document. XSLT stylesheet is written in XML format. XSLT Processor takes the XSLT stylesheet and applies the transformation rules on the target XML document and then it generates a formatted document in the form of XML, HTML, or text format. This formatted document is then utilized by XSLT formatter to generate the actual output which is to be displayed to the end-user.

Here are the advantages of using XSLT −
·        Independent of programming. Transformations are written in a separate xsl file which is again an XML document.
·        Output can be altered by simply modifying the transformations in xsl file. No need to change any code. So Web designers can edit the stylesheet and can see the change in the output quickly.

Let’s suppose we have the following sample XML file, students.xml, which is required to be transformed into a well-formatted HTML document.
<?xml version = "1.0"?>
   <student rollno = "393">
   <student rollno = "493">
   <student rollno = "593">
We need to define an XSLT style sheet document for the above XML document to meet the following criteria −
·        Page should have a title Students.
·        Page should have a table of student details.
·        Columns should have following headers: Roll No, First Name, Last Name, Nick Name, Marks
·        Table must contain details of the students accordingly.
Step 1: Create XSLT document
Create an XSLT document to meet the above requirements, name it as students.xsl and save it in the same location where students.xml lies.
<?xml version = "1.0" encoding = "UTF-8"?>
<!-- xsl stylesheet declaration with xsl namespace:
Namespace tells the xlst processor about which
element is to be processed and which is used for output purpose only
<xsl:stylesheet version = "1.0"
xmlns:xsl = "">  
<!-- xsl template declaration: 
template tells the xlst processor about the section of xml
document which is to be formatted. It takes an XPath expression.
In our case, it is matching document root element and will
tell processor to process the entire document with this template.
   <xsl:template match = "/">
      <!-- HTML tags
         Used for formatting purpose. Processor will skip them and browser
            will simply render them.
            <table border = "1">
               <tr bgcolor = "#9acd32">
                  <th>Roll No</th>
                  <th>First Name</th>
                  <th>Last Name</th>
                  <th>Nick Name</th>
               <!-- for-each processing instruction
               Looks for each element matching the XPath expression
               <xsl:for-each select="class/student">
                        <!-- value-of processing instruction
                        process the value of the element matching the XPath expression
                        <xsl:value-of select = "@rollno"/>
                     <td><xsl:value-of select = "firstname"/></td>
                     <td><xsl:value-of select = "lastname"/></td>
                     <td><xsl:value-of select = "nickname"/></td>
                     <td><xsl:value-of select = "marks"/></td>
Step 2: Link the XSLT Document to the XML Document
Update student.xml document with the following xml-stylesheet tag. Set href value to students.xsl
<?xml version = "1.0"?>
<?xml-stylesheet type = "text/xsl" href = "students.xsl"?>
Step 3: View the XML Document in Internet Explorer
<?xml version = "1.0"?>
<?xml-stylesheet type = "text/xsl" href = "students.xsl"?>
   <student rollno = "393">
   <student rollno = "493">
   <student rollno = "593">

Next Post »


Write comments
avinash more
26 December 2017 at 03:00 delete

very good information Looking for the Dedicated PHP Web Programmer team in india? Xtensible Software Technologies will be the best option for you, they have the team of dedicated PHP web programmers. Dedicated PHP Web Programmer team in india

19 January 2018 at 04:35 delete

Thanks for sharing infomation with us walnutinnovations