[slide 1] -hi, for those of you who weren't at the last meeting, my name is ryan flannery, and i'm giving a series of presentations on Sun Microsystems Technology -tonights presentations i on XML -have give-aways -> after presentation [slide 2] formally prepared by Srikanth Raju a tech evang for sun [slide 3] i'm going to cover -what xml is, from a brief, high-level perspective -using java with xml, primarily SAX and JAXP -what you can do by implementing xml -references for more info [slide 4] so, to start out - what is xml [slide 5] -stands for extensible markup language -a markup language uses tags in its syntax to give code meaning -since it's "extensible", it has no set tags [slide 6] also... -architecture & language independent * stored in a basic text format, just like html, so it's just as portable -xml documents are also self-describing, meaning, they can contain Document Type Definitions (DTD's) that manipulate how the document can be viewed/interpreted by other applications * done by 2 parts 1 - content 2 - DTD's [slide 7] what can xml be used for? -storing and exchaning data between different applications, wether the applications are desktop apps or apps running in a cell-phone or a dashboard computer in a new luxery car. -abstract presentation of a file away from it's content, by using xml style-sheet transformations and DTD's. -defining configuration information (which is the same as storing info) [slide 8] here's some html, that you'll see re-written in xml here next -you can see that the content itself (the trade/account info) is in a logical manner, but the manner in which it is represented in html is NOT. [slide 9] here's that same info, in xml -you can see that the content is organized much better xml. -it would be much easier to parse this file for data than the last one. [slide 10] some general characteristics of xml are: -xml doc's have a strict hierarchy of tags * there's one root element which every other element is a child of. -tags are handled identical to html (with opening/closing braces) -anal about syntax: * xml is case-sensitive * attributes must have double-quotes * elements must have a closing brace * html is the exact opposite, with very lax syntax [slide 11] xml elements are the base unit of text in xml -the naming rules for elements are similar to c (except for the colon) -all elements must have a set of start/end tags, and can opptionally have attributes. [slide 12] xml elements can what are called "attributes" -same as in html, only they are meant to serve a different purpose -attributes are supposed to be used to add meta-data (info about info) to an element. -any attribute could be expanded into another, seperate element which is generally the prefferred method. -can be used to affect the presentation to an end-user [slide 13] -now, onto incorporating java w/ xml [slide 14] first, i'll talk about XML Parsers -a parser is used to extract & analyze data in an xml doc, and can be used to analyze the syntax of an xml document. -any errors with syntax are thrown immediately, back to the controlling application -there's some interfaces that you can use to parse XML, and i'll start off by going over SAX [slide 15] SAX is the Simple API for XML -native to Java, but now also available in alot of other languages. it's strong points are that it provides fast, memory-efficient read access to xml data. -it's down-down fall is that it is only, read-only (meaning you can't write xml) and it only has serial access to an xml document, making searching an xml document a real pain. An alternative to SAX, if you're in a web-environment, is DOM DOM is the Document Object Model, and anyone here who's ever written a web page is more than familiar with this. -DOM can work with an xml document as a whole, providing random access to the entire document, and read/write access. -the only down-fall to DOM is that it is very memory intensive, requiring the entire document be loaded into memory. [slide 16] back to parsers...parsers come in two major flavors: 1 - validating parsers and 2 - non-validating parsers -a validating parser can use a provided Document Type Definition and can check to see if the xml document follows the rules defined in it. -non validating parsers doesn't compare the document against a DTD, and as a result will not catch any rule's or constraints placed on it. it is, however much faster than a validatinparser. [slide 17] here's an exmaple of why you would want to use validating parser. -the action attribute of trade is set to something other than buy or sell, and there's multiple quantitly elements within the trade element. [slide 18] if we were to use a DTD with that xml, and a validating parser, it could catch such mistakes <> [slide 19] know, a little about XML transformations... -first, XSL stands for eXtensible Stylesheet Language, and is almost identical to regular style-sheets for the web. -XSL Transformations can be applied to an XML document, and actually transform the document into someting else (html, or another XML document). [slide 20] XSLT works by defining a set of text used to match specific elements. everywhere that element appears in the xml doc that this style-sheet is applied to, will be completely replaced by what we define here. we can even grab the attributes from an xml element and have them displayed inside the text. [slide 21] this picture just shows how that process works, and how the XSLT document is "applied" to an XML document, by an XSLT processor, to produce an entirely new file of virtually any format. [slide 22] You can see some of the operations you can do with XSL Transformations, and really there's enough of the basics to do just about anything with them. [slide 23] -on to using xml with java in web-applications [slide 24] Applets can be used to work with XML, and this puts all of the processing responsiblities on the client. which means a lighter load on the server, but could potentially annoy users with slow machines or connections. would also require them to download all XSL and DTD documents. There's an apache module called Xalan which is an XSLT processor. [slide 25] Servlets could also be used to work with XML, putting all of the processing responsibility on the server. clients would then be completely unware of XML, and just see the 'end product', so to speak. [slide 27] that's all i have for this presentation, if you're interested in getting more material on XML, you can use one of the links i have listed, or just email me. [slide 28]