xml bis4430 – unit 10. xml origins extensible markup language (xml) 1998 inspired by standard...
TRANSCRIPT
XML
BIS4430 – unit 10
XML Origins• Extensible Markup Language (XML) 1998
• Inspired by Standard Generalized Markup Language (SGML) and HTML.
• SGML defines how any given markup language can be formally specified
• HTML combines markup from several categories: Text Structuring Tags <H1>,
• Formatting Tags <B>, Linking <A>, <IMG>, and Data Input Tags <FORM>,<INPUT>
The key benefits of XML are:
· Readable by both humans and computers
· Facilitates the optimal structuring of data
· Free and/or inexpensive
· Widely available
· Easy to learn
· Supported by all major software vendors
XML vs HTML
<book><title>XML by Example</title><author>Sean McGrath</author><publisher>Prentice Hall, Inc.</publisher><publish_date>1999</publish_date><description>Building E-commerce Applications with XML</description></book>
<P>Book</P><P>Title: XML by Example</P><P>Author: Sean McGrath</P><P>Publisher: Prentice Hall, Inc.</P><P>Date Published: 1999</P><P>Description: Building E-commerce Applications </P>
Namespaces
• Namespaces resolve ambiguous element tag names, in order to associate correct elements in an XML document.
Namespaces
OrderInfo.xml
<Order_Info>
<Name>John Dow</Name>
<Address>19 Footlong Court</Address>
<City>Tallwood</City>
<Order>Cigars</Order>
<Date>31-12-02</Date>
</Order_Info>
BillingInfo.xml
<Billing_Info>
<Name>Angela Dow</Name>
<Payment>Visa</Payment>
<Number>12344</Number>
</Billing_Info>
Namespaces: Explicit<order: Order_Info xmlns:order =”http://www.mdx.ac.uk/~ariel/order”
xmlns:bill=“http://www.mdx.ac.uk/~ariel/bill” >
<order:Name >John Dow</order:Name>
< order:Address>19 Footlong Court</ order:Address>
< order:City>Tallwood</ order:City>
< order:Order>Cigars</ order:Order>
< order:Date>31-12-02</ order:Date>
<bill:Billing_Info >
< bill:Name >Angela Dow</bill:Name>
< bill:Payment>Visa</ bill:Payment>
< bill:Number>12344</ bill:Number>
</ bill:Billing_Info>
</ order:Order_Info>
XML Parsers
• XML processor is used to read XML documents and provide access to their content and structure
• It is assumed that an XML processor is doing its work on behalf of another module, called the application
XML Processing
Parsers• Nonvalidating – they simply verify if the
document adheres to rules of the XML syntax i.e. whether the XML document is well formed
• Validating – these parsers read in XML documents, check if they are well formed and verify their compliance with a specified XML schema or other validation set, i.e. they verify if the XML document is valid.
Content Access
Converting XML with XSLT
• XSL technologies allow to transform XML documents into various formats, such as PDF( Adobe Acrobat Reader), WML for wireless devices, and into HTML.
Retrieve the element content
• <xsl:value-of select="element name goes here"/>
• <xsl:if test= "boolean-expression-goes here">....</xsl:if>
<xsl:for-each select="element name goes here">
<!--processing instructions go here-->
</xsl:for-each>
Example
xsl:for-each select="student_list/student">
<b>Name: </b><xsl:value-of select="name"/><p/><b>ID: </b><xsl:value-of select="student_ID"/><p/><b>Studying : </b><xsl:value-of select="major"/>
</xsl:for-each>
Database Integration
• XML Database Mapping– More description on next slide
• Using Native XML Databases– Store XML data in XML document– Data is serialised
XML Database Mapping
• Associate elements in an XML document with the relational database fields.
• Query the database with SQL
• Convert results into an XML document
• Popular solution: Java & JDBC
XML Web Services
• Advantages of Web Services– Component independence
– Component based
– XML based interfaces