Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML Configuration in Java David Roossien CS62112/2009.

Similar presentations


Presentation on theme: "XML Configuration in Java David Roossien CS62112/2009."— Presentation transcript:

1 XML Configuration in Java http://blog.davidroossien.com/?p=337 David Roossien CS62112/2009

2 Presentation Outline 1. 3 different ways to process XML configuration: DOM DOM JDOM JDOM SQLXML SQLXML 2. Code Review - Interesting implementation details Singleton pattern Singleton pattern Drivers (library / jar files) Drivers (library / jar files) XML SQL data type XML SQL data type Transform Transform Streams Streams Java Color class Java Color class

3 Configuration Using XML for configuration is common, convenient and useful Using XML for configuration is common, convenient and useful

4 DOM Document Document Object Model Document Object Model http://java.sun.com/j2se/1.5.0/docs/guide/p lugin/dom/index.html http://java.sun.com/j2se/1.5.0/docs/guide/p lugin/dom/index.html http://java.sun.com/j2se/1.5.0/docs/guide/p lugin/dom/index.html http://java.sun.com/j2se/1.5.0/docs/guide/p lugin/dom/index.html org.w3c.dom.Document org.w3c.dom.Document http://www.w3.org/TR/2004/REC-DOM- Level-3-Core-20040407/ http://www.w3.org/TR/2004/REC-DOM- Level-3-Core-20040407/

5 SAX Parser https://jaxp- sources.dev.java.net/nonav/docs/api/javax /xml/parsers/SAXParser.html https://jaxp- sources.dev.java.net/nonav/docs/api/javax /xml/parsers/SAXParser.html https://jaxp- sources.dev.java.net/nonav/docs/api/javax /xml/parsers/SAXParser.html https://jaxp- sources.dev.java.net/nonav/docs/api/javax /xml/parsers/SAXParser.html SAX Parser can parse SAX Parser can parse InputStreams InputStreams Files Files URLs URLs SAX InputSources SAX InputSources

6 JDOM http://www.jdom.org/ http://www.jdom.org/ http://www.jdom.org/ Makes it easier to parse than DOM (Java) Makes it easier to parse than DOM (Java) Jarfile: http://www.jdom.org/dist/binary/ Jarfile: http://www.jdom.org/dist/binary/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 To use it, include the jdom.jar on the libraries tab as an external jar in your eclipse project

7 SQLXML SQLXML is a Java interface class 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/SQLXML.html http://java.sun.com/javase/6/docs/api/java/ sql/SQLXML.html 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 http://java.sun.com/javase/6/docs/api/java/ sql/class-use/SQLXML.html http://java.sun.com/javase/6/docs/api/java/ sql/class-use/SQLXML.html http://java.sun.com/javase/6/docs/api/java/ sql/class-use/SQLXML.html

8 XML in SQL Server 2005 http://msdn.microsoft.com/en- us/library/dd571291.aspx http://msdn.microsoft.com/en- us/library/dd571291.aspx http://msdn.microsoft.com/en- us/library/dd571291.aspx http://msdn.microsoft.com/en- us/library/dd571291.aspx XML data type XML data type http://www.w3schools.com/SQL/sql_dataty pes.asp http://www.w3schools.com/SQL/sql_dataty pes.asp http://www.w3schools.com/SQL/sql_dataty pes.asp http://www.w3schools.com/SQL/sql_dataty pes.asp no support in MS Access no support in MS Access SQL 2005 (2 GB limit) SQL 2005 (2 GB limit)

9 Conclusions DOM DOM NodeList – iterate to find your element NodeList – iterate to find your element JDOM - makes configuration easier JDOM - makes configuration easier SQLXML – makes it possible to get XML data from a database SQLXML – makes it possible to get XML data from a database


Download ppt "XML Configuration in Java David Roossien CS62112/2009."

Similar presentations


Ads by Google