Skip to main content

introduction on xml

HTML
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:
<note>
  
<to>ram</to>
  
<from>shyam</from>
  
<heading>Reminder</heading>
  
<body>Don't forget me this weekend!</body>
</note>

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
  • PCDATA
  • CDDATA
Element:

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". 

Example:

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

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

Attributes:

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.

Example:

< img src="mycomputer.jpg"  />

Entities:

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
&amp;&ampersand 
&apos;'apostrophe
&quot;"quotation mark


PCDATA:

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.

CDDATA:

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 to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend</body>
</note>


An External DTD Declaration

(1)write code for external.dtd file:

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

(2)write code for  demo.xml :

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

EXtensible Stylesheet Language Transformation commonly known as XSLT is a way to transform the XML document into other formats such as XHTML.
XSL
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.

Advantages
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.
students.xml
<?xml version = "1.0"?>
<class>
   <student rollno = "393">
      <firstname>Dinkar</firstname>
      <lastname>Kad</lastname>
      <nickname>Dinkar</nickname>
      <marks>85</marks>
   </student>
   <student rollno = "493">
      <firstname>Vaneet</firstname>
      <lastname>Gupta</lastname>
      <nickname>Vinni</nickname>
      <marks>95</marks>
   </student>
   <student rollno = "593">
      <firstname>Jasvir</firstname>
      <lastname>Singh</lastname>
      <nickname>Jazz</nickname>
      <marks>90</marks>
   </student>
</class>
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.
students.xsl
<?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 = "http://www.w3.org/1999/XSL/Transform">  
<!-- 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.
      -->
                
      <html>
         <body>
            <h2>Students</h2>
                                  
            <table border = "1">
               <tr bgcolor = "#9acd32">
                  <th>Roll No</th>
                  <th>First Name</th>
                  <th>Last Name</th>
                  <th>Nick Name</th>
                  <th>Marks</th>
               </tr>
                                  
               <!-- for-each processing instruction
               Looks for each element matching the XPath expression
               -->
                                  
               <xsl:for-each select="class/student">
                  <tr>
                     <td>
                        <!-- value-of processing instruction
                        process the value of the element matching the XPath expression
                        -->
                        <xsl:value-of select = "@rollno"/>
                     </td>
                                                   
                     <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>
                                                   
                  </tr>
               </xsl:for-each>
                                           
            </table>
         </body>
      </html>
   </xsl:template> 
</xsl:stylesheet>
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"?>
<class>
...
</class>
Step 3: View the XML Document in Internet Explorer
students.xml
<?xml version = "1.0"?>
<?xml-stylesheet type = "text/xsl" href = "students.xsl"?>
<class>
   <student rollno = "393">
      <firstname>Dinkar</firstname>
      <lastname>Kad</lastname>
      <nickname>Dinkar</nickname>
      <marks>85</marks>
   </student>
   <student rollno = "493">
      <firstname>Vaneet</firstname>
      <lastname>Gupta</lastname>
      <nickname>Vinni</nickname>
      <marks>95</marks>
   </student>
   <student rollno = "593">
      <firstname>Jasvir</firstname>
      <lastname>Singh</lastname>
      <nickname>Jazz</nickname>
      <marks>90</marks>
   </student>
</class>  


Comments

  1. 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 http://xtensible.in/dedicated-php-web-programmers-india

    ReplyDelete

Post a Comment

Popular posts from this blog

Jquery Sliding

jQuery Sliding Methods:-  With jQuery you can create a sliding effect on elements. jQuery has the following slide methods: slideDown() slideUp() slideToggle() (1)slideDown()  example:- <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){   $("#flip").click(function(){     $("#panel").slideDown("slow");   }); }); </script> <style> #panel, #flip {   padding: 5px;   text-align: center;   background-color: #e5eecc;   border: solid 1px #c3c3c3; } #panel {   padding: 50px;   display: none; } </style> </head> <body> <div id="flip">Click to slide down panel</div> <div id="panel">Hello world!</div> </body> </html> (2)sldeUP()  example:- <html> <head> <script src="https://ajax.

layout code example:-

<!DOCTYPE html> <html lang="en"> <head>   <title>Bootstrap Example</title>   <meta charset="utf-8">   <meta name="viewport" content="width=device-width, initial-scale=1">   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>   <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>   <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script> </head> <body>  <section>       <div class="container">         <header>           <h3  class="text-center">Services</h3>           <p class="text-center">Laudem latine pe

Juqery fade

jQuery Fading Methods :-  With jQuery you can fade an element in and out of visibility. jQuery has the following fade methods: fadeIn() fadeOut() fadeToggle() fadeTo() jQuery fadeIn() Method The jQuery fadeIn() method is used to fade in a hidden element. Syntax:- $(selector).fadeIn(speed,callback); <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){   $("button").click(function(){     $("#div1").fadeIn();     $("#div2").fadeIn("slow");     $("#div3").fadeIn(3000);   }); }); </script> </head> <body> <p>Demonstrate fadeIn() with different parameters.</p> <button>Click to fade in boxes</button><br><br> <div id="div1" style="width:80px;height:80px;display:none;background-color:red;"></div><