XML Presentation by Kamalakar Dandu

Embed Size (px)

Citation preview

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    1/79

    COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    XML - An Introduction

    A Presentation By

    Kumar

    Microsoft Competence Group

    Satyam Enterprise Solutions Limited

    XML - An Introduction

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    2/79

    XML - Introduction

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    3/79

    COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    What is XML?

    Extensible Markup Language (XML) is a W3C proposedrecommendation for a file format to easily and cheaply distributeelectronic documents on the World Wide Web

    XML gives developers the power to deliver structured data from a widevariety of applications to the desktop for local computation and

    presentation. XML allows the creation of unique data formats for specific

    applications; it is also an ideal format for server-to-server transfer ofstructured data.

    Delivers data for local computation.

    Gives users an appropriate view of structured data.

    Enables the integration of structured data from multiple sources intocommon logical views.

    Describes data from a wide variety of applications.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    4/79

    COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    Why Not HTML?

    In short, HTML provides rich facilities for display, it does not provideany standards-based way to manage data. For Ex. HTML Does not

    provide a standard way for a doctor to send a prescription to apharmacist.

    enable a medical laboratory to publish statistical information in a

    format that any receiver can analyze.

    describe an electronic payment in a form that any recipient candecode and process.

    provide a standard way to search law libraries for all litigation

    documents about a certain topic. specify how information in a company catalog can be transmitted

    in a way that allows a salesman to work offline, show the catalog toclients, take orders, and upload those orders in a standard format.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    5/79

    COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    Once the data is on the client desktop, it can be manipulated, edited,and presented in multiple views, without return trips to the server.

    Servers can now become more scalable, due to lower computationaland bandwidth loads.

    Also, since data is exchanged in the XML format, it can be easilymerged from different sources.

    XML is valuable to the Internet, as well as to large corporate intranetenvironments, because it provides interoperability using a flexible,open, standards-based format, with new ways of accessing legacy

    databases and delivering data to Web clients.

    Applications can be built more quickly, are easier to maintain, and caneasily provide multiple views on the structured data.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    6/79

    COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    7/79COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    XML in all..

    Extensibility

    HTML with user-defined tags

    Can be used in any domain

    Structure XML provides a structural representation of data that can beimplemented broadly and is easy to deploy.

    Can represent trees and graph structures(database schemas, OO hierarchies, )

    Validation Consuming applications can check for

    structural validity on importation

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    8/79COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    A Sample XML

    September 04, 200009:45

    Chennai

    Tamil Nadu

    India

    partly cloudy

    30

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    9/79COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    HTML and XML

    The power and beauty of XML is that it maintains the separation of theuser interface from the structured data.

    HTML specifies how to display data in a browser, XML defines thecontent.

    In HTML you use tags to tell the browser to display data as bold oritalic; with XML you only use tags to describe data, such as city name,temperature, and barometric pressure.

    In XML, you use style sheets such as Extensible Style Language(XSL) and Cascading Style Sheets (CSS) to present the data in a

    browser.

    XML separates the data from the presentation and the process,enabling you to display and process the data as you wish by applyingdifferent style sheets and applications.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    10/79COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    Comments and Escaped Content

    Script elements frequently include greater than ()symbols, the ampersand symbol (&), and other characters that arereserved in XML.

    If you are creating a closely conformant XML file, you must make surethat these reserved characters do not confuse the XML parser.

    you can make an entire script element opaque by enclosing it in a section.

    Example:

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    11/79COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    Processing Instructions

    Special instructions to the XML consumer application

    Example:

    version

    A string in the form n.nspecifying the XML level of the file. Use the value1.0.

    DTDflagOptional.

    A Boolean value indicating whether the XML file includes a reference toan external Document Type Definition (DTD). Script component XML files

    do not include such a reference, so the value for this attribute is always"yes."

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    12/79COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    Our New XML Sample

    September 04, 2000

    09:45

    ChennaiTamil Nadu

    India

    this is an hml file]]>

    partly cloudy

    30

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    13/79

    XML Namespaces

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    14/79COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    Conflicting Issues

    Because XML is truly about interoperability and everyone is free tocreate their own XML vocabularies, everything would start to breakdown rather quickly if different developers chose identical elementnames to represent conceptually distinct entities.

    To safeguard against these potential conflicts, the W3C introducednamespaces into the XML language.

    You use XML namespaces to provide a context for your XMLdocument elements.

    XML namespaces allow developers to resolve elements to a particular

    implementation semantic.

    In the case of our example, the temperature element on one systemmight represent the reactor temperature, but on our system itrepresents the Citys temperature.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    15/79COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    XML Document with xmlns:

    Masala DosaRice Pan Cake with Potato Masala0.992.99

    Rava IddlyRice Boiled Cake with Coconut Chutny

    0.25

    0.99

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    16/79COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    XML Namespaces

    This code tells any reader that if a name begins withpurchase:" its meaning is defined by whoever owns the

    "http://www.indianfood.org /franchise/price" namespace.

    Similarly, elements beginning with the sales:" prefix have

    meanings defined by the corresponding namespace. Namespaces ensure that element names do not conflict, and

    clarify who defined which term.

    Namespaces do not give instructions on how to process the

    elements. Readers still need to know what the elements mean and decide

    how to process them.

    Namespaces simply keep the names straight.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    17/79

    XML Schemas

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    18/79COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    Self Definition

    Another extremely useful feature that is built into XML is the idea thatdocuments contain information about themselvesmetadata.

    If the tags and attributes are well-designed, both people andcomputers can read and use the information contained in the XMLdocument.

    With XML, Document Type Definitions (DTDs) / Schemas canaccompany a document, essentially defining the rules of thedocument, such as which elements are present and the structuralrelationship between the elements.

    DTDs and Schemas help to validate the data when the receivingapplication does not have a built-in description of the incoming data.With XML, however, DTDs are optional.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    19/79COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    Document Type Definition (DTD)

    Data sent along with a DTD is known as valid XML. In this case, an XML parser could check incoming data against the rules

    defined in the DTD to make sure the data was structured correctly.

    Data sent without a DTD is known as well-formed XML.

    Here an XML-based document instance, such as the hierarchicallystructured weather data shown, can be used to implicitly describe itself.

    With both valid and well-formed XML, XML encoded data is self-describing since descriptive tags are intermixed with the data.

    The open and flexible format used by XML allows it to be employed

    anywhere a need exists for the exchange and transfer of information.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    20/79COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    DTD for our Simple XML

    A DTD consists of a left square bracket character ([) followed bya series of markup declarations, followed by a right squarebracket character (]).

    ]

    >

    This is the most simplest XML document I have ever seen

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    21/79COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    DTC Declarations

    Element type declarations

    Attribute-list declarations

    Entity declarations

    Notation declarations

    Processing declarations Comments

    Parameter entity references

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    22/79

    COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    Element Type

    Title permitted ti have only char data

    You can use any key word which is legal under General Root tag

    Element must be empty. It can not have anything

    Book element must have the 3 elements in the same order

    Prerequisite element can have either only one of the above

    Qualification could be one or more, XMLExpousure is optional andOtherSkills could be zero or more

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    23/79

    COMPETENCE GROUP

    ASEI-CMMLEVELCompany Presentation by Kumar

    ]

    >

    Devotional Songs by Pankaj

    Kajal by Pankaj

    Classical Songs by Pankaj

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    24/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Attribute List

    In a valid XML document you must also explicitly declare allattributes that you might intend to use with the documents

    elements.

    You define this by using a type of DTD markup known as anattribute-list declaration.

    This declaration does the following

    Defines the names of the attributes associated with that element

    Specifies the data type of each attribute

    Specifies for each attribute whether that attribute is required.

    Attibute-list declaration has the following form:

    Name - is the type name of the element associated with the attribute

    AttDefs - is the attribute definition that defines one atribute

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    25/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Simple form of defining an attribute. Attribute contains characters

    you must specify an attribute value

    You can either include or omit the attribute, no default value supplied

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    26/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    ]

    >

    Hum Aapke Hain Kaun

    Love Story

    Madhuri Dixit

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    27/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Using an External DTDThe XML File MyExternDTD.XML

    Hum Aapke Hain Kaun

    Love Story

    Madhuri Dixit

    Document Definition file - MyExternDTD.dtd

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    28/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Exercises - ????

    DTD for Visiting Card - Is it OK?

    ]>

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    29/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Schema

    The schema defines the elements that can appear within thedocument and the attributes that can be associated with an element.

    It also defines the structure of the document: which elements are childelements of others, the sequence in which the child elements canappear, and the number of child elements.

    It defines whether an element is empty or can include text. Theschema can also define default values for attributes.

    A schema is a formal specification of the rules of an XMLdocument, namely the element names, that indicateswhich elements are allowed in a document and in whatcombinations

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    30/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Schema Explained

    Using a schema, an author can define precisely which elementnames are permitted in a document and, within each element,which sub-elements, attributes, and relations are allowed.

    An author can import fragments from other schemata, andextend types through inheritance. This allows complex

    relationships between elements, while retaining the simplicity ofa lexical tree structure.

    Authors can invent their own schemata, or they can share onescreated by other authors. Readers can check the schema

    references to verify that the document they have received is thecorrect type.

    They can also use the information in the schema to validate thestructure of the document automatically.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    31/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    One method for describing this schema is the Document TypeDefinition (DTD), a grammar that can be used to formally describe aparticular schema.

    Other method is to use XML-Schema which is the easiest method as itdefines the schema using standard XML tags rather than DTDs.

    XML Schema, like DTD, can be used to specify the schema of aparticular class of documents.

    Unlike DTDs, however, XML Schema uses XML syntax.

    This is convenient since you are not required to learn a completely

    new syntax just to describe your grammaralthough you do need tolearn how to declare elements and attributes using XML Schema.

    XML Schemas offer a number of other significant advantages overusing DTDs.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    32/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    The Mechanism

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    33/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Weather XML and Schema

    1970-09-3067.5

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    34/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Schema Document Element

    The definitions in an XML schema are contained within the top-levelSchema document element.

    The Schema document element definition must come from thenamespace: xmlns="urn:schemas-microsoft-com:xml-data."

    The Schema document element in an XML Schema document shouldalso contain namespace declarations for any other schemas, such asthe namespace that defines the built-in data types for XML Schema.

    http://xmrefschemaelement.htm/http://xmrefschemaelement.htm/
  • 8/2/2019 XML Presentation by Kamalakar Dandu

    35/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Schema Elements & Attributes

    ElementType: Assigns a type and conditions to anelement, and what, if any, child elements it can contain.

    AttributeType: Assigns a type and conditions to anattribute.

    attribute: Declares that a previously defined attribute typecan appear within the scope of the named ElementTypeelement.

    element: Declares that a previously defined element typecan appear within the scope of the named ElementType

    element.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    36/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Step - 1 Attribute & Element Types

    The content of the schema begins with the AttributeTypeand ElementType declarations of the innermost elements.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    37/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Step-2 Attributes for child Elements

    The next ElementType declaration is followed by its attribute andchild elements.

    When an element has attributes or child elements they must beincluded this way in its ElementType declaration.

    They must also be previously declared in their own ElementType orAttributeType declaration

    This process is continued throughout the rest of the schema, untilevery element and attribute has been declared.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    38/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    ElementType

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    39/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Content

    Indicator of whether the content must be empty, or cancontain text, elements, or both.

    The following values can be assigned to this attribute. Empty - The element cannot contain content.

    textOnly - The element can contain only text, not elements. Note that if themodel attribute is set to "open," the element can contain text and otherunnamed elements.

    eltOnly - The element can contain only the specified elements. It cannotcontain any free text.

    Mixed - The element can contain a mix of named elements and text.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    40/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Model & Name

    Model is the Indicator of whether the content can includeonly what is defined in the content model, or can containcontent not specified in the model.

    When the model is defined as open, the element can include

    ElementType elements, AttributeType elements, and mixed content notspecified in the content model.

    When the model is defined as closed, the element cannot includeelements and cannot include mixed content not specified in the contentmodel. The document type definition (DTD) uses a closed model.

    Name of the element. This attribute is required. If thiselement type is declared as a valid child of anotherelement type, this name is specified within an elementelement.

    http://attributetype.htm/http://element.htm/http://element.htm/http://attributetype.htm/
  • 8/2/2019 XML Presentation by Kamalakar Dandu

    41/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Order

    The following values can be assigned to this attribute. One - Permits only one of a set of elements.

    Seq - Requires the elements to appear in the specified sequence.

    Many - Permits the elements to appear (or not appear) in any order.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    42/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    AttributeType

    default

    Default value for the attribute. The default value must be legal for thatattribute instance. For example, when the attribute is an enumerated type,the default value must appear in the values list.

    dt:values

    When dt:type is set to "enumeration," this attribute lists the possiblevalues.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    43/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    dt:type Specifies the data type for this attribute type. In the implementation

    provided with Internet Explorer 5, an attribute can take one of the followingtypes: entity, entities, enumeration, id, idref, idrefs, nmtoken, nmtokens,notation, or string. When the type "enumeration" is selected, the dt:valuesattribute should also be supplied, listing the allowed values. For more

    information about data types, see XML Data Types.

    name

    Name of the attribute type. This attribute is required. References to thisattribute type within an ElementType definition are made in the schemawith the attribute element. The name supplied here corresponds to the

    "type" attribute of the "attribute" element.

    required

    Indicator of whether the attribute must be present on the element.

    http://datatypes.htm/http://elementtype.htm/http://attribute.htm/http://attribute.htm/http://elementtype.htm/http://datatypes.htm/
  • 8/2/2019 XML Presentation by Kamalakar Dandu

    44/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Syntax type

    Name of an ElementType element defined in this schema (oranother schema indicated by the specified namespace).

    The supplied value must correspond to the name attribute on theElementType element.

    Note that the type can include a namespace prefix.

    http://elementtype.htm/http://elementtype.htm/
  • 8/2/2019 XML Presentation by Kamalakar Dandu

    45/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    minOccurs

    Optional - Minimum number of times the reference element type canoccur on the element. The following values can be assigned to thisattribute.

    0 - When the minimum value is zero, the specified element is notrequired; the element is optional.

    1 - The specified element must occur at least once.

    maxOccurs

    Optional - Maximum number of times the element can occur on theelement. The following values can be assigned to this attribute.

    1 - Can occur at most once.

    * - Unlimited number of occurrences.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    46/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    XML Data Types

    In addition to the string and other primitive types defined by the XML1.0 recommendation, the Microsoft XML processor supports a rich setof additional data types.

    This release also supports conversions between the primitive typesand these rich data types.

    Data types are referenced from the data type namespace,"urn:schemas-microsoft-com:datatypes".

    To use data types within an XML Schema, declare the data typenamespace within the schema document.

    Normally the data type namespace has been assigned the "dt" prefix.

    http://datatypes.htm/http://datatypes.htm/http://datatypes.htm/http://datatypes.htm/
  • 8/2/2019 XML Presentation by Kamalakar Dandu

    47/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    8

    1012

    For further reading refer XML Data Types in MSDN

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    48/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    XML for Schema Exercise

    James Smith

    3.8

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    49/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    ClassSchema.xml

    Corresponding XML Schema

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    50/79

    XSL

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    51/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    XSL

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    52/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Presenting XML

    There are two style sheet languages available for use with XML inInternet Explorer

    Cascading Style Sheets (CSS)

    Extensible Style Language (XSL)

    An important point to consider in choosing a style sheet language for aparticular document is whether the structure of the XML document issuitable for display.

    With CSS, the structureof the XML content must be virtually identicalto the structureof the presentation.

    Since one of the goals of XML is a complete separation of contentfrom display, many XML documents are difficult to display as youmight wish using CSS.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    53/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    XML and CSS

    A cascading style sheet is a separate HTML file that keeps track ofdesign and format information such as the colors, fonts, font sizes,and margins you use in your help files or Web pages.

    By linking your HTML /XML files to a cascading style sheet, you caneasily create a consistent design for all of your files.

    For example, suppose that you select a background color, colors foryour links and text, and fonts for each heading level in your files.Instead of specifying that information in each file, you can create astyle sheet. When you want to change those settings in all your files,you change only the style sheet.

    You can also create a separate style sheet for different displaydevices. For example, Pocket PCs, handheld PCs, Desktop PCs,Monochrome Screens etc

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    54/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Books.XML

    Professional Active Server Pages 3.0

    Richard Anderson

    Chris Blexrud

    Andrea Chiarelli

    Dan Denault

    us="$59.99"

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    55/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Books.CSS

    authors{

    display:block;

    font-family:Arial,Helvetica;

    font-style:italic;font-size:10pt;

    color:#990099;

    text-align:left;

    }

    price{

    display:block;

    border:2px solid black;

    padding:1em;background-color:#888833;

    color:#FFFFDD;

    font-weight:bold

    margin-bottom: .4em;

    }

    Try display:inline

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    56/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Problems with CSS Lets assume a XML for Hotel which is structured as following sections

    Data about the Hotel

    Hotel Category Information - Like a **, ***, ****, *****

    The Facilities in that Hotel.

    An excerpt from the menu.

    When applying CSS to this document, the overall structure must be usedfor the display as well.

    For example, the four sections will be displayed in the order they appearin the document.

    If later on it became necessary that the Hotel Category should bedisplayed after the menu excerpts, the XML document itself would haveto be modified, not just the style sheet.

    XSL transcends this limitation by allowing sophisticated transformations.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    57/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    XSL Advantages

    More sophisticated layout using HTML tables.

    Data items appearing more than once in the style sheet

    Access to information stored in attribute values

    Reordering of items

    Dynamic display behaviors not easily possible through CSS ormodifying of the source

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    58/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Interview.XML

    Mahesh

    Baypar

    88

    Mahesh

    Baypar

    99

    Mahesh

    Baypar

    100

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    59/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Name

    Project

    Score

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    60/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Interview.XSL

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    61/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Xsl:for-each

    order-by Sort criteria in a semicolon-separated list. When the first sort

    results in two equal items, the second sort criterion is checked, andso on. The first non-white-space character in each sort criterionindicates whether the sort is ascending (optional +) or descending(-). The sort criterion is expressed as an XSL pattern, relative tothe pattern described in the select attribute.

    select

    XSL pattern query evaluated the current context to determine theset of nodes to iterate over. The default value "node()" indicatesselection of all children of the current node.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    62/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    63/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Xsl:value-of

    Inserts the value of the selected node as text.

    select

    XSL pattern to be matched against the current context. The default value is ".", which inserts the value of the current node.

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    64/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Accessing the Attribute

    Go to the Interview.XML and introduce an attribute called Skill tothe Candidate

    NameProject

    Score

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    65/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    66/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Accessing Attribute of Child Node

    Now introduce attribute as DOB to Name and try this code.

    Name

    Date of Birth

    Project

    Score

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    67/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    68/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    The BestXSLDemo.ZIP

    This Zip file is located in our Public folderunder Markup Languages - XML.

    Copy this to your local Directory, unzip

    Startup File Name :Multiple.htm

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    69/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    XSL Demo

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    70/79

    XML DOM

    h O OO

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    71/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    The DOM not DOOM

    The Document Object Model (DOM) is a platform- andlanguage-neutral interface that permits script to accessand update the content, structure, and style of adocument.

    The DOM includes a model for how a standard set ofobjects representing HTML and XML documents arecombined, and an interface for accessing andmanipulating them.

    Web authors can use the DOM interface in InternetExplorer 5 and later to take advantage of this dynamicmodel.

    Th T S

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    72/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    The Tree Structure

    XML P d DOM

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    73/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    XML Parser and DOM Retrieving information from XML files is done by an XML parser.

    An XML parser is, quite simply, software that reads an XML file andmakes available the data in it.

    In general all parsers support the XML Document Object Model(DOM).

    The DOM defines a standard set of commands that parsers shouldexpose so you can access HTML and XML document content fromyour programs.

    An XML parser that supports the DOM will take the data in an XMLdocument and expose it via a set of objects that you can programagainst.

    Here we will learn how to access and manipulate XML documents viathe XML DOM implementation, as exposed by the Microsoft XMLParser (MSXML.DLL).

    MSXML DLL

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    74/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    MSXML.DLL

    You use the XML DOM by creating an instance of an XMLparser.

    To make this possible, Microsoft exposes the XML DOMvia a set of standard COM interfaces, in MSXML.DLL.

    MSXML.DLL contains the type library and implementationcode for you to work with XML documents.

    You can obtain the MSXML library in one of two ways.

    You can install Internet Explorer 5.0the MSXMLparser is an integral component.

    Alternatively, you can download a redistributableversion of the parser.

    C i I f XML P

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    75/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Creating Instance of XML Parser

    If you're working with a scripting client, such as VBScript executing inInternet Explorer, you use the DOM by using the CreateObject methodto create an instance of the parser object.

    Set objDOM = CreateObject( "Microsoft.XMLDOM" )

    L di XML D

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    76/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Loading an XML Document

    If objDOM .Load("C:\My Documents\cds.xml") Then

    ' The document loaded successfully.

    ' Now do something intersting.

    Else

    ' The document failed to load.

    End If

    A i El t

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    77/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Accessing Elements

    Accessing a Child Nodes Text.

    MyElement = objDOM.documentElement.FirstChild.text

    Accssing one of the Child Nodes Text. (if one or more child node

    exist at the same level)

    MyElement =objDOM.documentElement.firstChild.childNodes(1).text

    C ti El t & S tti V l

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    78/79

    COMPETENCE GROUP

    ASEI-CMM

    LEVELCompany Presentation by Kumar

    Creating Element & Setting Values

    Set RootNode = objDOM.createElement(Interview)

    RootNode.appendChild objDOM.createElement(Name)

    RootNode.appendChild objDOM.createElement(Project)

    RootNode.appendChild objDOM.createElement(Score)

    RootNode.childNodes(0).text = Deepa

    RootNode.childNodes(1).text = Banking

    RootNode.childNodes(1).text = 99

  • 8/2/2019 XML Presentation by Kamalakar Dandu

    79/79

    XML DOM Demo

    By - Rohini