1 / 30

XML Extensible Markup Language

XML Extensible Markup Language. Kaj A. Jørgensen Aalborg University, Department of Production. Extensible Markup Language (XML). XML: looks like HTML but is more than HTML XML will not replace HTML – XML will complement HTML XML is extensible – users can define custom tags

star
Download Presentation

XML Extensible Markup Language

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XMLExtensible Markup Language Kaj A. Jørgensen Aalborg University, Department of Production XML – Extensible Markup Language

  2. Extensible Markup Language (XML) • XML: looks like HTML but is more than HTML • XML will not replace HTML – XML will complement HTML • XML is extensible – users can define custom tags • Data can be formatted for displaying with HTML • With XML, the meaning of data can be represented • XML is a metalanguage • a language for making new markup languages • XML is a simplification of Standard Generalized Markup Language (SGML) • Public software available for XML processing, e.g. i Java XML – Extensible Markup Language

  3. XML – Schema Definition and Style Definition XML Schema and Document Type Definition (DTD) • Separate files defining the structure of XML documents • Well-formed XML documents folows the rules of XML • Valid XML documents are well-formed and conforms with a schema file or DTD file Extensible Style Language (XSL) • Style sheets can be written in XSL • With XSL, XML documents can be formatted, e.g. in HTML • Different XSL style sheets can format XML documents differently XML – Extensible Markup Language

  4. HTML Example: <!-- The original html recipe --> <HTML> <HEAD><TITLE>Lime Jello Marshmallow Cottage Cheese Surprise</TITLE></HEAD> <BODY> <H3>Lime Jello Marshmallow Cottage Cheese Surprise</H3> <P>My grandma's favorite (may she rest in peace).</P> <H4>Ingredients</H4> <TABLE BORDER="1"> <TR BGCOLOR="#308030"> <TH>Qty</TH><TH>Units</TH><TH>Item</TH></TR> <TR><TD>1</TD><TD>box</TD><TD>lime gelatin</TD></TR> <TR><TD>500</TD><TD>g</TD><TD>multicolored tiny marshmallows</TD></TR> <TR><TD>500</TD><TD>ml</TD><TD>cottage cheese</TD></TR> <TR><TD></TD><TD>dash</TD><TD>Tabasco sauce (optional)</TD></TR> </TABLE> <H4>Instructions</H4> <OL> <LI>Prepare lime gelatin according to package instructions...</LI> <!-- and so on --> </BODY> </HTML> XML – Extensible Markup Language

  5. Hypertext Markup Language (HTML) Characteristics of HTML: • isn't extensible • is very display-centric • isn't directly reusable • only provides one 'view' of data • has little or no semantic structure HTML documents are presented with a browser • View the HTML document with the IE browser:example: Recipe.html XML – Extensible Markup Language

  6. XML tags – User Definable End tag: Empty tag: Start tag: XML – Extensible Markup Language

  7. <?xml version="1.0"?><Recipe>   <Name>Lime Jello Marshmallow Cottage Cheese Surprise</Name>   <Description> My grandma's favorite (may she rest in peace).</Description>   <Ingredients>      <Ingredient>         <Qty unit="box">1</Qty>         <Item>lime gelatin</Item>      </Ingredient>      <Ingredient>         <Qty unit="g">500</Qty>         <Item>multicolored tiny marshmallows</Item>      </Ingredient>      <Ingredient>         <Qty unit="ml">500</Qty>         <Item>Cottage cheese</Item>      </Ingredient>      <Ingredient>         <Qty unit="dash"/>         <Item optional="1">Tabasco sauce</Item>      </Ingredient>   </Ingredients>   <Instructions>      <Step>Prepare lime gelatin according to package instructions</Step>      <!-- And so on... -->   </Instructions></Recipe> XML – Extensible Markup Language

  8. Characteristics of XML • Some simple rules must be obeyed: • No unclosed tags • No overlapping tags – example:<Tomato>Let's call<Potato>the whole thing off</Tomato></Potato> • Attribute values must be enclosed in quotes • The text characters (<), (>), (") and (space) must be represented by 'character entities': (&lt;), (&gt;), (&quot;) and (&nbsp;) • The tag names define the meaning of data • Data + meaning = information • The hierarchy of tags define the information structure • The tags don't define how the document is displayed • Browsers can display XML documentes – example: Recipe.xml XML – Extensible Markup Language

  9. Document Type Definition (DTD) DTD example: <!ELEMENT Recipe (Name, Description?, Ingredients?, Instructions?)> <!ELEMENT Name (#PCDATA)> <!ELEMENT Description (#PCDATA)> <!ELEMENT Ingredients (Ingredient)*> <!ELEMENT Ingredient (Qty, Item)> <!ELEMENT Qty (#PCDATA)> <!ATTLIST Qty unit CDATA #REQUIRED> <!ELEMENT Item (#PCDATA)> <!ATTLIST Item optional CDATA "0" isVegetarian CDATA "true"> <!ELEMENT Instructions (Step)+> XML – Extensible Markup Language

  10. XML Schema example: <xsd:schemaxmlns:xsd="http://www.w3.org/1999/XMLSchema"> <xsd:element name="shipOrder" type="order"/> <xsd:complexType name="order"> <xsd:element name="shipTo" type="shipAddress"/> <xsd:element name="items" type="cdItems"/> </xsd:complexType> <xsd:complexType name="shipAddress"> <xsd:element name="name" type="xsd:string"/> <xsd:element name="street" type="xsd:string"/> <xsd:element name="address" type="xsd:string"/> <xsd:element name="country" type="xsd:string"/> </xsd:complexType> <xsd:complexType name="cdItems"> <xsd:element name="item" type="cdItem"/> </xsd:complexType> <xsd:complexType name="cdItem"> <xsd:element name="title" type="xsd:string"/> <xsd:element name="quantity" type="xsd:positiveInteger"/> <xsd:element name="price" type="xsd:decimal"/> </xsd:complexType> </xsd:schema> XML – Extensible Markup Language

  11. XML document conforming to the XML Schema: <?xml version="1.0"?> <shipOrder> <shipTo> <name>ToveSvendson</name> <street>Ragnhildvei 2</street> <address>4000 Stavanger</address> <country>Norway</country> </shipTo> <items> <item> <title>Empire Burlesque</title> <quantity>1</quantity> <price>10.90</price> </item> <item> <title>Hide your heart</title> <quantity>1</quantity> <price>9.90</price> </item> </items> </shipOrder> XML – Extensible Markup Language

  12. Hierarchcical View of XML Documents • Recipe example: Recipe Name Description Ingredients Ingredient Qty Item … Instructions Step … XML – Extensible Markup Language

  13. Xpath • Xpath is an expression language for • Express addresses/links • Navigation in XML documents • Selection of sets of XML elements • XPath is used in • XSL/XSLT • XLink, Xpointer and XQuery • Xpath expression syntax • axes::pathexpression[predicate] • Path expressions are either • Full path expressions or • Relative path expressions XML – Extensible Markup Language

  14. Xpath – Path Expressions • Full Path Expressions • Expresses a full path from the root node of a document • Examples: • /Recipe – selects all nodes • /Recipe/Name – selects the Name node • Relative Path Expressions • Expresses a path from current node • Examples: • //Description – selects the Description node • //Ingredient – selects all Ingredient nodes • //Item – selects Item node in first Ingredient node XML – Extensible Markup Language

  15. Xpath - Predicates • Predicates are expressions to filter selected node sets • Examples: • //Ingredient[2] – Second ingredient node • //Ingredient[last()] Last ingredient node • //Ingredient[3]/Qty/@unit – The unit attribute of Qty node • //Ingredient[Qty>200] Ingredient nodes with Qty>200 • //Ingredient[Qty>200]/Item Item nodes for which Qty>200 XML – Extensible Markup Language

  16. Xpath - Axes • Additional standard path expressions • Reserved words: • child • descendant • parent • ancestor • following • preceding • Attribute • Example with /Recipe/Ingredients as current node: • descendant::Item[@optional=“1”] XML – Extensible Markup Language

  17. Style Sheets in Extensible Style Language (XSL) • XSL style sheets • define how to format XML documents, e.g. HTML, RTF and SQL • input elements can be rearranged with style sheets • are defined by • Cascading Style Sheet language (CSS) • Extensible Style Language (XSL) • are also XML documents • contain special <xsl: ... > tags with pre-defined meaning • Each XSL style sheet contains a series of templates • Different XSL style sheets can transform XML documents for different applications and display equipment XML – Extensible Markup Language

  18. XSL Style Sheet: <?xml version="1.0"?> <xsl:stylesheetxmlns:xsl="http://www.w3.org/TR/WD-xsl"><xsl:template match="/Recipe">. . . </xsl:template><!-- Format ingredients --><xsl:template match="Ingredients">. . . </xsl:template><!-- Format instructions --><xsl:templatematch="Instructions">. . . </xsl:template><xsl:templatematch="Step">. . . </xsl:template><!-- ignore all not matched --> <xsl:template match="*" priority="-1"/> </xsl:stylesheet> XML – Extensible Markup Language

  19. XSL Style Sheet – individual templates: <xsl:template match="/Recipe"> <HTML>  <HEAD>  <TITLE>   <xsl:value-of select="Name"/>  </TITLE>  </HEAD>  <BODY>  <H3>  <xsl:value-of select="Name"/>  </H3>  <STRONG>  <xsl:value-of select="Description"/>  </STRONG>  <xsl:apply-templates/>  </BODY> </HTML></xsl:template> XML – Extensible Markup Language

  20. XSL Style Sheet – individual templates: <!-- Format ingredients --><xsl:template match="Ingredients"> <H4>Ingredients</H4> <TABLE BORDER="1"> <TR BGCOLOR="#308030"><TH>Qty</TH><TH>Units</TH><TH>Item</TH></TR> <xsl:for-each select="Ingredient"> <TR> <!-- handle empty Qty elements separately --> <xsl:if test='Qty[not(.="")]' >   <TD><xsl:value-of select="Qty"/></TD> </xsl:if> <xsl:if test='Qty[.=""]' >   <TD BGCOLOR="#404040"> </TD> </xsl:if><TD><xsl:value-ofselect="Qty/@unit"/></TD> <TD><xsl:value-ofselect="Item"/> <xsl:if test='Item/@optional="1"'>    <SPAN> -- <em><STRONG>optional</STRONG></em></SPAN></xsl:if></TD> </TR> </xsl:for-each> </TABLE></xsl:template> XML – Extensible Markup Language

  21. XSL Style Sheet – individual templates: <!-- Format instructions --><xsl:templatematch="Instructions"> <H4>Instructions</H4> <OL> <xsl:apply-templatesselect="Step"/> </OL></xsl:template><xsl:templatematch="Step"><LI><xsl:value-ofselect="."/></LI></xsl:template> XML – Extensible Markup Language

  22. Exchanging XML Documents XML – Extensible Markup Language

  23. Exchanging XML Documents, cont. XML – Extensible Markup Language

  24. Application Integration XML – Extensible Markup Language

  25. New Internet Technologies and Standards • XML is the basis for Web Services • expose and describe itself to other applications • can be located by other applications via directories • can be invoked by using standard protocols • XML based standards are currently available • Simple Object Access Protocol (SOAP) • Web Services Desription Language (WSDL) • Universal Desription, Discovery, and Integrat. (UDDI)a standard for new ways of publishing services • conform to the basic ”request” and ”response” functionality • supported by the World Wide Web Consortium (W3C) XML – Extensible Markup Language

  26. Internet Technologies and Standards XML – Extensible Markup Language

  27. Internet Technologies and Standards • Discovery and access to an Internet Service (example) • 1.a A Service Provider creates a service • 1.b The service is defined in WSDL • 1.c The service is published in a Service Directory • 2.a A Service Client queries the directory • 2.b The directory creates a reply • 2.c The reply contains a WSDL descriptor of the service • 3.a The Service Client invokes the service using the descriptor • 3.b A SOAP message is structured, built and sent • 3.c The Service Client receives and interprets the response XML – Extensible Markup Language

  28. Simple Object Access Protocol (SOAP) • Lightweight protocol for exchange of information • The protocol is XML based, simple and extensible • The SOAP standard consists of three parts • the SOAP envelope, what message and who should handle it • the SOAP encoding rules, serialisation mechanisms • the SOAP remote procedure call representation • SOAP envelope is an XML document with • SOAP header, optional • SOAP body, the message body, a set of body entries XML – Extensible Markup Language

  29. Web Services Desription Language (WSDL) • XML format for describing Internet services • Abstract description of network endpoints operating on messages containing either document-oriented or procedure-oriented information • Types, data type definitions, e.g. with XSD • Message, definition of the data being communicated • Port Type, set of supported operations by one or more endpoints • Binding, protocol and data format for a particular port type. • Port, single endpoint defined as binding and network address • Service, a collection of related endpoints XML – Extensible Markup Language

  30. Conclusion • XML – Extensible Markup Language • Meta language – users kan define specific languages, custom tags • The tag names define the meaning of data • XML Schema – definition of the structure of XML documents • Extensible Style Language (XSL) – document formatting • Style sheets are XML documents written in XSL • Product data models can be formulated in XML • Data exchange can be based on XML and XML Schema • International solutions: E-business XML, WEB services XML – Extensible Markup Language

More Related