Vgo Software

Monday
Apr192010

Welcome to the new Java Hair site!

We have had our share of technical difficulties in running the blog site, espcially without resources solely devoted to the the updating and running of the server.  To deal with that and to be able to post some new content, we have moved the Java-Hair blog to Squarespace.

One of our staffers will be re-posting the content from the old blog up here on the new site, so you will be sure to see a lot of recycled content in the coming weeks, but after that, we'll be on to the new stuff.

So with our technical issues now behind us, we will continue to delight and enlighten you with our vast knowledge of Java, ADF, XML and other enterprise technologies!  Be sure to visit frequently and comment often!

 

Tuesday
Jun232009

Generate an Java-based Ajax-enabled Web App in 5 Minutes

Over the last couple of years there has been a lot of talk about Ruby on Rails and Grails and how easy it is to use them to quickly build an application. How would you like to be able to have all of that speed of development, but have it in a technology that you already know? If you are familiar with Struts or JSF, you can use Rev to quickly build an application for you. 

Rev is a code generation tool developed by Vgo Software, and it gives you the power to do that. All you need is a database, a JDBC driver (most of the common ones are provided with Rev out of the box), a JDK of version 1.5 or better and Rev. Using Rev you’ll be able to generate a completely functional CRUD application based on the tables that you select. The output can be in a variety of different flavors: JSF, Struts, JSF with AJAX, JDBC, EJB, Hibernate, etc. Rev also generates ANT build scripts for a variety of popular application servers so you can build and deploy your application directly from the tool. 

What good is a CRUD application? It all depends on what type of application you are building. For adding testing data or building some Administration screens for a system, the Rev output may be all you need. If you are building a more complicated system, then maybe the persistence layer is all you need and you can rework most of the UI layer. All of the source code is available for you to modify as you see fit, so whether it is the final application itself or the basis for something bigger you will always have something to start with.

One of the unique features of Rev is the ability to customize the generation. Not only can you easily customize the stylesheet from within Rev, but if you want to go deeper you can customize the templates that Rev uses to generate virtually whatever you’d like. From modifying the JSP pages that get generated to creating a whole new set of templates for a completely different language, you can do it all! In fact, included with Rev is a set of templates for generating a PHP-based application. 

You can download your free trial of Rev at the Vgo Software site. Also, be sure to sign up for the webinar I will be presenting on June 30th at 11:00 a.m. EST. During that webinar I will demonstrate how to use Rev and talk about the various output options.
Monday
Jun012009

Book Review: Processing XML documents with Oracle JDeveloper 11g

This is a new feature here on Java Hair, a book review. I was recently approached by the publisher of this book who asked if I would be interested in doing a review. The request was quite timely, I thought, since I have recently been working with XML Schema design (check out the XML category). 

“Processing XML documents with Oracle JDeveloper 11g” seems more like the title to a whitepaper than a full-fledged book, but I found that the book actually covers a lot of topics that fall under the XML Processing umbrella. That, and the fact that JDeveloper documentation can be difficult to come by makes this book a pretty handy addition to your library if you develop with JDeveloper 11g and you are working with XML. 

Starting out, the book covers the parsing of XML documents using both the SAX API and the DOM API. Information that you could get elsewhere, but as the book is JDeveloper 11g specific, it also includes information on how to set up your projects and which libraries you need to include that may or may not be included with your JDeveloper distribution. Very handy information for someone using JDeveloper. 

There is a chapter on using JDeveloper to design an XML Schema, something I could have used a few months ago, actually. JDeveloper’s visual design feature for XML Schema’s is a great tool and comparable to anything I’ve used with Eclipse and NetBeans. Following that is a chapter on validating your schema 3 different ways and how to create these projects in JDeveloper. 

There are some chapters that I didn’t expect to see in this book, but were quite welcome. A chapter devoted to transforming XML to PDF, another on transforming XML to MS Excel, storing XML in Oracle Berkeley DB XML, and even a chapter on Oracle XML Publisher. 

So all in all, despite the self-imposed limitation of XML and JDeveloper, the author, Deepak Vohra, has managed to cram in some very useful topics into his book. Though some of it isn’t really JDeveloper specific, he does makes it relevant by walking thru setting up each project in JDeveloper as well as building and running the subsequent applications in JDeveloper. 

The writing style is very dry, much like you’d probably expect from a reference book, and it should be treated as such, it isn’t something that you are going to want to sit down and read in one sitting. However, if you have work to do in XML and you are considering using or already using JDeveloper as your IDE, I would definitely recommend picking it up. 

You can find the book on virtually any online bookstore or on the publisher’s website: Packt Publishing.
Friday
May292009

Music Post: William Elliott Whitmore


Animals In The Dark

If you haven’t heard William Elliott Whitmore before, you really ought to give his new album, Animals in the Dark, a listen to. He’s an old soul in a not-so-old body with a voice that makes him sound decades older than he is. He’s been compared to Tom Waits many a time. His style has been described as Folk, Country, Alt-Country, Punk, and Soul. He definitely sings with a lot of soul, has a punk attitude, and
musically sounds a lot like folk, playing a lone acoustic guitar or banjo. 

I just started listening to him recently, but he has been around for a while. I haven’t had the chance to see him live yet, but hopefully sometime after he gets back from his tour in Europe I’ll be able to catch him somewhere. 

Animals in the Dark is a politically charged album which is pretty self evident on tracks like “Mutiny”, “Old Devils” and “Johnny Law”. If that isn’t your thing, don’t let that deter you, there really is some great music on this album. If you like this one, be sure to check out “Songs of the Blackbird”, I’m not sure if I like it more than “Animals”, but it certainly has grown on me since I snagged it from the iTunes store. That purchase, btw, marks my first purchase of music from the iTunes store, now that it isn’t DRM’d and I can use play it anywhere, I no longer have a good reason to not buy my music there. I still am a little annoyed by the lack of mp3 support, but being able to purchase and download directly on my iPhone really seems to make up for that. 

As Whitmore says, “I don’t want to be set, I just want to be free.” 

More about William Elliott Whitmore: 

The Official Site 

MySpace
Thursday
May282009

XML Schema Design: Part 3

This is Part 3 of a 3 part series on XML Schema Design. Check out Part 1 or Part 2.

I recently helped complete a project for a large enterprise and this series was inspired by that work and some of the questions that were raised during that process. This last part of the series covers some ways to make your schema design more flexible. 

Reasons to make it more flexible were covered in Part 1, but the basic idea is adopted from evolution. If your solution is extendable and adaptable, it will encourage more people in your organization to use it., ensuring its survival. Ideally different applications within the enterprise will be able to make use of the schema without requiring an updated release of the XSD to adapt to the application’s
specific needs. 

Extendability 

In order to achieve expandability within a single version of the schema it becomes necessary to have the types and elements within the schema allow the addition of different elements and even different attributes. This would allow a user of the schema to add their own elements to the schema without violating the schema definition and would therefore promote the schema’s use within the organization. 

To provide extensibility to the schema, named complex types could have the following elements added to their definition:

<xsd:any namespace="##targetNamespace" processContents="strict" minOccurs="0" maxOccurs="unbounded" />
<xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />

These element definitions will render the schema invalid if there are options elements appearing before their declaration. To prevent this from being an error, add a new element to encompass those generic elements. Your final definition would look like:

<xsd:complexType name="ExtraData">
<xsd:sequence>

<xsd:any namespace="##targetNamespace" processContents="strict" minOccurs="0" maxOccurs="unbounded
<xsd:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>

The addition of these two element definitions allow for any other elements of the target namespace to be added to the type as well as any other elements from any other namespace to be added to the type. Finally to allow for any other attributes to be added the following attribute definition could be added to named complex types:

<xsd:anyAttribute namespace="##any" processContents="skip" />

A Better Approach? 

This method of expandibility works but does so by allowing for almost any XML constructs to be added to XML files in that ExtraData element. This may not always be what you want. Instead, by being careful to abstract out just enough to make the schema flexible, you may be able to achieve the same thing. 

For instance, consider an XML Schema that contains many different discreet data points. Let take a simple user profile type definition for instance:

<xsd:complexType name="UserProfileType">
<xsd:sequence>
<xsd:element name="FirstName" type="xsd:string"></xsd:element>
<xsd:element name="LastName" type="xsd:string"></xsd:element>
<xsd:element name="AccountCreated" type="xsd:dateTime"></xsd:element>
</xsd:sequence>
<xsd:attribute name="userId" type="xsd:string"/>
</xsd:complexType>
 
An example of an instance of an XML document that is validates against this schema definition might be:

<Profile userid="rjava">
<FirstName>Rob</FirstName>
<LastName>Java</LastName>
<AccountCreated>2009-05-26T09:00:00</AccountCreated>
</Profile>
This might work fine for a while, but what happens when you want to keep track of the last time the user accessed the site? You would have to change the schema definition. The solution discussed above would work, but what if we create a generic data type:

<xsd:complexType name="DataType">
<xsd:sequence>
<xsd:element name="Description" type="xsd:string" minOccurs="0"/>
<xsd:element name="StringValue" type="xsd:string" minOccurs="0"/>
<xsd:element name="DateValue" type="xsd:dateTime" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
 

We could use this generic data type inside our UserProfileType:

<xsd:complexType name="UserProfileType">
<xsd:sequence>
<xsd:element name="Data" type="tns:DataType" minOccurs="0" maxOccurs="unbounded"></xsd:element>
</xsd:sequence>
<xsd:attribute name="userId" type="xsd:string"/>
</xsd:complexType>

We could now represent the same data using an XML document like this:

<Profile userid="rjava">
<Data name="FirstName">
<StringValue>Rob</StringValue>
</Data>
<Data name="LastName">
<StringValue>Java</StringValue>
</Data>
<Data name="AccountCreated">
<DateValue>2009-05-26T09:00:00</DateValue>
</Data>
<Data name="Email">
<StringValue>rob@java-hair.com</StringValue>
</Data>
</Profile>

So now we have made the UserProfileType very fluid, maybe too fluid depending on what you want to accomplish. It is exapandable simply by adding whatever instances of Data into the UserProfileType element in your XML Document, but it doesn’t require any fields or even suggest any. A better use may be to combine the first two examples. That way you could enforce the required fields and make optional some of the more common fields, but still leave room for other elements that new applications may require. 

Conclusion

It is very important that the Canonical XML Schema be as easy as possible to understand while still maintaining re usability and flexibility. A Canonical XML Schema is only going to be as good as it’s user-base is large. There isn’t much point in investing in one if the organization as a whole is not going to adopt it. 

Hopefully this series of articles has given you some ideas on how to design an XML Schema that your organization can make use of. Getting the business as a whole to adopt something like this isn’t going to be easy, especially if you don’t have an immediate need for one. My suggestion would be to start small, start with new applications that requires an XML Schema. Prove the value in a proper
enterprise-wide design by showing how the time and effort for enhancements and changes can be reduced and you will go a long way it getting it adopted.