Join David Gassner for an in-depth discussion in this video Using the exercise files, part of XML Integration with Java.
This course is accompanied by exercise files that you can use to follow along with the demonstrations that I do on screen. I've copied the exercise files to my desktop, but you can place them anywhere on your hard disk. The exercise files are organized by chapter, one folder for each chapter of the course. Within each of the folders, you'll find zip files. Each of the zip files is an Eclipse Project archive, intended to be imported into Eclipse. There's one folder for each of the chapters for starting projects, and then, under the Solutions folder, there's a set of folders for the chapters as well.
And within those folders, you'll find the Solution Projects, the finished versions of each exercise. Additionally, there is an Assets folder. It contains a data folder with all of the data files that I use in the course, including both JSON and XML files, and a Lives folder. This contains JAR files that I use in the course. Whenever I use an external JAR file, I'll tell you where to download it on the web because these are all open source free JAR files.
But I've included just the JAR files here for convenience. To make sure that you can use exactly the same version of any particular JAR file that I'm using. To work through the course, I'm using Eclipse 4.3, or Kepler. And specifically, I'm using the version for Java developers. If you prefer, you can use Eclipse for Java EE developers. It'll look different than this by default, but to make it look the same as the Java version, switch your perspective.
Choose Window, Open Perspective, Other and then switch to the Java perspective. If you prefer, you can work in the XML perspective, which is available from the same place. The XML perspective has a couple of additional views. Named Documentation and Properties that are specific to XML. I'll be using the Java perspective mostly throughout this course. To work with the exercise files, import them into Eclipse.
Many of the exercise files depend on a project called data provider. That's a part of those projects' build path. You need to have that project imported and open. To import that project, choose File > Import, choose Existing Projects into Workspace and Select Archive File, browse, and go to the Exercise Files folder to the 01_GettingStarted folder. And follow the prompt to import the DataProvider project.
I'll describe in detail what this project does, but briefly it has a few Java classes and a particular library named Json-simple that's used throughout the course to get data that can be serialized into XML. This project replaces a database or any other more complex data provider. Once you have the Data Provider Project open, you can open other projects. So for example, I'll import something from the chapter on DOM, or Document Object Model.
Now go back up to the exercise files, then down to 03_dom. And then, I'll import the project DomCreateDocument. This project will require data. And so, in order to get it, you have to have the data provider in the DOM create project's build path. For the most part, this binding will already be done for you, but if you have any issues, here's how you can double-check it. Right click on the project that needs to be bound to data provider.
Go to Build Path and then Configure Build Path. In the Projects tab, you should see the DataProvider project listed. If you don't, click the Add button and add it to this project's build path. And then, you'll be able to start working on that project. If you want to look at the solution for any particular project, you can open it at the same time because it has a different name than the starting project. So I'll select File > Import > Existing Projects Into Workspace.
And this time, I'll go to the Solutions folder. Once again to 03_DOM, and I'll choose the finished version of this project, DOMCreateDocument_Solution. Now click Finish and I'll be able to look at the finished code for that project. So that's a tour of the exercise files, how to import the zip files into Eclipse, how to make sure that you have the build paths set up correctly, and how you can use the solution projects if you want to peek ahead.
- Choosing a Java-based XML API
- Reading XML as a string
- Comparing streaming and tree-based APIs
- Parsing XML with SAX
- Creating and reading XML with DOM
- Adding data to an XML document with JDOM
- Reading and writing XML with StAX
- Working with JAXB and annotated classes
- Comparing Simple XML Serialization to JAXB