90 likes | 108 Views
XML Configuration in Java http://blog.davidroossien.com/?p=337. David Roossien CS621 12/2009. Presentation Outline. 3 different ways to process XML configuration: DOM JDOM SQLXML Code Review - Interesting implementation details Singleton pattern Drivers (library / jar files)
E N D
XML Configuration in Javahttp://blog.davidroossien.com/?p=337 David Roossien CS621 12/2009
Presentation Outline • 3 different ways to process XML configuration: • DOM • JDOM • SQLXML • Code Review - Interesting implementation details • Singleton pattern • Drivers (library / jar files) • XML SQL data type • Transform • Streams • Java Color class
Configuration • Using XML for configuration is common, convenient and useful
DOM Document • Document Object Model • http://java.sun.com/j2se/1.5.0/docs/guide/plugin/dom/index.html • org.w3c.dom.Document • http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/
SAX Parser • https://jaxp-sources.dev.java.net/nonav/docs/api/javax/xml/parsers/SAXParser.html • SAX Parser can parse • InputStreams • Files • URLs • SAX InputSources
JDOM • http://www.jdom.org/ • Makes it easier to parse than DOM (Java) • Jarfile: http://www.jdom.org/dist/binary/ • To use it, include the jdom.jar on the libraries tab as an “external jar” in your eclipse project
SQLXML • SQLXML is a Java interface class • http://java.sun.com/javase/6/docs/api/java/sql/SQLXML.html • http://java.sun.com/javase/6/docs/api/java/sql/class-use/SQLXML.html
XML in SQL Server 2005 • http://msdn.microsoft.com/en-us/library/dd571291.aspx • XML data type • http://www.w3schools.com/SQL/sql_datatypes.asp • no support in MS Access • SQL 2005 (2 GB limit)
Conclusions • DOM • NodeList – iterate to find your element • JDOM - makes configuration easier • SQLXML – makes it possible to get XML data from a database