Published on

  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • XML 1.0 is the specification that defines what "tags" and "attributes" are XLink describes a standard way to add hyperlinks to an XML file. XPointer is a syntax in development for pointing to parts of an XML document. CSS , the style sheet language, is applicable to XML as it is to HTML. XSL is the advanced language for expressing style sheets. Based on XSLT. XSLT is used to transfom XML documents from one form to other.
  • Key Messages: .NET is our implementation of xml web services – our strategy to ensure that our products connect better together and better with others. we ’ ve spent the past 3 years making XML web services integral to our entire business software platform .NET provides the comprehensive means for interoperating and driving new value from all of your (your partners and customers) existing systems … regardless of platform they run on or what programming language they were created in … Your decision will be in choosing the best software platform for bringing connectedness and integration to life … and we hope you see that .NET is the best choice We are continuing to push XML Web services and support for it in the toolset – you will see our implementations of WS-Security as we get into the details of our platform and tools Slide Build: 2 [see script] Slide Script: [BUILD 1] Microsoft .NET is software for connecting people, systems, information and devices. For Developers it means the ability to quickly build solutions that interoperate across languages, platforms and devices For IT, it means the ability to integrate new and existing systems across the organization and externally w/ Partners For Businesses, it means having the agility to connect more deeply with customers, integrate with business partners and empower its employees For Consumers it ’ s the ability to access and act upon information anytime, anywhere and on any device [BUILD 2] Microsoft .NET is built on a foundation of XML Web Services enabling both new and existing applications to connect with software and services across platforms, applications and programming languages Slide Transition: Strips Right-Down Additional Information for Presenter: NOTE: If you forego a drilldown on tools, servers, etc, this slide provides a high level overview on the commitment.
  • The current version of XML is 1.0. Still XML version 1.1 exists but not used those have special requirements. Any Kind of Data: XML documents contain text, never binary data. So BMP, voice information can’t be store in XML documents. To include binary data you need to encode into different format and you can specify encode format as attribute. But MTOM works on binary format. Unambiguous structure: An XML document not only contains data but also the structure
  • XML is designed to improve the functionality of the Web by providing more flexible and adaptable information identification. XML is a powerful tool for data representation, storage, modelling , and interoperation . Structured information contains both content (words, pictures, etc.) and some indication of what role that content plays (for example, content in a section heading has a different meaning from content in a footnote, which means something different than content in a figure caption or content in a database table, etc.). Almost all documents have some structure. A meta language used to define new markup languages . With XML, you can create a language crafted specifically for your application or domain. (Eg: XAML, ebXML , etc.,) SGML is the Standard Generalized Markup Language defined by ISO 8879. This is also a meta language. SGML has been the standard, vendor-independent way to maintain repositories of structured documentation for more than a decade, but it is not well suited to serving documents over the web. XML was created so that richly structured documents could be used over the web. The only viable alternatives, HTML and SGML, are not practical for this purpose.
  • Well formed documents are: Only small set of rules. Semantics not really known. Can be displayed Can be processed Easy to work with. Valid XML documents are: Can be validated against a standard set of rules Large number of DTD's available For instance XHTML is an XML DTD Others: e-business, multimedia, chemical language, mathematics, etc. Advantage: correct interpretation and processing possible Superceeded by XML-schema: start today, use schema not DTD
  • explex
  • In short HTML is a markup language for presentation, and XML is a language for creating markup language that describe structured data.
  • XML has its root in SGML which was created in 1986. SGML was too complex, something bit simpler was needed thus the birth of XML. SGML is the Standard Generalized Markup Language defined by ISO 8879. SGML has been the standard, vendor-independent way to maintain repositories of structured documentation for more than a decade, but it is not well suited to serving documents over the web.
  • The XML PI is: Very important for detecting encoding Identifies XML when file and media type information is unavailable or unreliable
  • Elements are the most common form of markup. Delimited by angle brackets, most elements identify the nature of the content they surround. <title> Definitive XML Schema </title>
  • In order to insert these characters into your document as content, there must be an alternative way to represent them. Character reference is a mechanism for inserting characters that cannot be typed directly on your keyboard.
  • The name , called the PI target, identifies the PI to the application. Applications should process only the targets they recognize and ignore all other PIs. Any data that follows the PI target is optional, it is for the application that recognizes the target. The names used in PIs may be declared as notations in order to formally identify them. Any data that follows the PI target is optional, it is for the application that recognizes the target.
  • The commas between element names indicate that they must occur in succession. The plus after author indicates that it may be repeated more than once but must occur at least once. The question mark after price indicates that it is optional An XML DTD can be interchanged with the XML instance An XML DTD can provide a schema for a broad class of XML documents
  • Target element is the element which the attribute applies. Attr- Name is the attribute name.
  • The commas between element names indicate that they must occur in succession. The plus after employee indicates that it may be repeated more than once but must occur at least once. The question mark after nick indicates that it is optional
  • Schemas are developed to replace DTD’s
  • Schemas are developed to replace DTD’s The Schema consists a set of predefined rules that describes a given class of XML document.
  • XML Schema definition language (XSD) has become the mainstream language for describing XML documents.
  • The definitions placed within the xsd:schema element are automatically associated with the namespace specified in the targetNamespace attribute.
  • Lexical
  • The definitions placed within the xsd:schema element are automatically associated with the namespace specified in the targetNamespace attribute.
  • The key difference between the above two parsing is that DOM loads the entire document into an in-memory data structure. In case of SAX iterates over the XML document one piece at a time in a forward-only and read-only fashion. Processing instructions provide a mechanism for document authors to communicate with XML-aware applications behind the scenes. SAX is primarily a collection of interfaces in the org.xml.sax package. The interface ContentHandler is the key piece of SAX. Almost every SAX program need to use this interface. ContentHandler is a call back interface.
  • DOM allows programs and scripts to dynamically access and update the content structure and style of a document. The HTML DOM defines the objects and properties of all HTML elements, and the methods (interface) to access them.
  • Some of the DOM rules: In a node tree, the top node is called the root Every node, except the root, has exactly one parent node A node can have any number of children A leaf is a node with no children Siblings are nodes with the same parent Some of the properties and methods of XML DOM : These are some typical DOM properties: x.nodeName - the name of x x.nodeValue - the value of x x.parentNode - the parent node of x x.childNodes - the child nodes of x x.attributes - the attributes nodes of x Element methods are: x. getElementsByTagName ( name ) - get all elements with a specified tag name x. appendChild ( node ) - insert a child node to x x. removeChild ( node ) - remove a child node from x
  • SAX stands for Simple API for XML. Unlike DOM , there is no formal specification for SAX. The Java implementation of SAX is considered to be normative , and implementations in other languages attempt to follow the rules laid down in that implementation, adjusting for the differences in language where necessary. The memory footprint of a SAX parser, by contrast, is based only on the maximum depth of the XML file (the maximum depth of the XML tree) and the maximum data stored in XML attributes on a single XML element.
  • XmlReader and XmlWriter are abstract classes.
  • Another significant XML-related feature that was introduced in SQL Server 2005 is support for XML indexes . You can create primary and secondary XML indexes for columns of type xml to enhance XML query performance. XML DML is Microsoft enhancement for XQuery.
  • The XML data type in SQL Server can also be strongly typed with XML Schemas. With a strongly typed XML Column, it is verified if the data confirms to the schema when XML data is inserted.
  • XPath is used by XSL also by XPointer .
  • XPath is used by XSL also by XPointer .
  • The <xsl:stylesheet> and <xsl:transform> are completely synonymous and either can be used. The match attribute can also be used to define a template for the entire XML document.
  • An <xsl:template> element defines a template rule to be triggered when a particular part of the source document is being processed. The attribute match="/" indicates that this particular rule is triggered right at the start of processing the source document. Here «/» is an Xpath expression which identifies the root node of the document:
  • XQuery is based on existing XPath query language. With support added for better iteration, better sorting results, and the ability to construct the necessary XML. Whereas XML Schema only defined the types, XQuery has defined the operations that are allowed on those types. XQuery results are either typed or untyped. The type information is based on schema language. XQuery is a strongly typed programming language . Like Java and C#, for example, it's a mix of static typing (type consistency checked at compile-time) and dynamic typing (run-time type tests).
  • Types in XQuery: Numbers, including integers and floating-point numbers. The boolean values true and false. Strings of characters, for example: "Hello world!". These are immutable - i.e. you cannot modify a character in a string. Various types to represent dates, times, and durations. A few XML-related types. For example a QName is a pair of a local name (like template) and a URL, which is used to represent a tag name like xsl:template after it has been namespace-resolved.
  • Popular template processors , like JSP, ASP, and PHP, allow you to embed expressions in a programming language into HTML content. XQuery gives you that ability, plus the ability to embed XML/HTML forms inside expressions, and to have them be the value of variables and parameters. XQuery node values are immutable. You can’t modify node after it has been created. The sortby() takes an input sequence (in this case $books) and one or more ordering expressions . $books sortby (author/name)
  • The document() function returns the root node of a document. The /book expression selects the child elements of the root that are named book, so $book gets set to the single root element.
  • An important goal for XQuery is that it should be usable as a query language for XML databases. Compare the corresponding SQL statement,
  • So 3+4 is a complete, valid XQuery program which evaluates to the integer 7. The XQuery standard specifies the result value of an expression or program, but it does not specify how it is to be evaluated. An implementation has considerable freedom in how it evaluates an XQuery program, and what optimizations it does.
  • The below is second section of the fifth chapter of the doc. /doc/chapter[5]/section[2] XQuery element constructor consists of a start tag and an end tag, enclosing an optional list of expressions that provide the content of the element. A FLWOR expression binds some expressions, applies an optional predicate and ordering, and constructs a new result. FLOWER stands for FOR, LET, WHERE, ORDER and RETURN Clause
  • Popular template processors , like JSP, ASP, and PHP, allow you to embed expressions in a programming language into HTML content. XQuery gives you that ability, plus the ability to embed XML/HTML forms inside expressions, and to have them be the value of variables and parameters. XQuery node values are immutable. You can’t modify node after it has been created.
  • We've seen atomic values (numbers, strings, etc), and node values (elements, attributes, etc). These are together known as simple values. The for expression first evaluates the expression following the in . Then for each value of the resulting sequence, The variable (in this case $x) is bound to the value, and the return expression evaluated using that variable binding.
  • USER & AUTO: Today <A> links in HTML are USER Today <IMG> links in HTML are AUTO <A> links are ACTUATE =USER and SHOW =REPLACE <IMG> links are ACTUATE =AUTO and SHOW =EMBED
  • Simple declaration is : H1 { font-weight: bold } Simple Complex declaration is: H2, H3, H4 {font-size: 12pt; font-style: normal; font-weight: bold;} Complex
  • My Notes: Today's applications require the ability to communicate with other systems in an efficient and secure manner. Speaker Notes For years, software development has focused on how to best reuse the code that we write. Ultimately, people and businesses want long-term return on their short-term investments in code. How do we do this? We’ve seen 3 waves of advancement in this movement in recent decades: 1980s and Object-Orientation: Object-oriented development promised the idea of building reusable abstractions (called classes) that we could then inherit from in order to reuse the base class functionality. This shift from simple procedural-based code brought with it a lot of benefits including polymorphism (the ability to dynamically bind types at runtime), abstractions that included both state and behavior, and encapsulation (controlling which parts of the code the external world can access). However, Object-Orientation by itself didn’t facilitate the dynamic evolution of software at runtime. Once an application was built, it was static. There wasn’t an easy way to infuse new code into an application. 1990s and Components: Component-based development helped us overcome this challenge. It forced the developer to think about the external facing interface of the application. This enabled us to build systems that dynamically load and bind to new functionality at runtime (an application discovers new components after it has been built) and introduced the notion of an application as a growing/evolving organism. To facilitate dynamic loading, we saw a big emphasis on runtime metadata. In the past, you couldn’t easily discern application capabilities since there was very little/rudimentary metadata information stored as part of the application. Whereas C and C++ programs from 1980s were these relatively opaque collections of code, component-based applications of the 1990s enabled runtime inspection of code to determine what a particular component supported. This introduced the notion of self-describing systems. But while this metaphor worked really well on a single machine (using method invocation on an object reference), we hit scaling problems when we tried to stretch it out and apply it as the substrate for distributed software integration (across machines, etc). 2000s and Service-Orientation – With Service-Orientation, we retain the benefits of self-describing applications, explicit encapsulation, and dynamic loading of functionality. What changes is the metaphor with which we accomplish it. Instead of using method invocation on an object reference, we shift the conversation to that of message passing – a proven metaphor for scalable distributed software integration. In addition, to support dynamic loading of service-based functionality, we use schema to describes the structure of messages, behavioral contract to define acceptable message exchange patterns, and policy to define service semantics. Simplifying service-oriented development is one of the biggest bets we’re making in "WCF". "WCF" takes the service-oriented concepts of message passing, schema, contract, and policy, and implicitly applies it to all of the services we build. As such, "WCF" provides you with the first true service-oriented programming model. Transition to next slide: We define service oriented applications as those that adhere to “The Four Tenets of Service-Orientation.” Let’s examine these and see how "WCF" implements them… 03/27/11 05:51 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary. Next Generation Business Solutions Platform Strategy Review
  • Service management includes many functions including, Security, Deployment, Logging, Dynamic rerouting and Maintenance.
  • Speaker Notes Boundaries are Explicit: Services run in a separate process from their clients • Well-defined public interface to your service • Avoid RPC use explicit messages • Public “gateway” to your internal (private) implementation • Don’t expose implementation details. Explicit boundaries mean that a service can be deployed anywhere and be easily and freely accessed by other services, regardless of the environment or development language of the other service. Here messages need to cross the development environment boundaries. Same time it doesn’t care about the message consumer environment also. The thing to keep in mind is that there is a cost associated with crossing boundaries. These costs come in a number of forms, such as communication, performance, and processing overhead costs. Services should be called quickly and efficiently. Tenet 1: Boundaries are Explicit . Based on the underlying concept of encapsulation, this tenet specifies the publishing and consumption of functionality as sets of services that abstract their underlying implementation Services are Autonomous: • Deployed/Versioned independent of system and other services • Contract, once published should not be changed • A service owns its needed business components • A service should be able to perform without external dependencies Services are built and deployed independently of other services. Systems, especially distributed systems, must evolve over time and should be built to handle change easily. This SOA principle states that each service must be managed and versioned differently so as to not affect other services in the process. Ex: In the book publisher example, the Order Process service and Order Fulfillment service are completely independent of each other; each is versioned and managed completely independent of the other. In this way, when one changes it should not affect the other. It has been said that services should be built not to fail. In following this concept, if a service is unavailable for whatever reason or should a service depend on another service that is not available, every precaution should be taken to allow for such services to survive, such as redundancy or failover. Tenet 2: Services are Autonomous . Autonomy means we design the system to support the inevitable evolution of the service’s implementation over time. As we build our services, we need to assume that their internal implementation will evolve (be versioned) over time and that our services as well as the services on which we depend could change location at (almost) any time. Services share schema and contract, not class: • Clients send messages to a service that conform to a contract. • Classes contain data and behavior. • Contract must not change once published. • Contracts/Schemas provide platform-independent interoperability • Contract via WSDL Think “schemas = data” and “contracts = behavior.” The contract contains information regarding the structure of the message. Services do not pass classes and types; they pass schemas and contracts. This allows for a loosely coupled system where the service does not care what type of environment the other service is executing on. The information being passed is 100 percent platform independent.. Tenet 3: Services share schema and contract, not class . For those of you who are familiar with ASMX - this is exactly how ASMX works: The service publishes a contract that clients use to generate their own code to call the service. No types are shared between service and its clients by default. In addition, neither Service requires knowledge of each others’ internal workings in order to exchange data – they only need the published schemas & contracts. Service compatibility is determined based on policy: • Separate “content” from “behavior” • Policy describes non functional constraint such as communication protocols, security and reliability requirements Services look at each others’ policy, looking for similarities so that they can start communicating. If two services can’t satisfy each others’ policy requirements, all bets are off. These policies exist in the form of machine-readable expressions. Policies also allow you to move a service from one environment to another without changing the behavior of the service. Tenet 3: Service compatibility is determined based on policy . The services communicate through dynamically negotiated communications channels that support the necessary semantics (security, reliability, etc). Service policy statements created automatically based on configuration, class attributes, and method signatures. Client channels automatically configured via retrieved service policy. By “name” means that we reference a well known name in Policy that represents a whole specification of behavior that needs to be used when talking to this endpoint.
  • UDDI : Universal Description, Discovery and Integration. XML Web Service discovery is the process of locating and interrogating XML Web Service descriptions. Programmatic discovery can be enabled when an XML Web service publishes a .disco file.
  • If SOAP uses the HTTP as transport then HTTP security would be adequate for SOAP.
  • An Envelope : That defines a framework for describing what is in a message and how to process it. It is always a root element of SOAP message. Optional Header: A set of encoding rules for expressing instances of application-defined data types. When Header present it should be the first child element of the envelope. The Header element is a generic mechanism for adding features to a SOAP message in a decentralized manner. Mandatory Body: A convention for representing remote procedure calls and responses. Play load, response message and Fault elements goes here. The fault element is shown in <soap:Fault> . The fault element must contain a faultcode followed by faultstring .
  • The SOAP fault model requires that all SOAP-specific and application-specific faults be reported using a single distinguished element, env:Fault , carried within the env:Body element. The Fault element contains two mandatory sub-elements, Code and Reason , and (optionally) application-specific information in the Detail sub-element Another optional sub-element, Node , identifies via a URI the SOAP node which generated the fault, its absence implying that it was the ultimate recipient of the message which did so. There is yet another optional sub-element, Role , which identifies the role being played by the node which generated the fault. The Code sub-element of Fault is itself made up of a mandatory Value sub-element, whose content is specified in the SOAP specification as well as an optional Subcode sub-element.
  • The user subscribes to a feed by entering into the reader the feed's URI or by clicking an RSS icon in a web browser that initiates the subscription process. The RSS reader checks the user's subscribed feeds regularly for new work, downloads any updates that it finds, and provides a user interface to monitor and read the feeds.
  • The above RSS feed in version 1.0 format: <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"   xmlns="http://purl.org/rss/1.0/“ xmlns:dc="http://purl.org/dc/elements/1.1/“ >   <channel rdf:about="http://www.xml.com/cs/xml/query/q/19">     <title>XML.com</title>     <link>http://www.xml.com/</link>     <description>XML.com features a rich mix of information and services for the XML community.</description>     <language>en-us</language>     <items>       <rdf:Seq>         <rdf:li rdf:resource="http://www.xml.com/pub/a/2002/12/04/normalizing.html"/>         <rdf:li rdf:resource="http://www.xml.com/pub/a/2002/12/04/som.html"/>         <rdf:li rdf:resource="http://www.xml.com/pub/a/2002/12/04/svg.html"/>       </rdf:Seq>     </items>   </channel>   <item rdf:about="http://www.xml.com/pub/a/2002/12/04/normalizing.html">     <title>Normalizing XML, Part 2</title>     <link>http://www.xml.com/pub/a/2002/12/04/normalizing.html</link>     <description>In this second and final look at applying relational normalization techniques to W3C XML Schema data modeling, Will Provost discusses when not to normalize, the scope of uniqueness and the fourth and fifth normal forms.</description>     <dc:creator>Will Provost</dc:creator>     <dc:date>2002-12-04</dc:date>       </item>   <item rdf:about="http://www.xml.com/pub/a/2002/12/04/som.html">     <title>The .NET Schema Object Model</title>     <link>http://www.xml.com/pub/a/2002/12/04/som.html</link>     <description>Priya Lakshminarayanan describes in detail the use of the .NET Schema Object Model for programmatic manipulation of W3C XML Schemas.</description>     <dc:creator>Priya Lakshminarayanan</dc:creator>     <dc:date>2002-12-04</dc:date>       </item>   <item rdf:about="http://www.xml.com/pub/a/2002/12/04/svg.html">     <title>SVG's Past and Promising Future</title>     <link>http://www.xml.com/pub/a/2002/12/04/svg.html</link>     <description>In this month's SVG column, Antoine Quint looks back at SVG's journey through 2002 and looks forward to 2003.</description>     <dc:creator>Antoine Quint</dc:creator>     <dc:date>2002-12-04</dc:date>       </item> </rdf:RDF>
  • Xml

    1. 1. An overview of XML & SOAP Ch.Vishwa Mohan Project Manager KREST Embedded Technologies
    2. 2. Agenda <ul><li>What is XML ? </li></ul><ul><li>Where XML using ? </li></ul><ul><li>What is DTD ? </li></ul><ul><li>XML Schema Language </li></ul><ul><li>XML Query Languages </li></ul><ul><li>RSS </li></ul><ul><li>Web Services </li></ul><ul><li>SOAP & WSDL </li></ul>
    3. 3. XML Related Technologies <ul><li>XML </li></ul><ul><li>DTD </li></ul><ul><li>XML Schema </li></ul><ul><li>XPath </li></ul><ul><li>XQuery </li></ul><ul><li>XSLT </li></ul><ul><li>XLink & XPointer </li></ul><ul><li>CSS </li></ul><ul><li>XAML </li></ul><ul><li>SOAP & WSDL </li></ul><ul><li>RSS </li></ul><ul><li>All types of XML Specifications you can find at XML organization. </li></ul><ul><li>www.xml.org </li></ul><ul><li>WS-* specifications you can find at OASIS Web Site. </li></ul><ul><li>www.oasis-open.org </li></ul>
    4. 4. Microsoft .NET Experiences & Solutions Tools Software for Connecting Information, People, Systems and Devices XML Web Services across the Entire Microsoft Platform Servers Clients Services
    5. 5. What is XML ? <ul><li>XML is self describing </li></ul><ul><li>Open standard </li></ul><ul><li>Any kind of data </li></ul><ul><li>Unicode Character set </li></ul><ul><li>Clear syntax & Textual representation of data </li></ul><ul><li>Unambiguous structure </li></ul><ul><li>A language for creating markup languages </li></ul><ul><li>Platform Independent </li></ul><ul><li>Portable Data </li></ul><ul><li>Resembles HTML or SGML </li></ul><ul><ul><li>Tags, Attributes & Values </li></ul></ul><ul><ul><li>DTD’s </li></ul></ul>
    6. 6. What is XML ? <ul><li>XML is a markup language for document containing structured information. </li></ul><ul><li>XML is a markup specification language With which you can design ways of describing information (text or data), usually for storage, transmission or processing by a program. </li></ul><ul><li>A markup language is a mechanism to identify structures in a document. </li></ul><ul><li>XML is, roughly speaking, a restricted form of SGML. </li></ul><ul><li>XML is more then a markup language. It is a meta language A language used to define other languages . </li></ul><ul><li>XML is fully Unicode complaint. </li></ul><ul><li>XML is extensible, platform independent and supports internationalization and localization. </li></ul>
    7. 7. Different Types of XML Documents <ul><li>An XML document to be considered to be correct. It must meet two requirements: </li></ul><ul><ul><li>Well-formed </li></ul></ul><ul><ul><li>Valid </li></ul></ul><ul><li>A well-formed document must confirm to the following rules: </li></ul><ul><ul><li>An XML Document may contain XML declarations, PI’s, encoding and other information may exists. </li></ul></ul><ul><ul><li>Only one root element in specified XML document. </li></ul></ul><ul><ul><li>Elements those are not empty must specify start & end tags. </li></ul></ul><ul><ul><li>Empty elements can mark with the empty element tag. </li></ul></ul><ul><ul><li>Attributes must be enclosed in a single or double quotes. </li></ul></ul><ul><ul><li>Tags may be nested but must not overlap. </li></ul></ul><ul><ul><li>Elements names are case sensitive. </li></ul></ul><ul><ul><li>Document must used specified encoding (UTF-8). </li></ul></ul><ul><li>A valid document has data that confirms to a set of content rules. These rules describes the correct data values and document organizational structure. </li></ul>
    8. 8. What is Self Describing? ST*323*712990413 V1*7039610*NEW ZEALAND QUEEN*D*104N*SCAC***L LS*0100 R4*D*D*JAX*JACKSONVILLE FL**** V9*EAD**920819**JACKSONVILLE FL***A26 R4*D*D*ORF*NORFOLK, VA**NORFOLK INTL TERMIN** V9*EAD**920817**NORFOLK, VA***A26 R4*L*K*MEB*MELBOURNE, AUST**** V9*EDD**920712**MELBOURNE, AUST***A40 R4*L*K*SYD*SYDNEY, AUST**** V9*EDD**920715**SYDNEY, AUST***A40 R4*L*K*WLG*WELLINGTON, NEW ZEALAND**** V9*EDD**920721**WELLINGTON, NEW ZEA***A40 LE*0100 SE*25*712990413 This is not self describing data!
    9. 9. XML is Self Describing <?xml version=“1.0”?> <Data> <Item ID=“112”> <Name> Rod </Name> <Price> 12.00 </Price> <Units> 1 </Units> </Item> <Item ID=“114”> <Name>Reel</Name> <Price>15.00</Price> <Units>1</Units> </Item> <Item ID=“120”> <Name>Bait</Name> <Price>24.00</Price> <Units>3</Units> </Item> </Data> Here data is self explanatory <ul><li>In XML documents make structure explicit through markup: </li></ul><ul><li>Bad way to represent: <Transaction>Withdrawal 2003 12 15 200.00 </Transaction> </li></ul><ul><li>Better way : <Transaction type=&quot;withdrawal&quot;> </li></ul><ul><li><Date>2003-12-15</Date> </li></ul><ul><li><Amount>200.00</Amount> </li></ul><ul><li></Transaction> </li></ul>
    10. 10. What is XML is Not ? <ul><li>A replacement for HTML </li></ul><ul><li>A Programming Language </li></ul><ul><li>A Network Transport Protocol </li></ul><ul><li>A Database </li></ul>
    11. 11. XML vs HTML <ul><li>HTML is a markup language for presentation and XML is a language for creating markup language that describes the structured data. </li></ul>XML HTML Describes the structured data HTML describes layout. Allows you to define your own tags Has a fixed tag set Case sensitive Case insensitive All tags must be closed Not required. All attribute values must be in single or double quote mark. Different heading. First line of XML document is with <?xml ?>
    12. 12. The need for XML <ul><li>The real XML’s power come from the fact that it can be used regardless of the platform, language or data store of system using. </li></ul><ul><li>It is desirable to transport data around networks (including the internet). </li></ul><ul><li>XML is the format of choice for marking up that data. </li></ul><ul><li>SGML was too complex, HTML not robust enough. </li></ul>
    13. 13. A Simple XML File <?xml version=&quot;1.0&quot; encoding=&quot;utf-8“ ?> <books xmlns=&quot;http://www.MyStore.com/books&quot;> <book publisher=&quot;IDG books&quot; on-loan=&quot;Sanjay&quot;> <title>XML Bible</title> <author>Elliotte Rusty Harold</author> </book> <book publisher=&quot;Prentice Hall&quot; on-loan=&quot;Sander&quot; > <title>Definitive XML Schema</title> <author>Priscilla Walmsley</author> </book> <book publisher=&quot;APress&quot;> <title>A Programmer's Introduction to C#</title> <author>Eric Gunnerson</author> </book> </books> <ul><li>Optional </li></ul><ul><li>Specifies version , character set and encoding . </li></ul>
    14. 14. XML Syntax Rules <ul><li>Tags are case sensitive </li></ul><ul><li>Each document must have a root. </li></ul><ul><li>Closing tags are required </li></ul><ul><li>Values must be enclosed in quotation marks </li></ul><ul><li>Elements must be properly nested </li></ul><ul><li>Entities must be declared </li></ul>
    15. 15. An XML Example <ul><li>We will define a employee structure as follow: </li></ul><ul><ul><li>An employee is required to specify either male or female . </li></ul></ul><ul><ul><li>An employee has a name consists of </li></ul></ul><ul><ul><ul><li>A first name </li></ul></ul></ul><ul><ul><ul><li>A last name </li></ul></ul></ul><ul><ul><ul><li>An (optional) nick name </li></ul></ul></ul><ul><ul><li>An employee has a qualification. </li></ul></ul><ul><ul><li>An employee has a designation. </li></ul></ul>
    16. 16. XML Document Example <?xml version=&quot;1.0&quot; encoding=&quot;utf-8“ ?> <!DOCTYPE employees SYSTEM &quot;C:employee.dtd&quot;> <employees xmlns=&quot;http://www.krestembedded.com/empinfo&quot;> <employee gender=“male&quot;> <name> <first>Vishwa</first> <last> Mohan</last> <nick>C.V</nick> </name> <qualification>M.E </qualification> <designation>Project Manager</designation> </employee > <employee gender=“female&quot;> <name> <first>Subba</first> <last>Laxmi</last> </name> <qualification>B.Tech</qualification> <designation>Project Associate</designation> </employee > </employees>
    17. 17. XML Document Example <ul><li><?xml version=&quot;1.0&quot; encoding=&quot;utf-8“ ?> </li></ul><ul><li>The document begins with a processing instruction: </li></ul><ul><li>While it is not required, its presence explicitly identifies the document as an XML document and its version. </li></ul><ul><li>XML documents are composed of markup and content. </li></ul><ul><li>There are six kinds of markup that can occur in an XML document: </li></ul><ul><ul><li>elements ( and attributes) </li></ul></ul><ul><ul><li>entity references </li></ul></ul><ul><ul><li>comments </li></ul></ul><ul><ul><li>processing instructions </li></ul></ul><ul><ul><li>marked sections </li></ul></ul><ul><ul><li>document type declarations </li></ul></ul>
    18. 18. Elements vs Attributes <ul><li>Elements are the most common form of markup. Delimited by angle brackets, most elements identify the nature of the content they surround. </li></ul><ul><li><title> An introduction to C# Programming </title> </li></ul><ul><li>Some elements may be empty ( i.e., no content ). </li></ul><ul><li>Attributes are name-value pairs that occur inside start-tags after the element name. </li></ul><ul><li><book publisher =&quot;Prentice Hall&quot; > </book> </li></ul><ul><li>In XML, all attribute values must be either single or double quoted. </li></ul>
    19. 19. Attributes Advantages & Disadvantages <ul><li>Attributes Disadvantages: </li></ul><ul><ul><li>Can’t contain multiple values </li></ul></ul><ul><ul><li>Not very expandable </li></ul></ul><ul><ul><li>Can’t describe structures </li></ul></ul><ul><ul><li>More difficult to manipulate </li></ul></ul><ul><ul><li>Hard to test against DTD. </li></ul></ul><ul><li>Attribute Advantages: </li></ul><ul><ul><li>Great for internal info not needed by the user </li></ul></ul><ul><ul><li><messages> </li></ul></ul><ul><ul><li><Note ID =&quot;100&quot;>New Batch on .NET starts today </Note> </li></ul></ul><ul><ul><li><Note ID =&quot;101&quot;>New Batch on Java starts today </Note> </li></ul></ul><ul><ul><li></messages> </li></ul></ul>
    20. 20. Entity References <ul><li>Some of the characters are reserved for markup language ( Eg: ‘ < ‘, ‘ > ’, ..,). These characters have alternative name to represent them ( i.e., lt, gt, etc.,). </li></ul><ul><li>In XML, entities are used to represent these special characters. </li></ul><ul><li>To use an entity, you simply reference it by name. Entity references begin with the ampersand and ends with a semicolon . </li></ul><ul><li><book>  &lt; book>  &lt; book &gt; </li></ul><ul><li>Entities are also used to refer to often repeated or varying text and to include the content of external files. </li></ul><ul><li>Every entity must have a unique name. You can also define your own entities. </li></ul><ul><li>A special form of entity reference, called a character reference can be used to insert arbitrary Unicode characters into your document. It can be represented as </li></ul><ul><li>℞  ℞  Represents Rx symbol </li></ul>
    21. 21. Entity References <ul><li>The XML Specification provides 5 predefined internal entities: </li></ul><ul><ul><li>&lt; produces the left angle bracket, < </li></ul></ul><ul><ul><li>&gt; produces the right angle bracket, > </li></ul></ul><ul><ul><li>&amp; produces the ampersand, & </li></ul></ul><ul><ul><li>&apos; produces a single quote character (an apostrophe), ' </li></ul></ul><ul><ul><li>&quot; produces a double quote character, &quot; </li></ul></ul><ul><li>In addition to above entities there are other types of entities: </li></ul><ul><ul><li>External entities </li></ul></ul><ul><ul><li>Parameter Entities </li></ul></ul>
    22. 22. Comments <ul><li>Comments begin with <!-- and end with --> . </li></ul><ul><li>Comments can contain any data except the literal string “ -- ”. </li></ul><ul><li>You can place comments anywhere between markup. </li></ul><ul><li>Comments are not part of the textual content of an XML document. An XML processor is not required to pass them along to an application. </li></ul>
    23. 23. Processing Instructions <ul><li>Processing instructions (PIs) as an alternative means of passing information to a particular application that may read the document. ( Always appear before the root element) </li></ul><ul><li>Like comments, they are not textually part of the XML document but the XML processor is required to pass them to an application. </li></ul><ul><li>Processing instructions have the form: </li></ul><ul><ul><li><?name pidata?> </li></ul></ul><ul><li>Processing Instruction is just markup, but not element. </li></ul><ul><li>In the processing instructions section, you can script code, SQL statements etc.., </li></ul><ul><li>PI names beginning with xml are reserved for XML standardization. </li></ul><ul><li><?xml version=&quot;1.0&quot; encoding=&quot;utf-8“ ?> </li></ul><ul><li><?xml-stylesheet href=”person.css” type=”text/css”?> </li></ul>
    24. 24. Marked Sections <ul><li>In a document, a CDATA section instructs the parser to ignore most markup characters. This CDATA section starts with <![CDATA[ and ends the section with ]]> . </li></ul><ul><li><![CDATA[ </li></ul><ul><li>*p = &q; </li></ul><ul><li>b = (i <= 3); ]]> </li></ul><ul><li>All character data is passed directly to the application, without interpretation. </li></ul><ul><li>Elements, entity references, comments, & processing instructions are all unrecognized and the characters that comprise them are passed literally to the application. </li></ul><ul><li>The only string that cannot occur in a CDATA section is ]]>. </li></ul>
    25. 25. XML DTD & Schema
    26. 26. Document Type Declarations (DTD) <ul><li>Generally, declaration ( DTD, or Schema ) allows a document to communicate meta information to parser about its contents. </li></ul><ul><li>Meta-information includes the allowed sequence and nesting of tags, attribute values and their types and defaults, the names of external files that may be referenced and whether or not they contain XML. </li></ul><ul><li>There are four kinds of declarations in XML: </li></ul><ul><ul><li>Elements </li></ul></ul><ul><ul><li>Attributes </li></ul></ul><ul><ul><li>Entities </li></ul></ul><ul><ul><li>PCDATA & CDATA </li></ul></ul><ul><li>Element Type declaration identify the name of elements and the nature of their content. </li></ul><ul><li>< !ELEMENT books (title, author+, price?)> </li></ul><ul><li>DTD’s can be specified externally or you can embed internally. </li></ul>
    27. 27. Declaring Elements in a DTD <ul><li>General form of declaring element is : </li></ul><ul><li><!ELEMENT Element-Name Element-Rule> </li></ul><ul><ul><li>Creating an element which can contain both plain text & tags. </li></ul></ul><ul><ul><li><!ELEMENT Element-Name ANY > </li></ul></ul><ul><ul><li>Create an element which contain plain text but not other tags: <!ELEMENT Element-Name ( #PCDATA )> </li></ul></ul><ul><ul><li>To Create an empty element </li></ul></ul><ul><ul><li><!ELEMENT Element-Name EMPTY > </li></ul></ul><ul><ul><li>Create an element with children which must present in the order listed. </li></ul></ul><ul><ul><li><!ELEMENT Element-Name ( child1, child2 )> </li></ul></ul><ul><ul><li>Create an element with options ( Any one of them can appear, but not both). </li></ul></ul><ul><ul><li><!ELEMENT Element-Name ( child1 | child2 )> </li></ul></ul>
    28. 28. Declaring Elements in a DTD <ul><li>Some more element declarations are shown below: </li></ul><ul><ul><li>Create an element with child which must appear 0 or 1 times. </li></ul></ul><ul><ul><li><!ELEMENT Element-Name ( child ) ? > </li></ul></ul><ul><ul><li>Create an element with a child which must appear 1 or more times. </li></ul></ul><ul><ul><li> <!ELEMENT Element-Name ( child ) + > </li></ul></ul><ul><ul><li>Create an element with a child which may appear 0 or more times </li></ul></ul><ul><ul><li><!ELEMENT Element-Name ( child ) * > </li></ul></ul><ul><li>Declaring Attributes in a DTD as follows: </li></ul><ul><li><!ATTLIST target-element attr-name type default > </li></ul><ul><ul><li>The type specifies what type of data that attribute contains. </li></ul></ul><ul><ul><ul><li>Legal types are : CDATA </li></ul></ul></ul><ul><ul><li>The default specifies whether the item is required or not. </li></ul></ul><ul><ul><ul><li>Possible values for default are: #REQUIRED, #IMPLIED </li></ul></ul></ul>
    29. 29. The “employee” DTD <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <!ELEMENT employees ((employee+))> <!ATTLIST employees xmlns CDATA #FIXED &quot;http://www.krestembedded.com/empinfo&quot;> <!ELEMENT employee ((name, qualification, designation))> <!ATTLIST employee gender (male | female) #REQUIRED> <!ELEMENT name ((first, last, nick?))> <!ELEMENT first (#PCDATA)> <!ELEMENT last (#PCDATA)> <!ELEMENT nick (#PCDATA)> <!ELEMENT qualification (#PCDATA)> <!ELEMENT designation (#PCDATA)>
    30. 30. DTD’s are Limited <ul><li>The problem with DTD’s are: </li></ul><ul><ul><li>DTDs express only relationships and data typing intended by ISO 8879 </li></ul></ul><ul><ul><li>DTD’s do not easily express data types or conceptual relationships such as those found in RDBMS. </li></ul></ul><ul><ul><li>DTDs are specifications in a syntax unique to SGML and SGML tools </li></ul></ul><ul><ul><li>DTD’s works well for textual data. </li></ul></ul><ul><ul><li>DTD’s use old SGML style definitions. </li></ul></ul><ul><ul><li>DTD’s are not written in XML. </li></ul></ul>
    31. 31. XML Schema <ul><li>An XML Schema is a description of a type of XML document. The schema is typically expressed as constraints on the structure and content of document. </li></ul><ul><ul><li>An XML schema provides a superset of the capabilities found in DTD. </li></ul></ul><ul><ul><li>A schema used to defines the elements </li></ul></ul><ul><ul><li>It also defines structural information about the XML doc. </li></ul></ul><ul><ul><li>It also defines the sequence in which child elements can appear and the no of child elements. </li></ul></ul><ul><ul><li>It can define whether an element is empty or can include text as well as default values for attributes. </li></ul></ul><ul><ul><li>XML Data Schema provides one standard schema language for both text and relational data. </li></ul></ul><ul><ul><li>XML Schema uses XML syntax. </li></ul></ul>
    32. 32. Schema vs DTD <ul><li>XML Schema definition language (XSD) has become the mainstream language for describing XML documents. </li></ul><ul><li>XML schema an improvement over DTDs that allows the author to specify data types, default value, maximum and minimum values , enumerations and other types. </li></ul><ul><li>The Schema and DTD both provide a method for specifying the structure of an XML element, whereas the both allow for element definitions, only schemas allow you to specify the type information. </li></ul><ul><li>XML Schema supports reusable types and allow you to create new types using inheritance. </li></ul><ul><li>XML Schema allows you to group elements to control the recurrence of elements and attributes. </li></ul>
    33. 33. XML Schema Definition Language (XSD) <ul><li>The Schema definition must have a root xsd:schema element. There are a variety of elements that may be nested within xsd:schema including, but not limited to: </li></ul><ul><ul><li>xsd:element </li></ul></ul><ul><ul><li>xsd:attribute </li></ul></ul><ul><ul><li>xsd:complextType </li></ul></ul><ul><li>These are approximately 44 ( int, string, long, etc., ) simple data types defined in the XSD. </li></ul><ul><ul><li>Also possible to define custom simple types. </li></ul></ul><ul><li>XML Schema provides </li></ul><ul><ul><li>Enhanced ability to validate data. ( Element structure, Attribute values, Element content, etc., ). </li></ul></ul><ul><ul><li>Default values for elements. </li></ul></ul><ul><ul><li>Uniqueness as well as Key constraints. </li></ul></ul><ul><ul><li>Pattern matching. </li></ul></ul>
    34. 34. Schema Representation <ul><li>Within XSD file, you can derive complex types from the existing complex types also. </li></ul><ul><li><xsd:schema xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; </li></ul><ul><li>xmlns:tns=&quot;http://example.org/person&quot;> </li></ul><ul><li><xsd:complexType name=&quot; Person &quot;> </li></ul><ul><li><xsd:sequence> </li></ul><ul><li><xsd:element name=&quot;name&quot; type=&quot;xsd:string&quot;/> </li></ul><ul><li><xsd:element name=&quot;age&quot; type=&quot;xsd:byte &quot; minOccurs=&quot;0&quot;/> </li></ul><ul><li><xsd:element name=&quot;phone&quot; type=&quot;xsd:string“ </li></ul><ul><li>minOccurs=&quot;1“ maxOccurs=&quot;5&quot;/> </li></ul><ul><li></xsd:sequence> </li></ul><ul><li><xsd:attribute name=&quot;id&quot; type=&quot;xsd:string &quot;/> </li></ul><ul><li></xsd:complexType> </li></ul><ul><li><xsd:element name=“employee&quot; type=&quot;tns:Person&quot;/> </li></ul><ul><li></xsd:schema> </li></ul>
    35. 35. Pattern Definition in Schema <ul><li>Within your schema if you want to specify any element should present within specified pattern you can use <xsd:pattern …> . </li></ul><ul><ul><li>Suppose if you want to the phone element should be present in xxx-xxx-xxxx format then you can define as follow: </li></ul></ul><ul><li><xsd:simpleType name=&quot; Phone &quot;> </li></ul><ul><li>< xsd:restriction base=&quot;xsd:string&quot;> </li></ul><ul><li><xsd:pattern value=&quot; d{3}-d{3}-d{4} &quot;/> </li></ul><ul><li>< /xsd:restriction > </li></ul><ul><li></xsd:simpleType> </li></ul><ul><li>XML Schema defines a set of type characteristics, or facets, which can be used to restrict certain aspects of the base type. </li></ul><ul><ul><li>There are total 12 facets ( Eg: minInclusive, maxInclusive ). </li></ul></ul><ul><ul><li>Each facet makes it possible to restrict the value space of the base type in a different way. </li></ul></ul>
    36. 36. Schema for Employees <?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?> <xs:schema targetNamespace=&quot;http://www.krestembedded.com/empinfo&quot; xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot;> <xs:element name=&quot;employees&quot;> <xs:complexType> <xs:sequence> <xs:element maxOccurs=&quot;100&quot; name=&quot;employee&quot;> <xs:complexType> <xs:sequence> <xs:element name=&quot;name&quot;> <xs:complexType> <xs:sequence> <xs:element name=&quot;first&quot; type=&quot;xs:string&quot; /> <xs:element name=&quot;last&quot; type=&quot;xs:string&quot; /> <xs:element minOccurs=&quot;0&quot; name=&quot;nicK&quot; type=&quot;xs:string&quot; />
    37. 37. Schema for Employees </xs:sequence> </xs:complexType> </xs:element> <xs:element name=&quot;qualification&quot; type=&quot;xs:string&quot; /> <xs:element name=&quot;designation&quot; type=&quot;xs:string&quot; /> </xs:sequence> <xs:attribute name=&quot;gender&quot; type=&quot;xs:string&quot; use=&quot;required&quot; /> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
    38. 38. Parsing XML <ul><li>Two popular types of XML processing exists: </li></ul><ul><ul><li>DOM ( Document Object Model ) </li></ul></ul><ul><ul><li>SAX ( Simple API for XML ) </li></ul></ul><ul><li>The key differences between these two processing's are: </li></ul><ul><ul><li>DOM loads the entire document into in-memory data structure. ( In case of SAX it doesn’t required ). </li></ul></ul><ul><ul><li>SAX is a simple and straightforward, event based API for parsing XML documents. </li></ul></ul><ul><ul><li>In case of SAX iterates over the XML document one piece at a time in a forward-only and read-only fashion. </li></ul></ul><ul><ul><li>SAX allows the developers to take advantage of event-driven XML parsing. </li></ul></ul><ul><ul><li>Both SAX and DOM provide the client application access to XML processing instructions. </li></ul></ul><ul><ul><li>The DOM is intended to be OS and language neutral. </li></ul></ul>
    39. 39. DOM <ul><li>The DOM is W3C defined standard for accessing documents like XML & HTML. </li></ul><ul><ul><li>DOM is platform and language neutral. </li></ul></ul><ul><ul><li>The DOM is separated into 3 different parts: </li></ul></ul><ul><ul><ul><li>Core DOM </li></ul></ul></ul><ul><ul><ul><li>XML DOM </li></ul></ul></ul><ul><ul><ul><li>HTML DOM </li></ul></ul></ul><ul><ul><li>The DOM defines the objects and properties of all document elements and the methods ( interfaces ) to access them. </li></ul></ul><ul><ul><li>The XML DOM is a standard object model for XML and a standard programming interface for XML. ( W3C Standard ). </li></ul></ul><ul><ul><li>With XML DOM interfaces you can get, change, add or delete XML elements. </li></ul></ul><ul><ul><li>According to DOM everything in XML document is a node. </li></ul></ul>
    40. 40. DOM <ul><li>According to DOM everything in XML document is a node. </li></ul><ul><ul><li>The entire document is a document node . </li></ul></ul><ul><ul><li>Every XML element is an element node . </li></ul></ul><ul><ul><li>The text in the XML elements are text nodes . </li></ul></ul><ul><ul><li>Every attribute is an attribute node . </li></ul></ul><ul><ul><li>Comments are comment nodes . </li></ul></ul><ul><li>A common error in DOM processing is to expect an element node to contain text, however the text of an element node is stored in a text node. </li></ul><ul><ul><li><year>2005</year> , </li></ul></ul><ul><ul><li>The element node <year>, holds a text node with the value &quot; 2005 &quot;. So the &quot;2005&quot; is not the value of the <year> element !. </li></ul></ul><ul><li>Most browsers have a build-in XML parser. An XML parser reads XML and converts into an XML DOM object that can be accessed by JavaScript. </li></ul>
    41. 41. XML Elements and Relations
    42. 42. XML Elements and Relations
    43. 43. SAX <ul><li>SAX stands for Simple API for XML . SAX provides a mechanism for reading data from an XML document. ( Alternative to DOM ). </li></ul><ul><li>SAX is a callback implementation. It provides event driven API. The SAX events includes: </li></ul><ul><ul><li>XML Text nodes </li></ul></ul><ul><ul><li>XML Element nodes </li></ul></ul><ul><ul><li>XML Processing Instructions </li></ul></ul><ul><ul><li>XML Comments. </li></ul></ul><ul><ul><li>Events are fired when each of these XML features are encountered, and again when the end of them is encountered. </li></ul></ul><ul><ul><li>XML attributes are provided as part of the data passed to element events. </li></ul></ul><ul><li>The quantity of the memory by SAX parser is much smaller then DOM parser. </li></ul><ul><li>Because of the event-driven nature of SAX, processing documents can often be faster than DOM-style parsers. </li></ul><ul><li>SAX also have some draw backs. Certain validation requires full document to be loaded. </li></ul>
    44. 44. Classes in .NET <ul><li>The following are important classes defined in .NET to work with XML documents: </li></ul><ul><ul><li>XmlReader & XmlWriter ( abstract classes ) </li></ul></ul><ul><ul><li>XmlTextReader & XmlTextWriter </li></ul></ul><ul><ul><li>XmlValidatingReader </li></ul></ul><ul><ul><li>XmlNodeReader </li></ul></ul><ul><ul><li>XmlDocument </li></ul></ul><ul><ul><li>XPathDocument </li></ul></ul><ul><ul><li>XslTransform </li></ul></ul><ul><ul><li>XmlSchema </li></ul></ul><ul><ul><li>XPathNavigator </li></ul></ul><ul><ul><li>XmlCsvReader </li></ul></ul>
    45. 45. XML Query Languages
    46. 46. XML Query Languages <ul><li>At present XML has the following three types of Query languages: </li></ul><ul><ul><li>XPath </li></ul></ul><ul><ul><li>XQuery </li></ul></ul><ul><ul><li>XSLT </li></ul></ul><ul><li>XML support for Microsoft SQL server are: </li></ul><ul><ul><li>In MS SQL Server 2000 with the FOR XML and OPENXML T-SQL keywords. </li></ul></ul><ul><ul><li>In MS SQL Server 2005 introduced xml data type that supports XSD schema validation and XQuery based operations and XML indexing . </li></ul></ul><ul><ul><li>In 2005, FOR XML feature was enhanced. </li></ul></ul><ul><ul><li>In 2008 enhancements includes, </li></ul></ul><ul><ul><ul><li>Improved Schema validation, </li></ul></ul></ul><ul><ul><ul><li>Enhancement to XQuery support, </li></ul></ul></ul><ul><ul><ul><li>Enhancements in XML Data Manipulation Language ( DML ). </li></ul></ul></ul>
    47. 47. XML Query Languages <ul><li>From SQL Server 2005 supports XML as a data type . So it allows you to combine T-SQL Queries and XQuery expressions to search within XML data. </li></ul><ul><ul><li>An XML data type can be used as a variable, a parameter or a return value from a UDF. </li></ul></ul><ul><ul><li>With Office 2003, Word & Excel documents as XML. </li></ul></ul><ul><ul><li>Example of combining T-SQL query and XQuery: </li></ul></ul><ul><ul><li>Now T-SQL statement with XQuery is: </li></ul></ul><ul><ul><li>SELECT [id], [Number], [info]. query (‘ Exam/Course ’) As Course FROM [Exams] </li></ul></ul><ul><ul><li>XQuery is allowed to query data. Microsoft extends this XQuery has named XML DML ( Data Modification Language ) to manipulate data. </li></ul></ul><ul><ul><li>The following keywords of XML DML are: insert, delete & replace value of. </li></ul></ul>ID (int) Number (NCHAR(10)) Info(XML) 1 123456 XML Data 2
    48. 48. XPath <ul><li>XPath is a language for addressing parts of an XML document. </li></ul><ul><li>The most basic construct in XPath is the expression . </li></ul><ul><li>Using XPath expressions, developers can easily identify nodes in an XML document. </li></ul><ul><li>The following are XPath expressions: </li></ul><ul><ul><li>match=“/” the root element </li></ul></ul><ul><ul><li>Select=“/author/surname” select the surname element which is child of the author element. </li></ul></ul><ul><ul><li>Select=“@date” select the elements with the attribute “date” </li></ul></ul><ul><ul><li>Select=“./fname” select fname children of the current node. </li></ul></ul>
    49. 49. XPath <ul><li>XPath 2.0 supports 19 primitive data types plus some more derived data types . </li></ul><ul><li>Within XPath expressions you can use comparison operators such as ( =, <, > and <= , etc., ). </li></ul><ul><li>In addition XPath 2.0 also supports some string processing functionalities such as upper-case, starts-with , concat , etc., </li></ul><ul><li>XPath also supports for expression as well as if expression. </li></ul><ul><li>An XPath expression can contain location paths, function calls, variable references, unions of sets, comparisons, mathematical operations, and so on. </li></ul>
    50. 50. XPath Example <ul><li>Form the Employees XML document check whether is an employee element exists whose first name is ‘vishwa’. </li></ul><ul><li>/employees/employee/name/first='Vishwa‘ // return boolean </li></ul><ul><li>Similarly to find the nick name for an employee whose first name is ‘Vishwa’ </li></ul><ul><li>/employees/employee/name[first='Vishwa']/nick </li></ul><ul><li>To find the gender for an employee whose designation is ‘Project Associate’. </li></ul><ul><li>/employees/employee[designation='Project Associate']/@gender </li></ul>
    51. 51. XPath Example <ul><li>Let us assume the XML document to represent cars as follow: </li></ul><ul><ul><li><?xml version='1.0'?> </li></ul></ul><ul><ul><li><cars xmlns='urn:schemas-develop-com:cars'> </li></ul></ul><ul><ul><li><car make='BMW'> </li></ul></ul><ul><ul><li><model>323i</model> </li></ul></ul><ul><ul><li><year>2000</year> </li></ul></ul><ul><ul><li><price>26,990</price> </li></ul></ul><ul><ul><li></car> </li></ul></ul><ul><ul><li></cars> </li></ul></ul><ul><ul><li>The following expression returns the car model </li></ul></ul><ul><ul><li>/cars/car/model // returns ‘323i’ </li></ul></ul><ul><ul><li>The following expressions yields Boolean value </li></ul></ul><ul><ul><li>starts-with(model, '32') // returns true </li></ul></ul><ul><ul><li>car/price < 27,000 // returns false </li></ul></ul><ul><ul><li>The following expression concatenation the make and model </li></ul></ul><ul><ul><li>concat(car/make, car/model) </li></ul></ul>
    52. 52. XSLT <ul><li>XSLT strands for Extensible Stylesheet Language Transformation </li></ul><ul><li>XSLT can be used to transform </li></ul><ul><ul><li>XML to XML ( One format to another format ) </li></ul></ul><ul><ul><li>XML to Non XML ( Eg: HTML, Text, Pdf, etc., ) </li></ul></ul><ul><ul><li>XML to FO ( XML to Formatting Objects ) </li></ul></ul><ul><li>XSLT uses the XPath language for identifying the appropriate data in the source tree. </li></ul><ul><li><xsl:template match = XPath Expression > </li></ul><ul><li><xsl:apply-templates select = XPath Expression > </li></ul><ul><ul><li>XPath also provides range of functions that assist XSLT. </li></ul></ul><ul><li>Within the .NET Framework there is an XML Transform Control to convert XML document contents into different format. </li></ul><ul><li><asp:Xml ID=“ x &quot; runat=&quot;server&quot; DocumentSource =&quot; My .xml“ TransformSource =&quot; MyTrans .xslt“ /> </li></ul>
    53. 53. XSLT <ul><li>The XSLT document is an XML document so starts of XML PI. </li></ul><ul><li>The root element that declares the document to be an XSL style sheet is <xsl:stylesheet> or <xsl:transform> . </li></ul><ul><li>With the help of <?xml-stylesheet?> PI, you can reference stylesheet for your XML document. </li></ul><ul><li>An XSL style sheet consists of one or more set of rules that are called templates . </li></ul><ul><ul><li>A template contains rules to apply when a specified node is matched. The <xsl:template> element is used to build templates. </li></ul></ul><ul><ul><li>The match attribute is used to associate a template with an XML element. </li></ul></ul><ul><ul><li>The value for the match attribute is an XPath expression . </li></ul></ul>
    54. 54. XSLT Functions <ul><li>The below are some of the XSLT built-in commands. These functions ranged from string processing, date processing and loop operators etc., </li></ul><ul><ul><li><xsl:template match =“myElement” /> </li></ul></ul><ul><ul><li><xsl:value-of select =“myElement” /> </li></ul></ul><ul><ul><li><xsl:for-each select =“myElement” > … </xsl:for-each> </li></ul></ul><ul><ul><li><xsl:sort /> </li></ul></ul><ul><ul><li><xsl:if test=“cost &gt; 20.00”> …. </xsl:if> </li></ul></ul><ul><ul><li><xsl:choose > and <xsl:when > </li></ul></ul>
    55. 55. XSLT Example <ul><li>The below is an XML document and its transformation file. </li></ul><ul><li><?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> </li></ul><ul><li><menuitem xmlns:xsi= http://www.w3.org/2001/XMLSchema-instance > </li></ul><ul><li>< item>Hamburger</item> </li></ul><ul><li><item>French Fries</item> </li></ul><ul><li><item>Milk Shake</item> </li></ul><ul><li><cost>4.99</cost> </li></ul><ul><li></menuitem> </li></ul><ul><li>XSLT file for the above XML document is: </li></ul><ul><li><?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?> </li></ul><ul><li><xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; xmlns=&quot;http://www.w3.org/1999/xhtml&quot;> </li></ul><ul><li><xsl:template match=&quot;/item&quot;> </li></ul><ul><li><xsl:apply-templates /> </li></ul><ul><li></xsl:template> </li></ul><ul><li><xsl:template match=&quot;item&quot;> </li></ul><ul><li><xsl:value-of select=&quot;.&quot; /> <br /> </li></ul><ul><li></xsl:template> </li></ul><ul><li><xsl:template match=&quot;cost&quot; /> </li></ul><ul><li></xsl:stylesheet> </li></ul>
    56. 56. XQuery <ul><li>XQuery is based on existing XPath query language. </li></ul><ul><li>The XQuery language is to XML as the SQL language is to relational databases. </li></ul><ul><li>XQuery provides a distributed query mechanism across data sources that are exposed as XML and is set to become a universal query language for data integration. </li></ul><ul><ul><li>So you can use XML Query over SQL Server database. </li></ul></ul><ul><li>The following are the benefits of XQuery are: </li></ul><ul><ul><li>A greater expressiveness with an ability to perform complex query operations ( Eg: joins, ordering, sorting, etc., ). </li></ul></ul><ul><ul><li>A human-friendly, non-XML syntax. </li></ul></ul><ul><ul><li>Strong typing at both runtime and compile time. </li></ul></ul><ul><ul><li>A rich set of functions and operators to operate on the XML schema types. </li></ul></ul>
    57. 57. XQuery <ul><li>XQuery is a powerful and convenient language designed for processing XML data. </li></ul><ul><ul><li>XQuery not only used on files in XML format, but also other data including databases whose structure nested, named trees with attributes is similar to XML. </li></ul></ul><ul><li>The primitive data types in XQuery are same as XML Schema. Some of the data types used in XQuery are: </li></ul><ul><ul><li>Numbers & Boolean </li></ul></ul><ul><ul><li>Strings of Characters </li></ul></ul><ul><ul><li>Types to represent dates, times and duration. </li></ul></ul><ul><ul><li>A few XML Related types </li></ul></ul><ul><li>In addition to primitive types also supports derived types. The derived types are just variations or restrictions of other types. </li></ul><ul><li>The following are other data types to represent XML values: </li></ul><ul><ul><li>Element, attributes, namespace, text, comment, PI, & document(root) nodes. </li></ul></ul><ul><ul><li>These types are very similar to corresponding DOM classes. Such as Node, Element, and so on. </li></ul></ul>
    58. 58. XQuery Functions <ul><li>Various XQuery functions creates or returns nodes. Take note the function parameters and function results can be primitive values, nodes or sequences of either. </li></ul><ul><ul><li>document() : Returns the root node of specified XML file. </li></ul></ul><ul><ul><li>count() : Returns the number of values in the sequence. </li></ul></ul><ul><ul><li>children() : Returns the sequence of child nodes. </li></ul></ul><ul><ul><li>sortby() : To sort a sequence. </li></ul></ul><ul><ul><li>max() : The biggest element in the given element. </li></ul></ul><ul><ul><li>contains() : Is given element contains specified word or etc., </li></ul></ul>
    59. 59. XQuery User Defined Functions <ul><li>In addition to predefined functions, in XQuery you can also define your own utility function. </li></ul><ul><ul><li>Below function returns all the descendent nodes of argument: </li></ul></ul><ul><ul><li>define function descendant-or-self ($x) { </li></ul></ul><ul><ul><li>$x, </li></ul></ul><ul><ul><li>for $y in children ($x) </li></ul></ul><ul><ul><li>return descendant-or-self ($y) </li></ul></ul><ul><ul><li>} </li></ul></ul><ul><ul><li>By invoking the above function for the given node as below: descendant-or-self(<a>X<b>Y</b></a>) </li></ul></ul><ul><ul><li>Evaluates to the sequence: </li></ul></ul><ul><ul><li><a>X<b>Y</b></a>; &quot;X&quot;; <b>Y</b>; &quot;Y&quot; </li></ul></ul>
    60. 60. XQuery Expressions <ul><li>XQuery borrows path expressions from XPath . </li></ul><ul><ul><li>XQuery can be viewed as generalization of XPath . </li></ul></ul><ul><ul><li>All XPath expressions are also XQuery expressions. </li></ul></ul><ul><ul><li>The following XQuery expression retrieves the <chapter> sub elements from the <book> main element from books.xml file. </li></ul></ul><ul><ul><li> let $book := document(&quot;books.xml&quot;)/book </li></ul></ul><ul><ul><li> return $book/chapter </li></ul></ul><ul><ul><li>The below code retrieves the titles from each chapter from the books.xml file. </li></ul></ul><ul><ul><li><html> { </li></ul></ul><ul><ul><li> let $book := document(&quot;mybook.xml&quot;)/book </li></ul></ul><ul><ul><li> for $ch in $book/chapter </li></ul></ul><ul><ul><li>return <h2>{$ch/title)</h2> </li></ul></ul><ul><ul><li>}</html> </li></ul></ul>
    61. 61. XQuery Expressions <ul><li>The below is a SQL query and the corresponding XQuery: </li></ul><ul><ul><li>The below query is a join of two tables named Customers & Orders. </li></ul></ul><ul><ul><li>select customers.name from customers, orders where customers.cust_id=orders.cust_id and orders.part_id=&quot;xx&quot; </li></ul></ul><ul><ul><li>For the above SQL query expression corresponding XQuery is: </li></ul></ul><ul><ul><li>for $c in customers </li></ul></ul><ul><ul><li>for $o in orders </li></ul></ul><ul><ul><li>where $c.cust_id=$o.cust_id and $o.part_id=&quot;xx“ </li></ul></ul><ul><ul><li>return $c.name </li></ul></ul><ul><li>The below is another example of XQuery: </li></ul><ul><li>for $seller in document(&quot;users.xml&quot;) </li></ul><ul><li> return for $item in document(&quot;items.xml&quot;)//item_tuple </li></ul><ul><li> return if $seller/userid = $item/offered_by </li></ul><ul><li> then if $seller/name = &quot;Tom Jones&quot; then $item </li></ul><ul><li> else () </li></ul><ul><li> else () </li></ul>
    62. 62. XQuery Expressions <ul><li>Take note, in XQuery every thing is an expression which evaluates to a value. </li></ul><ul><ul><li>An XQuery program or script is just an expression together with some other optional functions and other definitions. </li></ul></ul><ul><ul><li>So 3+4 is a valid XQuery expression. //Evaluates 7 </li></ul></ul><ul><ul><li>The below is a query expression which evaluates a string. </li></ul></ul><ul><ul><li>if (3 < 4) then &quot;yes!&quot; else &quot;no!&quot; </li></ul></ul><ul><ul><li>In XQuery you can define local variables with ‘let’ statement. </li></ul></ul><ul><ul><li>let $x := 5 let $y := 6 return 10*$x+$y //Evaluates 56 </li></ul></ul><ul><ul><li>The primitive data types in XQuery is same as XML Schema </li></ul></ul><ul><li>adsfasf </li></ul>
    63. 63. XQuery Expressions <ul><li>XQuery supports the following different types of expressions: </li></ul><ul><ul><li>Path expressions : ( Based on syntax of XPath ) </li></ul></ul><ul><ul><li>/doc/chapter[5]/section[2] </li></ul></ul><ul><ul><li>Element constructors : Consists of start and end tags, enclosing an optional list of expressions. </li></ul></ul><ul><ul><li><emp empid = {$id}> {$name} {$job} </emp> </li></ul></ul><ul><ul><li>FLWOR expressions : ( For and Let expressions ) </li></ul></ul><ul><ul><li>FOR $b IN document(“myBooks.xml&quot;)//book </li></ul></ul><ul><ul><li>WHERE $b/publisher = &quot;Morgan Kaufmann&quot; AND $b/year = &quot;1998&quot; </li></ul></ul><ul><ul><li>RETURN $b/title </li></ul></ul><ul><ul><li>Expressions involving operators and functions </li></ul></ul><ul><ul><li>Conditional expressions (If, then else, etc.) </li></ul></ul><ul><ul><li>Quantified expressions </li></ul></ul><ul><ul><li>List constructors </li></ul></ul><ul><ul><li>Expressions that test or modify data types. </li></ul></ul>
    64. 64. XQuery Operators & Functions <ul><li>The following are different types of operator </li></ul><ul><ul><li>Infix and prefix operators </li></ul></ul><ul><ul><li>Parenthesized expressions </li></ul></ul><ul><ul><li>Arithmetic and logical operators </li></ul></ul><ul><ul><li>Sequence operators UNION, INTERSECT and EXCEPT </li></ul></ul><ul><ul><li>Functions can be defined in XQuery </li></ul></ul><ul><li>The function will find the maximum depth of the xml document. </li></ul><ul><li>DEFINE FUNCTION depth($e AS ELEMENT) AS xsd:integer </li></ul><ul><li>{ </li></ul><ul><li>IF empty($e/*) THEN 1 </li></ul><ul><li>ELSE max(FOR $c in $e/* RETURN depth($c)) + 1 </li></ul><ul><li>} </li></ul><ul><li>depth(document(&quot;partlist.xml&quot;)) </li></ul>
    65. 65. XQuery Conditional Expression <ul><li>IF THEN ELSE construct </li></ul><ul><li>Make a list of holdings. For journals, include the editor, and for all other holdings, include the author. </li></ul><ul><li>FOR $h IN //holding </li></ul><ul><li>RETURN </li></ul><ul><li><holding> </li></ul><ul><li>{$h/title, </li></ul><ul><li>IF $h/@type = &quot;Journal&quot; THEN </li></ul><ul><li>$h/editor </li></ul><ul><li>ELSE </li></ul><ul><li>$h/author </li></ul><ul><li>} </li></ul><ul><li></holding> </li></ul>
    66. 66. XQuery Quantified Expressions <ul><li>Existential and Universal quantifiers </li></ul><ul><ul><li>Find titles of books in which both sailing and windsurfing are mentioned in the same paragraph. </li></ul></ul><ul><ul><ul><li>FOR $b IN //book </li></ul></ul></ul><ul><ul><li>WHERE SOME $para IN $b </li></ul></ul><ul><ul><li>contains($para, &quot;sailing&quot;) </li></ul></ul><ul><ul><li>AND contains($para, &quot;windsurfing&quot;) </li></ul></ul><ul><ul><li>RETURN $b/title </li></ul></ul><ul><ul><li>Find titles of books in which sailing is mentioned in every paragraph. </li></ul></ul><ul><ul><li>FOR $b IN //book </li></ul></ul><ul><ul><li>WHERE EVERY $p IN $b //Para SATISFIES </li></ul></ul><ul><ul><li>contains($p, &quot;sailing&quot;) </li></ul></ul><ul><ul><li>RETURN $b/title </li></ul></ul>
    67. 67. XQuery Sequence-related Operators <ul><li>A sequence may be constructed by enclosing zero or more expressions separated by commas. </li></ul><ul><li>For example: ($x, $y, $z) denotes a sequence containing three members represented by variables </li></ul><ul><li>The >> (precedes) and << (follows) Boolean. functions </li></ul><ul><li>() denotes an empty sequence. </li></ul>
    68. 68. XQuery Operators on Data Types <ul><li>INSTANCE OF returns True if its first operand is an instance of the type named in its second operand. </li></ul><ul><li>CAST is used to convert a value from one data type to another. </li></ul><ul><li>TREAT AS causes the query processor to treat an expression as though its data type were a subtype of its static type. </li></ul><ul><li>VALIDATE executes XML Schema validation. </li></ul>
    69. 69. XQuery Functions <ul><li>You can also create new node objects directly in the program. By using an element constructor expression </li></ul><ul><li><p>See <a href=&quot;index.html&quot;><i>here</i></a> for info.</p> </li></ul><ul><li>You can use {curly braces} to embed XQuery expression inside element constructors. </li></ul><ul><ul><li>let $i := 2 return </li></ul></ul><ul><ul><li>let $r := <em>Value </em> return </li></ul></ul><ul><ul><li><p>{$r} of 10*{$i} is {10*$i}.</p> it creates following node </li></ul></ul><ul><ul><li><p><em>Value </em> of 10*2 is 20.</p> </li></ul></ul><ul><li>The below evaluates the children’s of sequences: </li></ul><ul><ul><li>children( <p>This is <em>very</em> cool.</p> ) evaluates to </li></ul></ul><ul><ul><li>&quot;This is &quot;, <em>very</em>, &quot; cool.“ </li></ul></ul>
    70. 70. XQuery Sequences <ul><li>XQuery expressions actually evaluates to sequences of simple values. </li></ul><ul><ul><li>The comma operator can be used to concatenate two values or sequences. ( Eg: 3,4,5 ). </li></ul></ul><ul><ul><li>The simple values can be atomic values or node values. </li></ul></ul><ul><ul><li>The following is an example of sequences: </li></ul></ul><ul><ul><li>let $a := 3,4 </li></ul></ul><ul><ul><li>let $b := ($a, $a) </li></ul></ul><ul><ul><li>let $c := 99 </li></ul></ul><ul><ul><li>let $d := () </li></ul></ul><ul><ul><li>return ( count ($a), count($b), count($c), count($d)) </li></ul></ul><ul><ul><li>Evaluates to (2, 4, 1, 0) </li></ul></ul><ul><ul><li>Iterating over sequences: </li></ul></ul><ul><li>for $x in (1 to 3) return ($x,10+$x) </li></ul>
    71. 71. XML Linking Languages (XLink, XPointer)
    72. 72. XML Linking Language <ul><li>The XML Linking Language is called Xlink . </li></ul><ul><ul><li>In HTML <A> provides linking and URL’s is the pointing mechanism. ( In XML we can still use <A> links). </li></ul></ul><ul><li>XML Links have two options. Actuate specifies when the link occurs. </li></ul><ul><ul><li>USER: Here user clicks on link to activate. </li></ul></ul><ul><ul><li>AUTO: Here the link is automatically activated when displays. </li></ul></ul><ul><li>In addition SHOW option in XML Links. It specifies what will “show” when link is actuated. </li></ul><ul><ul><li>NEW: means a new window appears </li></ul></ul><ul><ul><li>REPLACE: a new window replaces the existing </li></ul></ul><ul><ul><li>EMBED: the link will be embedded, becoming part of it </li></ul></ul><ul><ul><li>Eg: <IMG> links are ACTUATE =AUTO and SHOW =EMBED </li></ul></ul>
    73. 73. XPointers <ul><li>X Pointers enable us to more precisely point to data within a Web resource. </li></ul><ul><ul><li>doc: document which contains the reference </li></ul></ul><ul><ul><li>from: beginning section to be linked </li></ul></ul><ul><ul><li>to: end of section to be linked </li></ul></ul>
    74. 74. XML Style Sheet Specification (CSS, XSLT, XSLT-FO)
    75. 75. XML Style Sheet Languages <ul><li>HTML is simple markup tags that Web browsers use to format text on a screen. </li></ul><ul><ul><li>The basic HTML tags are simple. </li></ul></ul><ul><ul><li>The HTML tag set identifies the basic document structure. It doesn’t specify much about styles. </li></ul></ul><ul><li>In 1996, CSS was emerged as a separate stylesheet for formatting HTML. </li></ul><ul><ul><li>At present CSS was used to style XML as well. </li></ul></ul><ul><li>In addition to CSS XSL ( Extensible Stylesheet Language ) was specially developed to specify styles for XML. </li></ul>
    76. 76. Splitting Content from Style <ul><li>So HTML page contains document structure, contents and Styles. Now you can split the content and styles. </li></ul><ul><ul><li>HTML + Style Sheet </li></ul></ul><ul><ul><li>Style sheets can be exchanged with users across authoring, browsing, and viewing tools. </li></ul></ul><ul><ul><li>The first Web Style language is CSS. </li></ul></ul><ul><ul><li>A CSS style sheet can be directly placed into an HTML 4.0 document. It is within <STYLE> in <HEAD> or it can be placed in a separate file. </li></ul></ul>Style/Content Coding Content Coding Style Coding
    77. 77. Simple Style Sheet Example <ul><li>The below is a sample CSS example: </li></ul><ul><li><STYLE type=&quot;text/css&quot;> </li></ul><ul><li>H1 {color: blue; font-size: 18pt; font-style: italic; </li></ul><ul><li>font-weight: bold;} </li></ul><ul><li>H2, H3, H4 {font-size: 12pt; font-style: normal; </li></ul><ul><li>font-weight: bold;} </li></ul><ul><li>H2 {color: black} </li></ul><ul><li>H3 {color: aqua} </li></ul><ul><li>H4 {color: fuchsia} </li></ul><ul><li></STYLE> </li></ul><ul><li>CSS uses a linear model to directly apply formatting to the source HTML or XML. </li></ul><ul><li>CSS Selectors are used to match styles to tags/attributes. </li></ul><ul><li>Only a single “flow area” is recognized for CSS styling. </li></ul><ul><li>CSS can be used along with XSL for rendering XML or XHTML. </li></ul><ul><li>The CSS2 style sheet is made up of number of rules. Each rule can be declaration. The declaration can be simple or complex. </li></ul>
    78. 78. Selectors <ul><li>The patterns which are used to apply styles in CSS are called selectors . </li></ul><ul><li>A selector may simply be an element name </li></ul><ul><li>Selectors also may be rich contextual patterns </li></ul><ul><li>Case-sensitivity of document language element names in selectors depends on the document language. </li></ul><ul><ul><li>HTML is not case sensitive </li></ul></ul><ul><ul><li>XML is case sensitive </li></ul></ul><ul><li>Different kinds of selectors: </li></ul><ul><ul><li>* Matches any element (universal selector) </li></ul></ul><ul><ul><li>E Matches any type E element. </li></ul></ul><ul><ul><li>E F Matches any E element that is a descendant of an F element. </li></ul></ul><ul><ul><li>E > F Matches any F element that is a child of an element E (child selector) </li></ul></ul>
    79. 79. CSS for XML <ul><li>The below is an XML document with stylesheet PI. </li></ul><ul><li><?xml version=“1.0”?> </li></ul><ul><li><?xml:stylesheet type=&quot;text/css&quot; href=”MyStyles.css&quot;?> </li></ul><ul><li><Presentation> </li></ul><ul><li><Title> XML and Related Technologies </Title> </li></ul><ul><li><Date> 14 th of Dec 2009 </Date> </li></ul><ul><li><Speaker>Ch.Vishwa Mohan</Speaker> </li></ul><ul><li></Presentation> </li></ul><ul><li>The below is style sheet for above document. </li></ul><ul><li><STYLE type=&quot;text/css&quot;> </li></ul><ul><li>Title {color: blue; font-size: 14pt; font-style: italic; </li></ul><ul><li>font-weight: bold;} </li></ul><ul><li>Date {color: red; font-size: 12pt; font-style: normal; } </li></ul><ul><li>Speaker {color: black; font-size: 12pt; font-style: normal; } </li></ul><ul><li></STYLE> </li></ul>
    80. 80. XSL <ul><li>XSL stands for Extensible Style Sheet Language . </li></ul><ul><li>XSL was designed to specify styles for XML. </li></ul><ul><li>Unlike CSS XSL is in XML syntax. </li></ul><ul><li>XSL has a 2-part processing model Transform / Format . </li></ul><ul><li>XSL also allows for multiple flow areas and support for online and print formatting. </li></ul><ul><li>XSLT ( XSL Transformation Language ) was the first module of XSL. </li></ul>
    81. 81. XSLT with Templates <?xml version=“1.0”?> <xsl:transform xmlns:xsl= “http://www.w3.org/1999/ XSL/ Transform” xsl:version=“1.0”> <xsl:template match=“/”> <xsl:text> <html><head><title>Article Summary</title></head> <body><h1>Article Summary by Author</h1></xsl:text> <xsl:apply-templates> <xsl:text></body></html></xsl:text> </xsl:template/> <xsl:template match=“author”> <xsl:text><p><b>Author:&nbsp;</b></xsl:text> <xsl:apply-templates select=”/author/surname”/> <xsl:text>,&nbsp;</xsl:text> <xsl:apply-templates select=:”/author/fname”/></p> </template>
    82. 82. Web Services & SOAP
    83. 83. From Objects to Services <ul><li>Polymorphism </li></ul><ul><li>Encapsulation </li></ul><ul><li>Subclassing </li></ul><ul><li>Message-based </li></ul><ul><li>Schema+Contract+Policy </li></ul><ul><li>Broad Interop </li></ul><ul><li>Location Transparent </li></ul><ul><li>Tight Coupling </li></ul><ul><li>Runtime Metadata </li></ul>Object-Oriented Service-Oriented Component-Oriented 1980s 2000s 1990s
    84. 84. What is SOA ? <ul><li>Service Oriented Architecture ( SOA ) is an approach to loosely coupled, protocol independent, standards-based distributed computing where software resources available on the network are considered as Services. </li></ul><ul><ul><li>SOA represents business functions as shared, reusable services. </li></ul></ul><ul><ul><li>SOA is not a product but an architectural paradigm . </li></ul></ul><ul><ul><li>The software component in a SOA are services based on standard protocol. </li></ul></ul><ul><ul><li>In SOA share schema and contract not class/database. </li></ul></ul><ul><ul><li>Service orientation provides the benefits of loosely coupled , message-oriented programming. </li></ul></ul><ul><li>Two critical characteristics are realized for SOA development are: </li></ul><ul><ul><li>Services are truly independent. </li></ul></ul><ul><ul><li>Services can be managed. </li></ul></ul>
    85. 85. Four Tenets of Service Orientation SERVICE ORIENTATION Compatibility Based On Policy Share Schema & Contract, Not Class Services Are Autonomous Boundaries Are Explicit
    86. 86. What is a Service ? <ul><li>Services are reusable units providing business functionality that are .., </li></ul><ul><ul><li>Clearly defined using standard policies, practice and framework. </li></ul></ul><ul><ul><li>Clearly described (usually with XML) </li></ul></ul><ul><ul><li>Autonomous </li></ul></ul><ul><ul><li>Abstraction of the underlying business logic and functionality. </li></ul></ul><ul><li>Here functionality exposed via structured messaging scheme. </li></ul><ul><li>Not XML Centric, Not HTTP centric. </li></ul><ul><ul><li>JSON, XML, SOAP, .., over TCP, HTTP, Named Pipes, MSMQ .., </li></ul></ul><ul><li>Messages sent and received. </li></ul><ul><li>Moves from client server model to a sender/receiver model. </li></ul><ul><li>Versioning independency. </li></ul>
    87. 87. Web Services <ul><li>The Web Service technology is simulated (inspired) by SOA. </li></ul><ul><ul><li>Take note Web Services and Services are not identical. </li></ul></ul><ul><li>In Web Services, XML used as “ wire format ” of RPC that is SOAP. </li></ul><ul><li>With Web Services following specifications are used: </li></ul><ul><ul><li>SOAP : XML based messaging protocol </li></ul></ul><ul><ul><li>UDDI: Yellow Pages for Web Services </li></ul></ul><ul><ul><li>WSDL: Web Service Description Language </li></ul></ul><ul><li>XML Web Services use SOAP as the primary transport and serialization protocol. </li></ul>
    88. 88. Web Services
    89. 89. SOAP <ul><li>SOAP is a XML based protocol for invoking Remote Procedure Calls, specially for Web Applications. </li></ul><ul><li>SOAP is a specification that defines the XML format for messages. </li></ul><ul><li>SOAP uses the following transports HTTP, MSMQ, TCP/IP, SMTP, etc.,. Basically SOAP doesn’t care what the transport is. </li></ul><ul><ul><li>It can be used combination of all the above transports. </li></ul></ul><ul><li>The most compelling feature of SOAP is that it has been implemented on many different hardware and software platforms. </li></ul>
    90. 90. SOAP Message <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?> < env:Envelope xmlns:env= &quot; http://www.w3.org/2002/12/soap-envelope &quot;> < env:Header > <n:alertcontrol xmlns:n=&quot;http://example.org/alert&quot;> <n:priority>1</n:priority> <n:expires>2012-12-12T00:00:00</n:expires> </n:alertcontrol> < /env:Header > < env:Body > <m:alert xmlns:m=&quot;http://example.org/alert&quot;> <m:msg>World is going to destroy ! </m:msg> </m:alert> < /env:Body > < /env:Envelope >
    91. 91. SOAP <ul><li>SOAP is a light weigh protocol for the exchange of information in a decentralized, distributed environment. It is an XML based protocol consists of three parts: </li></ul><ul><ul><li>An Envelope </li></ul></ul><ul><ul><li>Optional Header </li></ul></ul><ul><ul><li>Mandatory Body </li></ul></ul><ul><li>A SOAP message must not contain DTD. Similarly SOAP message must not contain processing instructions. </li></ul><ul><li>SOAP versioning is based on XML namespaces: </li></ul><ul><ul><li>SOAP 1.1 is identified by the http://schema.xmlsoap.org/soap/evelope namespace. </li></ul></ul><ul><ul><li>SOAP 1.2 is identified by the http://www.w3.org/2002/12/soap-envelop namespace. </li></ul></ul>
    92. 92. SOAP Envelope
    93. 93. Schema for SOAP Envelop <ul><li>The below schema states every SOAP envelope consists of optional header and mandatory body. </li></ul><ul><li><schema targetNamespace='urn:schemas-xmlsoap-org:soap.v1'> </li></ul><ul><li> <element name='Envelope'> </li></ul><ul><li> <type> </li></ul><ul><li><element name='Header' type='Header' minOccurs ='0' /> </li></ul><ul><li> <element name='Body' type='Body' minOccurs ='1' /> </li></ul><ul><li> </type> </li></ul><ul><li> </element> </li></ul><ul><li></schema> </li></ul>
    94. 94. SOAP Faults <ul><li>Exceptions thrown by an Web Services are sent back to the client in the form of SOAP Fault . </li></ul><ul><ul><li>A SOAP Fault is a <Fault> XML element within the SOAP message. </li></ul></ul><ul><ul><li>In ASP.NET these faults are converted to SoapException . </li></ul></ul><ul><li>The SOAP Fault element is used to carry error and/or status information within a SOAP message. </li></ul><ul><li>The SOAP Fault element defines the following sub elements: </li></ul><ul><ul><li>FaultCode </li></ul></ul><ul><ul><li>FaultString </li></ul></ul><ul><ul><li>FaultActor </li></ul></ul><ul><ul><li>Detail </li></ul></ul><ul><ul><li>Node </li></ul></ul><ul><ul><li>Role </li></ul></ul>
    95. 95. RSS
    96. 96. What is RSS <ul><li>RSS ( Really Simple Syndication ) is a family of web feed formats used to publish frequently updated works such as blog entries, news, headlines, audio and video in standardized format. </li></ul><ul><ul><li>An RSS document ( called as “feed”, ‘web feed” or “channel” ) includes full or summarized text, plus metadata such as publishing dates and authorship. </li></ul></ul><ul><ul><li>RSS feeds can be read by an RSS reader/feed reader , or aggregator , which can be web based, desktop based or mobile devices based. </li></ul></ul><ul><ul><li>The feeds are stored in XML format. </li></ul></ul><ul><ul><li>RSS formats are specified using XML , a generic specification for the creation of data formats. </li></ul></ul><ul><ul><li>Users can subscribe the feed by entering RSS URI, or by clicking on RSS icon in a web browser. </li></ul></ul>
    97. 97. Simple RSS Example <rss version=&quot;0.91&quot;>   <channel>      <title>XML.com</title>      <link>http://www.xml.com/</link>      <description>XML.com features services for XML community</description>      <language>en-us</language>     <item>        <title>Normalizing XML, Part 2</title>        <link>http://www.xml.com/pub/a/2002/12/04/normalizing.html</link>        <description> Relation normalization techniques to XML schema data modeling </description>     </item>     <item>        <title>The .NET Schema Object Model</title>        <link>http://www.xml.com/pub/a/2002/12/04/som.html</link>        <description>Describes in detail the use of the .NET Schema Object Model </description>     </item>   </channel> </rss>
    98. 98. Thank You ! You can reach me at : [email_address] 9490995632