xsd or no xsd

I’ve been playing around with the controller configuration setup for my current project. The config is stored as XML, and partly as an exercise, I did an XSD for it.

Having pursuaded JDOM and xerces into playing nice, I now have the code. Kev pointed out that JDOM and xercesImpl are quite large. xercesImpl is needed for the xsd, and JDOM is just used for convenience (I’ve used it before).

The XSD isn’t particularly complicated, but as I already have the code in place, I just can’t decide wether the XSD is worth it. Is the extra 1.2 meg of xercesImpl worth it to have an XSD for xml that my own lib will be reading and writing?

Just looking for ideas on how I can go about answering myself.

Endolf

If your code is the only code writing that xml, I guess there’s no need for validation at all.

Erik

IMO, even it is just you reading and writing it, its nice to have some validation just to catch typos etc. However, its a “nice to have” so I stick to whats there for free (i.e. DTDs).

Kev

I thought you were up to J2EE game servers, in which case you don’t need to worry about size?

But if it’s for a downloadable thing, then perhaps you could just use the XSD when writing the XML. Or have the XML validated against the XSD as part of your build process. Then you get the benfits of the XSD without having to deploy big, fat xercesImpl.jar.

Hi

The plan is to test with J2EE game server yes, but the client will just see it as a socket connection, I’m not planning on using RMI with EJB’s from the client. I’m not sure why that means I don’t need to worry about size?, the client is still going to need to be downloaded, and sure, most players (if there are ever any) will be on broadband and an extra 1 meg isn’t going to make much difference.

One of the XSD’s is checking the configuration of the user selected input settings, so I can’t just check at compile time.

I could use a DTD as kev suggested as this really is simple XML.

Endolf

Note to self. If one does a google search, one will find the answer

I’m using features from java 1.5, and a quickish google reveals this. It seems as though I can get rid of jdom and xercesImpl from my webstart as if I convert my calls to this I get xsd for free in 1.5 :slight_smile:

Endolf

Excellent thanks for posting this little nugget :slight_smile:

It always seemed daft to me that XML schema wasn’t supported by deafult. Now it is :slight_smile: Looks pretty easy to use too.

Dan.

Yup, seems rather good, if you are using 1.5, I’m now in 2 minds.

If I rely on 1.5 being installed on the game players machine, I can use my xsd for free, generics, and enums.

If I rely on only 1.4 being present, I have to ship jdom/xerces if I want xsd (at ~1.5 meg), and have to write my own enum/list classes as before.

On the other hand, by the time my current project ever gets anyone else using it, this won’t be so much of an issue as jdk 432 will be out :wink:

Endolf

I don’t think you need jDOM just Xerces (although I know it is still about a meg).

You can set the standard java stuff up to parse using xsd but you need the xerces implementation of the xml parsing stuff. If I remember correctly it’s done through setting some attributes when you set it up. I’m sure the XML processing bit on the sun website shows an example.

hmm not sure I’m 100% correct there but anyway you can downlod this http://java.sun.com/developer/technicalArticles/xml/jaxp1-3/ it seems to give you the 1.5 stuff with out needing 1.5 so atleast it might still be the same interface. Sorry if you’ve already seen this. I know I have set 1.4 up to use xsd before (quite a while ago) and I didn’t need jDOM just xerces. I may have downloaded JAXP though.

Dan.

Hi

Yeah, JDOM can be dropped at any time. I looked at the JAXP stuff on java.net, but it’s 4 meg for some installer. xercesImpl is looking like the best option if I want xsd and 1.4.

The other route is just to say ‘you need 1.5’ :slight_smile:

Endolf