Xml
•XML stands for EXtensible Markup Language
•XML is a markup language much like HTML
•XML was designed to carry data, not to display data
•XML tags are not predefined. You must define your own tags
•XML is designed to be self-descriptive
•XML is a W3C Recommendation
There are two current versions of XML. The first XML 1.0 was initially defined in
1998 and it has undergone minor changes/revisions since then. Though changes
have been done, a new revision number has not been assigned to this version. It is
called XML 1.0 5th edition, with the latest edition (5th) being released on 26th Nov
2008.

The second version XML 1.1 was initially published on 4th Feb 2004, the same day
as the XML 1.0, 3rd edition. XML 1.1 is currently in its 2nd edition which was
released on 16th Aug 2006. It contains certain features that are expected to make
XML easier to use.
.




                                          Mobile Application                     Web Services




                 Windows Application


                                                                                                 Web Application

                                                                  XML




                                                          DB2           Oracle
                                       SQL Server                                       Access
                                                                Data Sources


Ashok K Sharma
 04/05/12                                                                                                          4
Domain-specific vocabulary
                 Data interchange
                 Smart searches
                 Granular updates
                 User-selected view of data
                 Message transformation




Ashok K Sharma
 04/05/12                                     5
The various components of an XML
          document used for representing data in a
          hierarchical order are:
                 Processing Instruction (PI)
                 Tags
                 Elements
                 Content
                 Attributes
                 Entities
                 Comments

Ashok K Sharma
 04/05/12                                            6
<?xml version=“1.0” encoding=“UTF-8”?>
                 <STOREDATA>                              Processing Instruction (PI)
                 <!--STOREDATA is the root element-->     Provides information on how
                     <STORE STOREID=“S101”>               the XML file should be
                       <PRODUCTNAME>Toys</PRODUCTNAME>    processed.


                       <QUANTITY>100</QUANTITY>
                       <DISPLAY>The price of this toy
                        is &lt; 200 </DISPLAY>
                    </STORE>
                 </STOREDATA>




Ashok K Sharma
 04/05/12                                                                               7
<?xml version=“1.0” encoding=“UTF-8”?>
                 <STOREDATA>
                 <!--STOREDATA is the root element-->   Tags
                     <STORE STOREID=“S101”>             Is a means of identifying
                       <PRODUCTNAME>Toys</PRODUCTNAME> data. Tags consist of start
                                                              tag and end tag.
                       <QUANTITY>100</QUANTITY>
                       <DISPLAY>The price of this toy
                        is &lt; 200 </DISPLAY>
                    </STORE>
                 </STOREDATA>




Ashok K Sharma
 04/05/12                                                                            8
<?xml version=“1.0” encoding=“UTF-8”?>
                 <STOREDATA>
                                                        Root Element
                 <!--STOREDATA is the root element-->
                     <STORE STOREID=“S101”>             Contains all other elements
                       <PRODUCTNAME>Toys</PRODUCTNAME> in the document.

                       <QUANTITY>100</QUANTITY>
                       <DISPLAY>The price of this toy
                        is &lt; 200 </DISPLAY>
                    </STORE>
                 </STOREDATA>




Ashok K Sharma
 04/05/12                                                                             9
<?xml version=“1.0” encoding=“UTF-8”?>
                 <STOREDATA>
                 <!--STOREDATA is the root element-->
                                                        Comments
                     <STORE STOREID=“S101”>
                       <PRODUCTNAME>Toys</PRODUCTNAME> Are statements used to
                                                            explain the XML code.
                       <QUANTITY>100</QUANTITY>
                       <DISPLAY>The price of this toy
                        is &lt; 200 </DISPLAY>
                    </STORE>
                 </STOREDATA>




Ashok K Sharma
 04/05/12                                                                           10
<?xml version=“1.0” encoding=“UTF-8”?>
                 <STOREDATA>
                 <!--STOREDATA is the root element-->
                     <STORE STOREID=“S101”>
                                                        Child Elements
                       <PRODUCTNAME>Toys</PRODUCTNAME>
                                                           Are the basic units used to
                       <QUANTITY>100</QUANTITY>            identify and describe data in
                                                           XML.
                       <DISPLAY>The price of this toy
                        is &lt; 200 </DISPLAY>
                    </STORE>
                 </STOREDATA>




Ashok K Sharma
 04/05/12                                                                                  11
Components of an XML Document (Contd.)


                 <?xml version=“1.0” encoding=“UTF-8”?>
                 <STOREDATA>
                 <!--STOREDATA is the root element-->
                     <STORE STOREID=“S101”>
                       <PRODUCTNAME>Toys</PRODUCTNAME> Attributes
                                                          Provide additional
                       <QUANTITY>100</QUANTITY>           information about the
                       <DISPLAY>The price of this toy     elements for which they are
                                                          declared.
                        is &lt; 200 </DISPLAY>
                    </STORE>
                 </STOREDATA>




Ashok K Sharma
 04/05/12                                                                               12
<?xml version=“1.0” encoding=“UTF-8”?>
                 <STOREDATA>
                 <!--STOREDATA is the root element-->
                     <STORE STOREID=“S101”>
                       <PRODUCTNAME>Toys</PRODUCTNAME> Content

                       <QUANTITY>100</QUANTITY>         Refers to the information
                                                        represented by the elements
                       <DISPLAY>The price of this toy   of an XML document. An
                        is &lt; 200 </DISPLAY>          element can contain:
                    </STORE>
                                                        • Character or data content
                 </STOREDATA>
                                                        • Element content
                                                        • Combination or mixed
                                                          content




Ashok K Sharma
 04/05/12                                                                             13
<?xml version=“1.0” encoding=“UTF-8”?>
                 <STOREDATA>
                 <!--STOREDATA is the root element-->
                     <STORE STOREID=“S101”>
                       <PRODUCTNAME>Toys</PRODUCTNAME>

                       <QUANTITY>100</QUANTITY>           Entities
                       <DISPLAY>The price of this toy     Is a set of information that
                        is &lt; 200 </DISPLAY>            can be used by specifying a
                    </STORE>                              single name.
                 </STOREDATA>




Ashok K Sharma
 04/05/12                                                                                14
Every start tag must have an end tag.
             Empty tags must be closed using a forward
             slash (/).
             All attribute values must be given in double
             quotation marks.
             Tags must have proper nesting.
             XML tags are case sensitive.




Ashok K Sharma
 04/05/12                                                   15
Xml
Element declaration

      Syntax
                 <!ELEMENT element-name (element-content)>
      Example
                 <!ELEMENT employee(#PCDATA)>

      Any Element content
               <!ELEMENT employee ANY>
      Other Child Element as Content
               <!ELEMENT employee (name,phone,age,dept)>
      At least One occurrence of child element
               <!ELEMENT employee (name,contact+)>
      Zero or more occurrence of element
               <!ELEMENT employee(name,phone,email*)>


Ashok K Sharma                                               04/05/12   17
Attribute Declaration

       Syntax
       <!ATTLIST element-name attribute-name attribute-type default-value>

       Example
       <!ATTLIST payment type CDATA "check">


         Entities
       Entity References           Character
       &lt;                        <
       &gt;                        >
       &amp;                       &
       &quot;                      "
       &apos;                      '

Ashok K Sharma                                                     04/05/12   18
<?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>


           http://www.xmlvalidation.com/

Ashok K Sharma                                   04/05/12   19
Note.dtd
    <!ELEMENT note (to,from,heading,body)>
    <!ELEMENT to (#PCDATA)>
    <!ELEMENT from (#PCDATA)>
    <!ELEMENT heading (#PCDATA)>
    <!ELEMENT body (#PCDATA)>

  Referring DTD from XML
  <!DOCTYPE root-element SYSTEM "filename">
     Note.xml
     <?xml version="1.0"?>
     <!DOCTYPE note SYSTEM "note.dtd">
     <note>
      <to>Tove</to>
      <from>Jani</from>
      <heading>Reminder</heading>
      <body>Don't forget me this weekend!
     </body>
     </note>
Ashok K Sharma                                04/05/12   20
Xml
An XML schema defines the list of
                 elements and attributes that can be
                 used in an XML document.
                 An XML schema specifies the order in
                 which the elements appear in the XML
                 document, and their data types.
                 Microsoft has developed the XML
                 Schema Definition (XSD) language to
                 define the schema of an XML
                 document.

Ashok K Sharma
 04/05/12                                               22
Some of the advantages of creating an XML
         schema by using XSD are:
             XSD provides control over the type of data that can
             be assigned to elements and attributes.
             XSD enables you to create your own data types.
             XSD enables you to specify restrictions on data.
             The syntax for defining an XSD is the same as the
             syntax used for XML documents.
             XML schema content models can be used to
             validate mixed content.
             XML schema is extensible.
             XML schema is self documenting.


Ashok K Sharma
 04/05/12                                                          23
Data Types in XML Schemas (Contd.)



                 In an XML schema created using
                 XSD, every element must be
                 associated with a data type.
                 XSD Data Types
                  Primitive
                  User Defined
                   Simple Type
                   Complex Type




Ashok K Sharma
 04/05/12                                         24
A Boolean true or false value. Representations of true are "true" and "1"; false
                      is denoted as "false" or "0".
boolean


byte                  A signed 8-bit integer in the range [-128, 127].
date                  Represents a specific date
                      Represents a specific instant of time. It has the form YYYY-MM-DDThh:mm:ss
dateTime
                      folowed by an optional time-zone suffix
decimal               Any base-10 fixed-point number.
double                A 64-bit floating-point decimal number
float                 A 32-bit floating-point decimal number
int
                   Represents a 32-bit signed integer in the range [-2,147,483,648, 2,147,483,647].
integer            Represents a signed integer
language           One of the standardized language codes
long               A signed, extended-precision integer; at least 18 digits are guaranteed
negativeInteger    Represents an integer less than zero
nonNegativeInteger An integer greater than or equal to zero
nonPositiveInteger An integer less than or equal to zero.
positiveInteger    An extended-precision integer greater than zero
string             Any sequence of zero or more characters.
1. Complex Type : A data type which contains other elements.
2. Simple Type : A data type which contains one formatted element.
Xml
A CSS is a text file containing one or
                 more rules or definitions for the style
                 characteristics of a particular
                 element.
                 It controls how tags are formatted in
                 XML and HTML documents.
                 The CSS file can be included in XML
                 documents with the same data
                 structure.

Ashok K Sharma
 04/05/12                                                  28
A CSS can be applied to an XML
                 document using the following
                 syntax:                            Specifies the type of
                 <?xml:stylesheet type="text/css"   formatting that is being used.
                 href="path-name"?>




Ashok K Sharma
 04/05/12                                                                            29
Introducing XSL


                 CSS does not support the reorder, sort, and display of
                 elements based on a condition.
                 For such advanced formatting, XML supports
                 Extensible Style Sheet Language (XSL).
                 XSL has two parts:
                   XSL Transformations (XSLT)
                   XML Path (XPath)
                 XSL:
                   Contains instructions on how an XML document should
                   be transformed into an HTML or an XHTML document.
                   Uses XPath expressions to extract specific data from an
                   XML document.
                 The XSLT processor transforms the XML document
                 into an HTML or XHTML or into another XML
                 document.


Ashok K Sharma
 04/05/12                                                                    30
The XSLT processor applies the
                 transformation information to the
                 source document and builds the
                 result tree as shown in the following
                 figure.              MSXML Parser

                   XSLT style sheet     XSLT tree



                                           XSLT      Result tree
                                         processor




                   XML document        Source tree

Ashok K Sharma
 04/05/12                                                          31
XSLT provides the following
          elements to select and format data:
             stylesheet
             value-of
             for-each
             sort
             text



Ashok K Sharma
 04/05/12                                       32
XSLT provides the following
                 elements to select and format data:
                 c stylesheet     Instructs the browser that the document is a style
                                sheet file.
                 g value-of       Is the root element for all XSLT style sheets.
                                  Is written as:
                 g for-each     <xsl:stylesheet
                                 xmlns:xsl=

                 g sort          "http://www.w3.org/1999/XSL/Transform"
                                 version="1.0">

                 g text



Ashok K Sharma
 04/05/12                                                                              33
XSLT provides the following
                 elements to select and format data:
                                  Displays the value of the specified element or
                 c stylesheet   attribute.
                                  Follows the syntax:
                 g value-of     <xsl:value‑of
                                 select="elementname/attributename"/>
                 g for-each
                 g sort
                 g text



Ashok K Sharma
 04/05/12                                                                          34
XSLT provides the following
                 elements to select and format data:
                 c stylesheet Instructs the XSLT processor to process the
                             information for each instance of the specified pattern.
                 g value-of    Follows the syntax:
                                         <xsl:for-each select="pattern">
                 g for-each              [action to be performed]
                                         </xsl:for-each>
                 g sort
                 g text



Ashok K Sharma
 04/05/12                                                                              35
XSLT provides the following
                 elements to select and format data:
                 c stylesheet
                 g value-of Sorts data based on the values assigned to elements
                                   and
                 g for-each           attributes.
                                       Follows the syntax:
                                      <xsl:sort select="expression"
                 g sort               order="ascending | descending"
                                      case-order="upper-first | lower-first“
                 g text               data-type="text | number | qname"/>




Ashok K Sharma
 04/05/12                                                                         36
XSLT provides the following
                 elements to select and format data:
                 c stylesheet
                 g value-of
                                  Generates constant text in the output and displays
                 g for-each     labels.
                                  Follows the syntax:
                 g sort         <xsl:text> Text to be displayed as
                                 label </xsl:text>
                 g text



Ashok K Sharma
 04/05/12                                                                              37
Used with the if and choose elements to narrow down
                   the formatting criteria.
                 r The following table lists various comparison and Boolean
                   operators.
                     Operator   Meaning                    Example
                                                           PRICE[. = 20]
                       =        Equal to                   PRODUCTNAME[. = ‘Mini Bus’]
                                                           PRICE[. != 20]
                       !=       Not equal to
                                                           PRODUCTNAME[. != ‘Barbie Doll’]
                      &lt;      Less than                  PRICE[. &lt; 20]
                      &gt;      Greater than               PRICE[. &gt; 20]
                      &lt;=     Less than or equal to      PRICE[. &lt;= 20]
                      &gt;=     Greater than or equal to   PRICE[. &gt;= 20]
                     and        Logical AND                PRICE[. &gt 20 and . &lt; 30]

                      or        Logical OR                 PRICE[. = 20 or . = 45]
                      not       Negation operator          PRICE[not(. = 30)]


Ashok K Sharma
 04/05/12                                                                                    38
Operator/Special   Example               Description
Character

@                  @PRODUCTID            Used as a prefix for the attribute.

@*                 @*                    Selects all attributes.

:                  :                     Separates the namespace prefix from the element or
                                         attribute name.

( )                (PRICE*QUANTITY)      Used to group operations.

[ ]                [@PRODUCTID='P001']   Applies a filter pattern.


+                  num1 + num2           Returns the sum of two numbers.

-                  num1 - num2           Returns the difference of two numbers.

*                  num1 * num2           Returns the product of two numbers.

div                num1 div num2         Returns the quotient of two numbers.

mod                num1 mod num2         Returns the modulus, that is, the remainder of integer
                                         division.
Xml
DOM defines the logical structure of documents.
                 DOM provides an Application Programming Interface
                 (API) for dynamically accessing and manipulating a
                 document.
                 The DOM objects have associated methods and
                 properties to access and manipulate a document.
                 A DOM-enabled parser is required to use the features
                 provided by DOM.
                 A DOM-enabled parser:
                   Parses an XML document to ascertain its validity.
                   Creates an in‑memory representation of the XML
                   document as a tree structure.




Ashok K Sharma
 04/05/12                                                               41
MSXML parser:
                   Is the Microsoft implementation of DOM.
                   Provides fundamental as well as added interfaces to access
                   documents.
                 The following figure represents how a DOM tree is used by
                 applications to access data.

                                      MSXML Library

                  XML                             DOM Tree
                 Document    Parser               Root                Application
                                       Parsed          Child
                                      Document                 Text
                                                       Child
                                                               Text




Ashok K Sharma
 04/05/12                                                                           42
Following are the key DOM objects:
                  Document
                  Element
                  Node
                  NodeList
                  Attr
                  Text
                  ParseError

Ashok K Sharma
 04/05/12                                             43
Following are the the top-level object thatobjects:
                                 •It is
                                        key DOM implements all the
                                       basic DOM methods.
                 e Document           •It also has methods that support XSLT.
                                      •It has methods that can be used to navigate,
                 e Element            query, and modify the content and structure of
                                      an XML document.
                                      •Some of the methods provided by this object
                 e Node                are createElement(), createAttribute(),
                                       createComment() , and createTextNode().
                 e NodeList           •Some of the properties provided by this object that
                                       help in manipulating the information contained in
                 e Attr                the object are async, childNodes, firstChild,
                                       documentElement, xml, and readyState.

                 e Text
                 e ParseError


Ashok K Sharma
 04/05/12                                                                                    44
Following are the key DOM objects:
                 e Document       •It represents all the element nodes in an XML
                                  document.
                 e Element        •The attributes associated with the elements are

                                   considered to be the properties of the elements
                 e Node            rather than their child elements.
                                   •Some of the methods of this object are
                 e NodeList        also inherited from the Node object.
                                   •Some of the methods provided by this object
                                are
                 e Attr           getAttribute(),
                                   getElementsByTagName(),
                 e Text            normalize(), and removeAttributeNS().


                 e ParseError


Ashok K Sharma
 04/05/12                                                                            45
Following are the key DOM objects:
                 e Document
                                It represents a single node in the XML document
                 e Element      tree structure.
                                It provides methods to work with child elements.
                 e Node         Some of the methods of this object are
                                appendChild(newChild),
                                insertBefore(newNode,refNode),
                 e NodeList     and removeChild(nodeName).

                 e Attr
                 e Text
                 e ParseError


Ashok K Sharma
 04/05/12                                                                          46
Following are the key DOM objects:
                 e Document
                 e Element       It provides a list of nodes present in an XML
                                  document for manipulation.
                 e Node          This object enables you to iterate through a
                                  collection of nodes.
                 e NodeList      Some of the method of this object are item()
                                  and nextNode().

                 e Attr
                 e Text
                 e ParseError


Ashok K Sharma
 04/05/12                                                                         47
Following are the key DOM objects:
                 e Document
                 e Element
                 e Node             It represents an attribute of the Element
                                object.
                                    It is also a Node and inherits various
                 e NodeList     attributes
                                   and methods of Node object.
                 e Attr             An attribute is not considered by the DOM to
                                be
                 e Text            a child node of an element, but rather a property.


                 e ParseError


Ashok K Sharma
 04/05/12                                                                               48
Following are the key DOM objects:
                 e Document
                 e Element
                 e Node
                                     It represents the text inside an XML element
                                in
                 e NodeList         the node tree.
                                    The splitText() method is associated
                 e Attr         with
                                    this object.

                 e Text
                 e ParseError


Ashok K Sharma
 04/05/12                                                                            49
XML DOM Objects in Scripts



                 The DOM objects can be used within
                 scripting languages such as
                 JavaScript and VBScript.
                 Using DOM objects in scripts allow
                 dynamically applying a style sheet to
                 an XML document.
                 The code for using DOM objects for
                 accessing an XML document needs
                 to be used as an HTML page.

Ashok K Sharma
 04/05/12                                                50
Xml

More Related Content

PDF
Lesson10
PDF
Lesson08
PPTX
Sql for biggner
PDF
MySQL Partitioning 5.6
PDF
Using sql server 2008's merge statement tech republic
PPT
Introduction to XML
Lesson10
Lesson08
Sql for biggner
MySQL Partitioning 5.6
Using sql server 2008's merge statement tech republic
Introduction to XML

Viewers also liked (20)

PPT
Introduction to XML
PPTX
Xml ppt
PPTX
XML, DTD & XSD Overview
PPTX
Introduction to xml
PPT
Introduction to XML
PPT
Xml Session No 1
PPT
XML - EXtensible Markup Language
PPTX
XML | Computer Science
PPT
XML and Web Services with PHP5 and PEAR
PPTX
Struts introduction
PDF
Basic JSTL
PPTX
jstl ( jsp standard tag library )
PDF
Introduction to Struts 1.3
PPT
java packages
PPS
Packages and inbuilt classes of java
PPT
JSP Standart Tag Lİbrary - JSTL
PDF
JSP Standard Tag Library
PPT
PDF
Database recovery techniques
Introduction to XML
Xml ppt
XML, DTD & XSD Overview
Introduction to xml
Introduction to XML
Xml Session No 1
XML - EXtensible Markup Language
XML | Computer Science
XML and Web Services with PHP5 and PEAR
Struts introduction
Basic JSTL
jstl ( jsp standard tag library )
Introduction to Struts 1.3
java packages
Packages and inbuilt classes of java
JSP Standart Tag Lİbrary - JSTL
JSP Standard Tag Library
Database recovery techniques
Ad

Similar to Xml (9)

ODP
PDF
Android de la A a la Z XML Ulises Gonzalez
ODP
Solr features
PDF
XML Introduction
PPT
DB2 Native XML
PDF
Transforming xml with XSLT
DOCX
PDF
Xml overview
Android de la A a la Z XML Ulises Gonzalez
Solr features
XML Introduction
DB2 Native XML
Transforming xml with XSLT
Xml overview
Ad

Recently uploaded (20)

PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PPTX
The various Industrial Revolutions .pptx
PDF
Unlock new opportunities with location data.pdf
PPTX
Web Crawler for Trend Tracking Gen Z Insights.pptx
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PPTX
observCloud-Native Containerability and monitoring.pptx
PDF
Zenith AI: Advanced Artificial Intelligence
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
Architecture types and enterprise applications.pdf
PPTX
Modernising the Digital Integration Hub
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PDF
Hybrid model detection and classification of lung cancer
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Getting Started with Data Integration: FME Form 101
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PPTX
Tartificialntelligence_presentation.pptx
PDF
DP Operators-handbook-extract for the Mautical Institute
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
The various Industrial Revolutions .pptx
Unlock new opportunities with location data.pdf
Web Crawler for Trend Tracking Gen Z Insights.pptx
NewMind AI Weekly Chronicles – August ’25 Week III
observCloud-Native Containerability and monitoring.pptx
Zenith AI: Advanced Artificial Intelligence
Benefits of Physical activity for teenagers.pptx
Architecture types and enterprise applications.pdf
Modernising the Digital Integration Hub
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
Hybrid model detection and classification of lung cancer
1 - Historical Antecedents, Social Consideration.pdf
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Getting Started with Data Integration: FME Form 101
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
sustainability-14-14877-v2.pddhzftheheeeee
Tartificialntelligence_presentation.pptx
DP Operators-handbook-extract for the Mautical Institute

Xml

  • 2. •XML stands for EXtensible Markup Language •XML is a markup language much like HTML •XML was designed to carry data, not to display data •XML tags are not predefined. You must define your own tags •XML is designed to be self-descriptive •XML is a W3C Recommendation
  • 3. There are two current versions of XML. The first XML 1.0 was initially defined in 1998 and it has undergone minor changes/revisions since then. Though changes have been done, a new revision number has not been assigned to this version. It is called XML 1.0 5th edition, with the latest edition (5th) being released on 26th Nov 2008. The second version XML 1.1 was initially published on 4th Feb 2004, the same day as the XML 1.0, 3rd edition. XML 1.1 is currently in its 2nd edition which was released on 16th Aug 2006. It contains certain features that are expected to make XML easier to use.
  • 4. . Mobile Application Web Services Windows Application Web Application XML DB2 Oracle SQL Server Access Data Sources Ashok K Sharma 04/05/12 4
  • 5. Domain-specific vocabulary Data interchange Smart searches Granular updates User-selected view of data Message transformation Ashok K Sharma 04/05/12 5
  • 6. The various components of an XML document used for representing data in a hierarchical order are: Processing Instruction (PI) Tags Elements Content Attributes Entities Comments Ashok K Sharma 04/05/12 6
  • 7. <?xml version=“1.0” encoding=“UTF-8”?> <STOREDATA> Processing Instruction (PI) <!--STOREDATA is the root element--> Provides information on how <STORE STOREID=“S101”> the XML file should be <PRODUCTNAME>Toys</PRODUCTNAME> processed. <QUANTITY>100</QUANTITY> <DISPLAY>The price of this toy is &lt; 200 </DISPLAY> </STORE> </STOREDATA> Ashok K Sharma 04/05/12 7
  • 8. <?xml version=“1.0” encoding=“UTF-8”?> <STOREDATA> <!--STOREDATA is the root element--> Tags <STORE STOREID=“S101”> Is a means of identifying <PRODUCTNAME>Toys</PRODUCTNAME> data. Tags consist of start tag and end tag. <QUANTITY>100</QUANTITY> <DISPLAY>The price of this toy is &lt; 200 </DISPLAY> </STORE> </STOREDATA> Ashok K Sharma 04/05/12 8
  • 9. <?xml version=“1.0” encoding=“UTF-8”?> <STOREDATA> Root Element <!--STOREDATA is the root element--> <STORE STOREID=“S101”> Contains all other elements <PRODUCTNAME>Toys</PRODUCTNAME> in the document. <QUANTITY>100</QUANTITY> <DISPLAY>The price of this toy is &lt; 200 </DISPLAY> </STORE> </STOREDATA> Ashok K Sharma 04/05/12 9
  • 10. <?xml version=“1.0” encoding=“UTF-8”?> <STOREDATA> <!--STOREDATA is the root element--> Comments <STORE STOREID=“S101”> <PRODUCTNAME>Toys</PRODUCTNAME> Are statements used to explain the XML code. <QUANTITY>100</QUANTITY> <DISPLAY>The price of this toy is &lt; 200 </DISPLAY> </STORE> </STOREDATA> Ashok K Sharma 04/05/12 10
  • 11. <?xml version=“1.0” encoding=“UTF-8”?> <STOREDATA> <!--STOREDATA is the root element--> <STORE STOREID=“S101”> Child Elements <PRODUCTNAME>Toys</PRODUCTNAME> Are the basic units used to <QUANTITY>100</QUANTITY> identify and describe data in XML. <DISPLAY>The price of this toy is &lt; 200 </DISPLAY> </STORE> </STOREDATA> Ashok K Sharma 04/05/12 11
  • 12. Components of an XML Document (Contd.) <?xml version=“1.0” encoding=“UTF-8”?> <STOREDATA> <!--STOREDATA is the root element--> <STORE STOREID=“S101”> <PRODUCTNAME>Toys</PRODUCTNAME> Attributes Provide additional <QUANTITY>100</QUANTITY> information about the <DISPLAY>The price of this toy elements for which they are declared. is &lt; 200 </DISPLAY> </STORE> </STOREDATA> Ashok K Sharma 04/05/12 12
  • 13. <?xml version=“1.0” encoding=“UTF-8”?> <STOREDATA> <!--STOREDATA is the root element--> <STORE STOREID=“S101”> <PRODUCTNAME>Toys</PRODUCTNAME> Content <QUANTITY>100</QUANTITY> Refers to the information represented by the elements <DISPLAY>The price of this toy of an XML document. An is &lt; 200 </DISPLAY> element can contain: </STORE> • Character or data content </STOREDATA> • Element content • Combination or mixed content Ashok K Sharma 04/05/12 13
  • 14. <?xml version=“1.0” encoding=“UTF-8”?> <STOREDATA> <!--STOREDATA is the root element--> <STORE STOREID=“S101”> <PRODUCTNAME>Toys</PRODUCTNAME> <QUANTITY>100</QUANTITY> Entities <DISPLAY>The price of this toy Is a set of information that is &lt; 200 </DISPLAY> can be used by specifying a </STORE> single name. </STOREDATA> Ashok K Sharma 04/05/12 14
  • 15. Every start tag must have an end tag. Empty tags must be closed using a forward slash (/). All attribute values must be given in double quotation marks. Tags must have proper nesting. XML tags are case sensitive. Ashok K Sharma 04/05/12 15
  • 17. Element declaration Syntax <!ELEMENT element-name (element-content)> Example <!ELEMENT employee(#PCDATA)> Any Element content <!ELEMENT employee ANY> Other Child Element as Content <!ELEMENT employee (name,phone,age,dept)> At least One occurrence of child element <!ELEMENT employee (name,contact+)> Zero or more occurrence of element <!ELEMENT employee(name,phone,email*)> Ashok K Sharma 04/05/12 17
  • 18. Attribute Declaration Syntax <!ATTLIST element-name attribute-name attribute-type default-value> Example <!ATTLIST payment type CDATA "check"> Entities Entity References Character &lt; < &gt; > &amp; & &quot; " &apos; ' Ashok K Sharma 04/05/12 18
  • 19. <?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> http://www.xmlvalidation.com/ Ashok K Sharma 04/05/12 19
  • 20. Note.dtd <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> Referring DTD from XML <!DOCTYPE root-element SYSTEM "filename"> Note.xml <?xml version="1.0"?> <!DOCTYPE note SYSTEM "note.dtd"> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend! </body> </note> Ashok K Sharma 04/05/12 20
  • 22. An XML schema defines the list of elements and attributes that can be used in an XML document. An XML schema specifies the order in which the elements appear in the XML document, and their data types. Microsoft has developed the XML Schema Definition (XSD) language to define the schema of an XML document. Ashok K Sharma 04/05/12 22
  • 23. Some of the advantages of creating an XML schema by using XSD are: XSD provides control over the type of data that can be assigned to elements and attributes. XSD enables you to create your own data types. XSD enables you to specify restrictions on data. The syntax for defining an XSD is the same as the syntax used for XML documents. XML schema content models can be used to validate mixed content. XML schema is extensible. XML schema is self documenting. Ashok K Sharma 04/05/12 23
  • 24. Data Types in XML Schemas (Contd.) In an XML schema created using XSD, every element must be associated with a data type. XSD Data Types Primitive User Defined Simple Type Complex Type Ashok K Sharma 04/05/12 24
  • 25. A Boolean true or false value. Representations of true are "true" and "1"; false is denoted as "false" or "0". boolean byte A signed 8-bit integer in the range [-128, 127]. date Represents a specific date Represents a specific instant of time. It has the form YYYY-MM-DDThh:mm:ss dateTime folowed by an optional time-zone suffix decimal Any base-10 fixed-point number. double A 64-bit floating-point decimal number float A 32-bit floating-point decimal number int Represents a 32-bit signed integer in the range [-2,147,483,648, 2,147,483,647]. integer Represents a signed integer language One of the standardized language codes long A signed, extended-precision integer; at least 18 digits are guaranteed negativeInteger Represents an integer less than zero nonNegativeInteger An integer greater than or equal to zero nonPositiveInteger An integer less than or equal to zero. positiveInteger An extended-precision integer greater than zero string Any sequence of zero or more characters.
  • 26. 1. Complex Type : A data type which contains other elements. 2. Simple Type : A data type which contains one formatted element.
  • 28. A CSS is a text file containing one or more rules or definitions for the style characteristics of a particular element. It controls how tags are formatted in XML and HTML documents. The CSS file can be included in XML documents with the same data structure. Ashok K Sharma 04/05/12 28
  • 29. A CSS can be applied to an XML document using the following syntax: Specifies the type of <?xml:stylesheet type="text/css" formatting that is being used. href="path-name"?> Ashok K Sharma 04/05/12 29
  • 30. Introducing XSL CSS does not support the reorder, sort, and display of elements based on a condition. For such advanced formatting, XML supports Extensible Style Sheet Language (XSL). XSL has two parts: XSL Transformations (XSLT) XML Path (XPath) XSL: Contains instructions on how an XML document should be transformed into an HTML or an XHTML document. Uses XPath expressions to extract specific data from an XML document. The XSLT processor transforms the XML document into an HTML or XHTML or into another XML document. Ashok K Sharma 04/05/12 30
  • 31. The XSLT processor applies the transformation information to the source document and builds the result tree as shown in the following figure. MSXML Parser XSLT style sheet XSLT tree XSLT Result tree processor XML document Source tree Ashok K Sharma 04/05/12 31
  • 32. XSLT provides the following elements to select and format data: stylesheet value-of for-each sort text Ashok K Sharma 04/05/12 32
  • 33. XSLT provides the following elements to select and format data: c stylesheet Instructs the browser that the document is a style sheet file. g value-of Is the root element for all XSLT style sheets. Is written as: g for-each <xsl:stylesheet xmlns:xsl= g sort "http://www.w3.org/1999/XSL/Transform" version="1.0"> g text Ashok K Sharma 04/05/12 33
  • 34. XSLT provides the following elements to select and format data: Displays the value of the specified element or c stylesheet attribute. Follows the syntax: g value-of <xsl:value‑of select="elementname/attributename"/> g for-each g sort g text Ashok K Sharma 04/05/12 34
  • 35. XSLT provides the following elements to select and format data: c stylesheet Instructs the XSLT processor to process the information for each instance of the specified pattern. g value-of Follows the syntax: <xsl:for-each select="pattern"> g for-each [action to be performed] </xsl:for-each> g sort g text Ashok K Sharma 04/05/12 35
  • 36. XSLT provides the following elements to select and format data: c stylesheet g value-of Sorts data based on the values assigned to elements and g for-each attributes. Follows the syntax: <xsl:sort select="expression" g sort order="ascending | descending" case-order="upper-first | lower-first“ g text data-type="text | number | qname"/> Ashok K Sharma 04/05/12 36
  • 37. XSLT provides the following elements to select and format data: c stylesheet g value-of Generates constant text in the output and displays g for-each labels. Follows the syntax: g sort <xsl:text> Text to be displayed as label </xsl:text> g text Ashok K Sharma 04/05/12 37
  • 38. Used with the if and choose elements to narrow down the formatting criteria. r The following table lists various comparison and Boolean operators. Operator Meaning Example PRICE[. = 20] = Equal to PRODUCTNAME[. = ‘Mini Bus’] PRICE[. != 20] != Not equal to PRODUCTNAME[. != ‘Barbie Doll’] &lt; Less than PRICE[. &lt; 20] &gt; Greater than PRICE[. &gt; 20] &lt;= Less than or equal to PRICE[. &lt;= 20] &gt;= Greater than or equal to PRICE[. &gt;= 20] and Logical AND PRICE[. &gt 20 and . &lt; 30] or Logical OR PRICE[. = 20 or . = 45] not Negation operator PRICE[not(. = 30)] Ashok K Sharma 04/05/12 38
  • 39. Operator/Special Example Description Character @ @PRODUCTID Used as a prefix for the attribute. @* @* Selects all attributes. : : Separates the namespace prefix from the element or attribute name. ( ) (PRICE*QUANTITY) Used to group operations. [ ] [@PRODUCTID='P001'] Applies a filter pattern. + num1 + num2 Returns the sum of two numbers. - num1 - num2 Returns the difference of two numbers. * num1 * num2 Returns the product of two numbers. div num1 div num2 Returns the quotient of two numbers. mod num1 mod num2 Returns the modulus, that is, the remainder of integer division.
  • 41. DOM defines the logical structure of documents. DOM provides an Application Programming Interface (API) for dynamically accessing and manipulating a document. The DOM objects have associated methods and properties to access and manipulate a document. A DOM-enabled parser is required to use the features provided by DOM. A DOM-enabled parser: Parses an XML document to ascertain its validity. Creates an in‑memory representation of the XML document as a tree structure. Ashok K Sharma 04/05/12 41
  • 42. MSXML parser: Is the Microsoft implementation of DOM. Provides fundamental as well as added interfaces to access documents. The following figure represents how a DOM tree is used by applications to access data. MSXML Library XML DOM Tree Document Parser Root Application Parsed Child Document Text Child Text Ashok K Sharma 04/05/12 42
  • 43. Following are the key DOM objects: Document Element Node NodeList Attr Text ParseError Ashok K Sharma 04/05/12 43
  • 44. Following are the the top-level object thatobjects: •It is key DOM implements all the basic DOM methods. e Document •It also has methods that support XSLT. •It has methods that can be used to navigate, e Element query, and modify the content and structure of an XML document. •Some of the methods provided by this object e Node are createElement(), createAttribute(), createComment() , and createTextNode(). e NodeList •Some of the properties provided by this object that help in manipulating the information contained in e Attr the object are async, childNodes, firstChild, documentElement, xml, and readyState. e Text e ParseError Ashok K Sharma 04/05/12 44
  • 45. Following are the key DOM objects: e Document •It represents all the element nodes in an XML document. e Element •The attributes associated with the elements are considered to be the properties of the elements e Node rather than their child elements. •Some of the methods of this object are e NodeList also inherited from the Node object. •Some of the methods provided by this object are e Attr getAttribute(), getElementsByTagName(), e Text normalize(), and removeAttributeNS(). e ParseError Ashok K Sharma 04/05/12 45
  • 46. Following are the key DOM objects: e Document It represents a single node in the XML document e Element tree structure. It provides methods to work with child elements. e Node Some of the methods of this object are appendChild(newChild), insertBefore(newNode,refNode), e NodeList and removeChild(nodeName). e Attr e Text e ParseError Ashok K Sharma 04/05/12 46
  • 47. Following are the key DOM objects: e Document e Element  It provides a list of nodes present in an XML document for manipulation. e Node  This object enables you to iterate through a collection of nodes. e NodeList  Some of the method of this object are item() and nextNode(). e Attr e Text e ParseError Ashok K Sharma 04/05/12 47
  • 48. Following are the key DOM objects: e Document e Element e Node It represents an attribute of the Element object. It is also a Node and inherits various e NodeList attributes and methods of Node object. e Attr An attribute is not considered by the DOM to be e Text a child node of an element, but rather a property. e ParseError Ashok K Sharma 04/05/12 48
  • 49. Following are the key DOM objects: e Document e Element e Node It represents the text inside an XML element in e NodeList the node tree. The splitText() method is associated e Attr with this object. e Text e ParseError Ashok K Sharma 04/05/12 49
  • 50. XML DOM Objects in Scripts The DOM objects can be used within scripting languages such as JavaScript and VBScript. Using DOM objects in scripts allow dynamically applying a style sheet to an XML document. The code for using DOM objects for accessing an XML document needs to be used as an HTML page. Ashok K Sharma 04/05/12 50

Editor's Notes

  • #5: While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
  • #6: While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
  • #7: Tell the students that the key words that they were told to note while discussing the definition of system forensics, will be elaborated as part of the system forensics process.
  • #8: Tell the students that the key words that they were told to note while discussing the definition of system forensics, will be elaborated as part of the system forensics process.
  • #9: Tell the students that the key words that they were told to note while discussing the definition of system forensics, will be elaborated as part of the system forensics process.
  • #10: Tell the students that the key words that they were told to note while discussing the definition of system forensics, will be elaborated as part of the system forensics process.
  • #11: Tell the students that the key words that they were told to note while discussing the definition of system forensics, will be elaborated as part of the system forensics process.
  • #12: Tell the students that the key words that they were told to note while discussing the definition of system forensics, will be elaborated as part of the system forensics process.
  • #13: Tell the students that the key words that they were told to note while discussing the definition of system forensics, will be elaborated as part of the system forensics process.
  • #14: Tell the students that the key words that they were told to note while discussing the definition of system forensics, will be elaborated as part of the system forensics process.
  • #15: Tell the students that the key words that they were told to note while discussing the definition of system forensics, will be elaborated as part of the system forensics process.
  • #23: Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  • #24: Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  • #25: While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
  • #29: Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  • #30: Hold a two- three minute discussion on the different types of system-related crimes that the students have experienced or heard. At the end of the discussion, give additional examples of system-related crimes.
  • #31: While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
  • #32: Elaborate on the role that system forensics plays in an organization, based on the discussion in the previous slide and the information given on this slide.
  • #33: Connect the information given on this slide to the initial discussion held on the different types of system-related crimes.
  • #34: Connect the information given on this slide to the initial discussion held on the different types of system-related crimes.
  • #35: Connect the information given on this slide to the initial discussion held on the different types of system-related crimes.
  • #36: Connect the information given on this slide to the initial discussion held on the different types of system-related crimes.
  • #37: Connect the information given on this slide to the initial discussion held on the different types of system-related crimes.
  • #38: Connect the information given on this slide to the initial discussion held on the different types of system-related crimes.
  • #39: While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
  • #42: Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  • #43: Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  • #44: Hold a two- three minute discussion on the different types of system-related crimes that the students have experienced or heard. At the end of the discussion, give additional examples of system-related crimes.
  • #45: Hold a two- three minute discussion on the different types of system-related crimes that the students have experienced or heard. At the end of the discussion, give additional examples of system-related crimes.
  • #46: Hold a two- three minute discussion on the different types of system-related crimes that the students have experienced or heard. At the end of the discussion, give additional examples of system-related crimes.
  • #47: Hold a two- three minute discussion on the different types of system-related crimes that the students have experienced or heard. At the end of the discussion, give additional examples of system-related crimes.
  • #48: Hold a two- three minute discussion on the different types of system-related crimes that the students have experienced or heard. At the end of the discussion, give additional examples of system-related crimes.
  • #49: Hold a two- three minute discussion on the different types of system-related crimes that the students have experienced or heard. At the end of the discussion, give additional examples of system-related crimes.
  • #50: Hold a two- three minute discussion on the different types of system-related crimes that the students have experienced or heard. At the end of the discussion, give additional examples of system-related crimes.
  • #51: Elaborate on the role that system forensics plays in an organization, based on the discussion in the previous slide and the information given on this slide.