e Xtensible Markup Language XML Objectives Introduction XML
e. Xtensible Markup Language (XML) • Objectives – – – – – Introduction XML overview through a practical example XML syntax Elements and attributes to mark up data XML parser -- A well-formed XML document Markup text vs. character data CDATA sections XML namespace XML applications XML related technologies
Introduction • e. Xtensible Markup Language (XML) – A description of XML from W 3 C school: XML is a cross-platform, software and hardware independent tool for transmitting information. – Technology for creating markup languages – Enables document authors to describe data of any type – Allows creating new tags • HTML limits document authors to fixed tag set • Example: <body>, <p>, <h 1>……etc. – A new tag, such as car type, compares to an HTML tag method <car. Type>4 -door</car. Type> vs. <h 2>4 -door</h 2>
Introduction (cont. ) How can XML be used? • XML can Separate Data from HTML – With XML, your data is stored outside your HTML. – with HTML, data is stored inside your HTML. With XML, data can be stored in separate XML files. – Concentrate on using HTML for data layout and display – XML data can also be stored inside HTML pages as "Data Islands". • XML is used to Exchange Data – With XML, data can be exchanged between incompatible systems. – Challenge: transmitting data in incompatible formats over the Internet – Converting the data to XML can greatly reduce this complexity and create data that can be read by many different types of applications.
Introduction (cont. ) How can XML be Used? • XML and Business To Business (B 2 B) – Financial information can be exchanged over the Internet. – Expect to see a lot about XML and B 2 B in the near future. – The main exchanging language for exchanging financial information between businesses over the Internet. – A lot of interesting B 2 B applications are under development. • XML can be used to Share Data – Plain text files can be used to share data. – XML in plain text format, a software- and hardware-independent. – Easier to create data for different applications – Easier to expand or upgrade a system to new operating systems, servers, applications, and new browsers.
Introduction (cont. ) How can XML be Used? • XML can be used to Store Data – Plain text files can be used to store data. – XML can also be used to store data in files or in databases. • XML can make your Data more Useful – Your data is available to more users. – Make your data available to other than only standard HTML browsers. – Other clients and applications can access your XML files as data sources, like they are accessing databases. – Data can be made available to all kinds of "reading machines" (agents), and it is easier to make your data available for blind people, or people with other disabilities.
Introduction (cont. ) How can XML be Used? • XML can be used to Create new Languages – XML is the mother of WAP and WML. – The Wireless Markup Language (WML), used to markup Internet applications for handheld devices like mobile phones, is written in XML. – Wireless Application Protocol (WAP) • If Developers have Sense (Sky is the limit!) – If “we” DO have sense, all future applications will exchange our data in XML – Word processors, spreadsheet applications and databases that can read each other's data in a pure text format, without any conversion utilities in between. – We can only pray that Microsoft and all the other software vendors will agree.
Introduction (cont. ) • An overview and structure diagram to present the idea of XML and its applications XML document XML Applications Presentation Of XML Doc. XSL, CSS, embedded in HTML… etc.
An XML Example • XML does not DO anything • XML was not designed to DO anything. • XML was created to structure, store and to send information. • The following example is a note to Class from Wei, <note> <to> TO: Class of Web Programming</to> <from> From : Wei</from> <heading> *** Reminder ***</heading> <body>Don't forget me this Friday!</body> </note> • The note has a header and a message body. It also has sender and receiver information. • But still, this XML document does not DO anything. It is just pure information wrapped in XML tags. Someone must write a piece of software to send, receive or display it.
But, How to present the data in the XML file? Using e. Xtensible Stylesheet Language (XSL) <? xml version = "1. 0"? > <xsl: stylesheet version = "1. 0" xmlns: xsl = "http: //www. w 3. org/1999/XSL/Transform"> <xsl: template match = "note"> <head> <title><xsl: value-of select = "heading"/></title> </head> <body bgcolor = "white"> <h 1><xsl: value-of select = "from"/></h 1> </br> <h 1><xsl: value-of select = "to"/></h 1> <h 2><xsl: value-of select = "heading"/></h 2> <p style = "font-size: 20 pt; color: #0000 ff">xsl: value-of select = "body"/></p> </body> XML </xsl: template> Presentation </xsl: stylesheet>
Present data in XML file: with CSS • With CSS (Cascading Style Sheets) you can define display information to an XML document • In the XML file: <? xml-stylesheet type="text/css" href=“example 1_2. css"? > • Same as normal CSS definition note { background-color: #ffffff; width: 100%; } CSS file XML Presentation
Present data in XML file: XML in Data. Island • IE 5. 0 or higher, XML can be embedded within HTML pages in Data Islands (http: //www. w 3. org/TR/2000/WD-DOM-Requirements 20001214/) • Unofficial <xml> tag, declare in the tag <body> <xml id="note" src="example 1_3. xml"></xml> • Data Islands can be bound to HTML elements <table>, <span>,<div> through attributes: “datasrc” & “datafld” , refers to the example XML Presentation
Introduction to XML Markup • XML document (intro. xml) – Marks up message as XML – Commonly stored in text files • Extension. xml – Must contain exactly one root element • Attempting to create more than one root element is erroneous • All other elements must be within this root element
1 2 3 4 5 6 7 8 <? xml version = "1. 0"? > Document begins with declaration that specifies XML version 1. 0 <!-- Fig. 5. 1 : intro. xml --> <!-- Simple introduction to XML markup --> <my. Message> <message>Welcome to XML!</message> </my. Message> Line numbers are not part of XML document. We include them for clarity. Comments Element message is child element of root element my. Message Outline Fig. 5. 1 Simple XML document containing a message. Line numbers are not part of XML document. We include them for clarity. Document begins with declaration that specifies XML version 1. 0 <root> Comments <child> Element message is child element of root element my. Message <subchild>. . . </subchild> </child> </root>
XML syntax • The syntax rules of XML are very simple and very strict. • The rules are very easy to learn, and. XML version & very easy Char. Encoding to use. (Latin-1/West root European) • element An example: Child elements <? xml version="1. 0" encoding="ISO-8859 -1"? > <note> <to>To: Class of Web Programming (II)</to> <from>From: Wei</from> <heading>*** Reminder ***</heading> <body>Don't forget me this Friday!</body> </note> Data content
XML Syntax (cont. ) • All XML elements – Consists of • Start tag: <message> • Content(may or may not) : Welcome to XML! • End tag : </message> – All elements must have corresponding end tag Example: <img src = “img. gif”> is correct in HTML, but not XML – XML requires end tag or forward slash (/) for termination <img src = “img. gif”></img> or <img src = “img. gif”/> is correct XML syntax
XML Syntax (cont. ) • XML tags are case sensitive – The tag <Letter> is different from the tag <letter> – Opening and closing tags must therefore be written with the same case: <Message>This is incorrect</message> <message>This is correct</message> • All XML elements must be properly nested – Improper nesting of tags makes no sense to XML • Incorrect: <x><y>hello</x></y> • Correct: <x><y>hello</y></x>
XML Syntax (cont. ) • Comments in XML – The syntax for writing comments in XML is similar to that of HTML. <!-- This is a comment --> • There is nothing special about XML – It is just plain text with the addition of some XML tags enclosed in angle brackets, like HTML • An software that can handle plain text can also handle XML. • In a simple text editor, the XML tags will be visible and will not be handled specially. • In an XML-aware application, however, the XML tags can be handled specially. i. e. Spy, . net • The tags may or may not be visible, or have a functional meaning, depending on the nature of the application.
Markup Elements • XML Elements are extensible – Authors are free to extend the elements without worrying the crash of document – Example: add 2 or 3 tags to the example 1_1. xml • XML Elements have relationships – Elements are related as parents and children Example: the content of a book: How I Play Golf Introduction to golf � What is golf � What are clubs Short Game � What is short game � Which club should be used
Markup Elements (cont. ) <book> <title>How I Play Golf</title> <prod id="33 -657" media="paper"></prod> <chapter>Introduction to golf Root element? <para>What is golf</para> child elements? <para>What are clubs</para> Parent element? </chapter> Sibling elements? <chapter>Short Game <para>What is short game</para> <para>Which club should be used</para> </chapter> </book>
Markup Elements (cont. ) • Element Content – Element content, mixed content, simple content, or empty content • Element Naming Rules – Names can contain letters, numbers, and other characters – Names must not start with a number or punctuation character – Names must not start with the letters xml (or XML or Xml. . ) – Names cannot contain spaces
Markup Elements (cont. ) • Element Naming Rules (cont. ) – Any name can be used, no words are reserved, but the idea is to make names descriptive – Element names can be as long as you like – Non-English letters like éòá are perfectly legal in XML element names, but watch out for problems if your software vendor doesn't support them – The ": " should not be used in element names because it is reserved to be used for something called namespaces – Avoid to use “-” and “. ”, these are normally used for specific purpose by software vendors book-title, book. title
Markup Element’s Attributes • XML elements can have attributes in the start tag <book isbn=“ 0 -13 -028417 -3”> • Attributes are used to provide additional information about elements • Values are enclosed in quotes: either single or double – Element car contains attribute doors, which has value “ 4” <car doors = “ 4”/>
Markup Element’s Attributes (cont. ) • Use of Elements vs. Attributes – Data can be stored in child elements or in attributes <person sex = “female”> <firstname>Anna</firstname> <lastname>Smith</lastname> </person> <sex>female</sex> <firstname>Anna</firstname> <lastname>Smith</lastname> </person>
Markup Element’s Attributes (cont. ) • Avoid using attributes? – attributes cannot contain multiple values (child elements can) – attributes are not easily expandable (for future changes) – attributes cannot describe structures (child elements can) – attributes are more difficult to manipulate by program code – attribute values are not easy to test against a Document Type Definition (DTD) - which is used to define the legal elements of an XML document
Markup Element’s Attributes (cont. ) • Processing instruction (PI) – The <xsl: processing-instruction> element writes a processing instruction to the output PI: <xsl: processing-instruction name="xml-stylesheet"> href="style. css" type="text/css" </xsl: processinginstruction> Result: <? xml-stylesheet href="style. css" type="text/css"? > – Passed to application using XML document – Provides application-specific document information – Delimited by <? and ? > – Refers to Ch. 12 e. Xtensible Stylsheet Language (XSL)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <? xml version = "1. 0"? > Processing instruction specifies stylesheet (discussed in Chapter 12) <!-- Fig. 5. 5 : usage. xml --> <!-- Usage of elements and attributes --> <? xml: stylesheet type = "text/xsl" href = "usage. xsl"? > Outline Fig. 5. 5 XML document that marks up information about a fictitious book. <book isbn = "999 -99999 -9 -X"> <title>Deitel& s XML Primer</title> Processing instruction Root element book contains child specifies stylesheet <author> elements title, author, <first. Name>Paul</first. Name> (discussed in Chapter 12) chapters and media <last. Name>Deitel</last. Name> </author> Root element book Element book contains child elements <chapters> attribute isbn, which has title, author, <preface num = "1" pages = "2">Welcome</preface> value of 999 -99999 -9 -X chapters and media <chapter num = "1" pages = "4">Easy XML</chapter> <chapter num = "2" pages = "2">XML Elements? </chapter> <appendix num = "1" pages = "9">Entities</appendix> </chapters> <media type = "CD"/> </book> Element book contains attribute isbn, which has value of 999 -9 -X Element chapters contains four child elements, each which contain two attributes
Fig. 5. 5 XML document that marks up information about a fictitious book.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 <? xml version = "1. 0"? > <!-- Fig. 5. 6: letter. xml --> <!-- Business letter formatted with XML --> <letter> <contact type = "from"> <name>Jane Doe</name> <address 1>Box 12345</address 1> <address 2>15 Any Ave. </address 2> <city>Othertown</city> <state>Otherstate</state> <zip>67890</zip> <phone>555 -4321</phone> <flag gender = "F"/> </contact> <contact type = "to"> <name>Jane Doe</name> <address 1>123 Main St. </address 1> <address 2></address 2> <city>Anytown</city> <state>Anystate</state> <zip>12345</zip> <phone>555 -1234</phone> <flag gender = "M"/> </contact> Outline Fig. 5. 6 XML document that marks up a letter.
30 <salutation>Dear Sir: </salutation> 31 32 <paragraph>It is our privilege to inform you about our new 33 database managed with <bold>XML</bold>. This new system 34 allows you to reduce the load on your inventory list 35 server by having the client machine perform the work of 36 sorting and filtering the data. </paragraph> 37 38 <paragraph>The data in an XML element is normalized, so 39 plain-text diagrams such as 40 /--- 41 | | 42 ---/ 43 will become gibberish. </paragraph> 44 45 <closing>Sincerely</closing> 46 <signature>Ms. Doe</signature> 47 48 </letter> Outline Fig. 5. 6 XML document that marks up a letter. (Part 2)
Fig. 5. 6 XML document that marks up a letter.
XML Validation • XML with correct syntax is Well Formed XML. • XML validated against a Document Type Definition (DTD is Valid XML) • A DTD defines the legal elements of an XML document • XML Schema is an XML based alternative to DTD • Errors will Stop you XML Parsing Error
XML Validation (cont. ) • XML Browser Support – XML in Mozilla Firefox 1. 0: supports the XML 1. 0 standard – XML in Netscape 6: Netscape 6 supports XML – XML in Internet Explorer 5. 0 : supports the XML 1. 0 standard
XML Validation (cont. ) • IE 5. 0 has the following XML support: – Viewing of XML documents – Full support for W 3 C DTD standards – XML embedded in HTML as Data Islands – Binding XML data to HTML elements – Transforming and displaying XML with XSL – Displaying XML with CSS – Access to the XML DOM
Parsers and Well-formed XML Documents • XML parser – To read and update - create and manipulate - an XML document, you need an XML parser – Processes XML document • Reads XML document • Checks syntax • Reports errors (if any) • Allows programmatic access to document’s contents • Example (by Javascript) var xml. Doc=new Active. XObject("Microsoft. XMLDOM") Create an XML document object XML Presentation
Parsers and Well-formed XML Documents (cont. ) • XML document syntax – Considered well formed if syntactically correct • Single root element • Each element has start tag and end tag • Tags properly nested • Attribute (discussed before) values in quotes • Proper capitalization – Case sensitive
Parsers and Well-formed XML Documents (cont. ) • XML parsers support – Document Object Model (DOM, heavy-weight API) • Builds tree structure containing document data in memory – Simple API for XML (SAX, light-weight API) • Generates events when tags, comments, etc. are encountered – (Events are notifications to the application) – More like event-driven
Parsing an XML Document with msxml • Load XML document into Internet Explorer 5. 0 – Document is parsed by msxml. (from Microsoft) – Places plus (+) or minus (-) signs next to container elements • Plus sign indicates that all child elements are hidden • Clicking plus sign expands container element – Displays children • Minus sign indicates that all child elements are visible • Clicking minus sign collapses container element – Hides children – Error generated, if document is not well formed Examples
XML document shown in IE 5.
Fig. 5. 3 Error message for a missing end tag. Error Message
Characters • Character set – Characters that may be represented in XML document • e. g. , ASCII character set – Letters of English alphabet – Digits (0 -9) – Punctuation characters, such as !, - and ?
White Space, Entity References and Built-in Entities • Whitespace characters – Spaces, tabs, line feeds and carriage returns • Significant (preserved by application) • Insignificant (not preserved by application) – Normalization » Whitespace collapsed into single whitespace character » Sometimes whitespace removed entirely <markup>This is character data</markup> after normalization, becomes <markup>This is character data</markup>
White Space, Entity References and Builtin Entities (cont. ) • XML-reserved characters – – – Ampersand (&) Left-angle bracket (<) Right-angle bracket (>) Apostrophe (’) Double quote (”) • Entity references – Allow to use XML-reserved characters • Begin with ampersand (&) and end with semicolon (; ) – Prevents from misinterpreting character data as markup
White Space, Entity References and Builtin Entities (cont. ) • Build-in entities – Ampersand (& ) < < – Left-angle bracket (< ) > > – Right-angle bracket (> ) & & ' ' " " – Apostrophe (' ) – Quotation mark (" ) • Mark up characters “<>&” in element message <message>< > & </message>
Character Set • XML documents may contain – Carriage Return (CR + LF) returns Line feeds (LF) – Unicode characters (Section 5. 5. 4) • Enables computers to process characters for several languages • Use editor that support the encoding • More about unicode specification, please visit: http: //www. unicode. org
Using Unicode in an XML Document • XML Unicode support – e. g. , Fig. 5. 4 displays Arabic words • Arabic characters – represented by entity references for Unicode characters
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 <? xml version = "1. 0"? > <!-- Fig. 5. 4 : lang. xml <!-- Demonstrating Unicode --> <!DOCTYPE welcome SYSTEM "lang. dtd"> Outline Document type definition (DTD) defines document structure and entities Fig. 5. 4 XML document that contains Arabic words <welcome> <from> <!-- Deitel and Associates --> د ا ي ت َ ل أ ن د <!-- entity --> &assoc; </from> <subject> <!-- Welcome to the world of Unicode --> أ ه ل ا ً ب ك م ف ي ِ ع ا ل م <!-- entity --> &text; </subject> </welcome> Document type definition (DTD) defines document structure and entities Root element welcome contains child elements from and subject Sequence of entity references for Unicode characters in Arabic Unicode characters alphabet in Arabic alphabet lang. dtd defines entities assoc and text
Fig. 5. 4 XML document that contains Arabic words. Show Example
Characters vs. Markup • XML must differentiate between – Markup text • Enclosed in angle brackets (< and >) – e. g, . <message> – Character data • Text between start tag and end tag – e. g. , Fig. 5. 1, line 7: Welcome to XML!
CDATA Sections • Parsing or not Parsing (CDATA section) • CDATA sections: <![CDATA[……………. ]]> – Everything inside a CDATA section is ignored by the parser – May contain text, reserved characters and whitespace • Reserved characters need not be replaced by entity references – A CDATA section cannot contain the string "]]>", nested CDATA sections are not allowed – Commonly used for scripting code (e. g. , Java. Script)
1 Outline <? xml version = "1. 0"? > 2 3 <!-- Fig. 5. 7 : cdata. xml --> 4 <!-- CDATA section containing C++ code --> Fig. 5. 7 Using a CDATA section. 5 6 <book title = "C++ How to Program" edition = "3"> 7 8 <sample> 9 // C++ comment 10 if ( this-> get. X() < 5 & value[ 0 ] != 3 ) 11 12 15 CDATA section cerr < this-> display. Error(); </sample> 13 14 Entity references required if not in CDATA section XML does not process <sample> <![CDATA[ XML does not process CDATA section Note the simplicity offered by CDATA section 16 17 // C++ comment 18 if ( this->get. X() < 5 && value[ 0 ] != 3 ) 19 cerr << this->display. Error(); 20 ]]> 21 </sample> 22 23 C++ How to Program by Deitel & Deitel 24 </book> Note the simplicity offered by CDATA section
Fig. 5. 7 Using a CDATA section
XML Namespaces • XML Namespaces provide a method to avoid element name conflicts • Naming collisions – Two different elements have same name <subject>Math</subject> <subject>Thrombosis</subject> • Solving Name Conflicts using a Prefix • Namespaces – Differentiate elements that have same name <school: subject>Math</school: subject> <medical: subject>Thrombosis</medical: subject> school and medical are namespace prefixes • Prepended to elements and attribute names • Tied to uniform resource identifier (URI) – Series of characters for differentiating names
XML Namespaces (cont. ) <h: table> <h: tr> <h: td>Apples</h: td> <h: td>Bananas</h: td> </h: tr> </h: table> <f: name>African Coffee Table</f: name> <f: width>80</f: width> <f: length>120</f: length> </f: table>
XML Namespaces (cont. ) • Uniform Resource Identifier (URI) – A string of characters which identifies an Internet Resource. – The most common URI is the Uniform Resource Locator (URL) which identifies an Internet domain address • Note that the address used to identify the namespace, is not used by the parser to look up information. • The only purpose is to give the namespace a unique name to be identified
XML Namespaces (cont. ) • Creating namespaces: – Use xmlns keyword xmlns: text = “urn: deitel: text. Info” xmlns: image = “urn: deitel: image. Info” • Creates two namespace prefixes text and image • urn: deitel: text. Info is URI for prefix text • urn: deitel: image. Info is URI for prefix image – Default namespaces • Child elements of this namespace do not need prefix xmlns = “urn: deitel: text. Info”
1 2 3 4 5 6 7 Element Outline directory <!-- Fig. 5. 8 : namespace. xml --> Fig. 5. 8 Listing for <!-- Namespaces --> contains two namespace. xml. namespace prefixes <directory xmlns: text = "urn: deitel: text. Info" Use prefix text to <? xml version = "1. 0"? > xmlns: image = "urn: deitel: image. Info"> 8 9 10 11 <text: filename = "book. xml"> <text: description> A book list</text: description> Use prefix text to describe elements file Apply prefix and description </text: file> 12 13 Element directory describe elements file contains two namespace and description prefixes <image: filename = "funny. jpg"> 14 <image: description> A funny picture</image: description> 15 <image: size width = "200" height = "100"/> 16 </image: file> 17 18 </directory> image to describe Apply prefix image to describe elements file, description and size
1 <? xml version = "1. 0"? > 2 3 <!-- Fig. 5. 9 : defaultnamespace. xml 4 <!-- Using Default Namespaces urn: deitel: t ext. Info is -->default namespace --> 5 6 <directory xmlns = "urn: deitel: text. Info" 7 xmlns: image = "urn: deitel: image. Info"> 8 9 10 11 <filename = "book. xml"> <description>A book list</description> </file> 12 13 <image: filename = "funny. jpg"> namespace Specify namespace <image: description>A funny picture</image: description> 15 <image: size width = "200" height = "100"/> </image: file> 17 18 </directory> Fig. 5. 9 Using default namespaces. Element urn: deitel: textfile is in Info is default namespace default Element file is in default namespace Specify 14 16 Outline
An XML Application • A small framework for an XML application 1. XML document 2. Load the document into a Data Island 3. Bind the Data Island to an HTML Table 4. Bind the Data Island to <span> or <div> elements 5. Add a Navigation Script to your XML
An XML Application (cont. ) • With a little creativity you can create a full application. • If you use what you have learned on this page, and a little imagination, you can easily develop this into a full application • Now, let’s see what we can do with those techniques we just learned? Demo
HW # 1 • P. 132 Exercises 5. 4,5. 5,5. 6 • Due day: Before next lecture (3/11) • Submit your homework# 1 to TAs • How to submit? Will be posted on the web page • http: //140. 116. 246. 95/Web%20 programing/Web. Pro gramming. htm
That’s it for today, Have a nice weekend!
An XML Application: 1. XML document • • First we start with a simple XML document. An original demonstration document, the CD catalog <? xml version="1. 0" encoding="ISO-8859 -1"? > <CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE>10. 90</PRICE> <YEAR>1985</YEAR> </CD>. . . more. .
An XML Application Load the document into a Data Island • A Data Island can be used to access the XML file. • To get your XML document "inside" an HTML page, add an XML Data Island to the page. <xml src="cd_catalog. xml" id="xmldso" async="false"> </xml> • The XML file "cd_catalog. xml" will be loaded into an "invisible" Data Island called "xmldso". • The async="false" attribute is added to the Data Island to make sure that all the XML data is loaded before any other HTML processing takes place.
An XML Application: Bind the Data Island to an HTML Table • An HTML table can be used to display the XML data. • To make your XML data visible on your HTML page, you must "bind" your XML Data Island to an HTML element. • To bind your XML data to an HTML table, add an attribute <table datasrc="#xmldso" …. > • Add data field attributes: <span datafld="TITLE" >
An XML Application: Bind the Data Island to an HTML Table (cont. ) <table datasrc="#xmldso" width="100%" border="1"> <thead> <th>Title</th> <th>Artist</th> <th>Year</th> </thead> <tr align="left"> <td><span datafld="TITLE"></span></td> <td><span datafld="ARTIST"></span></td> <td><span datafld="YEAR"></span></td> </tr> </table> Show
An XML Application: Bind the Data Island to <span> or <div> elements • <span> or <div> elements can be used to display XML data. • You don't have to use a table to display your XML data. • Data from a Data Island can be displayed anywhere on an HTML page by adding some <span> or <div> elements to your page. • Use the data source attribute to bind the elements to the Data Island, and the data field attribute to bind each element to an XML element, like this <span datasrc="#xmldso" datafld="TITLE"> <div datasrc="#xmldso" datafld="TITLE">
An XML Application: Bind the Data Island to <span> or <div> elements (cont. ) Title: <span datasrc="#xmldso" datafld="TITLE"></span> Artist: <span datasrc="#xmldso" datafld="ARTIST"></span> Year: <span datasrc="#xmldso" datafld="YEAR"></span> Title: <div datasrc="#xmldso" datafld="TITLE"></div> Artist: <div datasrc="#xmldso" datafld="ARTIST"></div> Year: <div datasrc="#xmldso" datafld="YEAR"></div> Show
An XML Application: Add a Navigation Script to your XML • Navigation has to be performed by a script. • Add navigation to the XML Data Island, create a script that calls the movenext() and moveprevious() methods of the Data Island <script type="text/javascript"> function movenext(){ x=xmldso. recordset if (x. absoluteposition < x. recordcount){ x. movenext() } } function moveprevious(){ x=xmldso. recordset if (x. absoluteposition > 1){ x. moveprevious() } } </script> Show
XML Related Technologies • XHTML - Extensible HTML – XHTML is the re-formulation of HTML 4. 01 in XML. XHTML 1. 0 is the latest version of HTML • CSS - Cascading Style Sheets – CSS style sheets can be added to XML documents to provide display information • XSL - Extensible Style Sheet Language – XSL consists of three parts: XML Document Transformation (renamed XSLT, see below), a pattern matching syntax (renamed XPath, see below), and a formatting object interpretation
XML Related Technologies (cont. ) • XSLT - XML Transformation – XSLT is far more powerful than CSS. It can be used to transform XML files into many different output formats • XPath - XML Pattern Matching – XPath is a language for addressing parts of an XML document. XPath was designed to be used by both XSLT and XPointer • XLink - XML Linking Language – The XML Linking Language (XLink) allows elements to be inserted into XML documents in order to create links between XML resources
XML Related Technologies (cont. ) • XPointer - XML Pointer Language – The XML Pointer Language (XPointer) supports addressing into the internal structures of XML documents, such as elements, attributes, and content • XQL - XML Query Language – The XML Query Language supports query facilities to extract data from XML documents
XML Examples
- Slides: 72