Re: Creating Ruby Classes from XSD?
- From: Geoffrey Lane <geoff@xxxxxxxxxxx>
- Date: Fri, 24 Feb 2006 22:27:52 +0900
On Feb 23, 2006, at 4:59 PM, Henrik Martensson wrote:
On Thu, 2006-02-23 at 18:32, Logan Capaldo wrote:
<snip>
Ok, I'm going to be honest and say first I've never had occasion to<snipped a W3C Schema>
use this tool. But I'm wondering what exactly is the point? Ruby's
syntax is much less verbose than XML.
Why would you want to type this:
When you can do one of these:<snipped Ruby class definitions
I may have mangled some of the XSD, I'm admitedly not familiar with
it, but generating classes froma schema seems rife with problems
The basic idea is that if you have a schema specification, you can
generate classes for whatever language you want, and the applications
that use them will all understand the same data formats.
<snip> Building classes directly from a data format specification
makes the application using the classes tightly coupled to the data
format.
Yep, that's the exact idea. You don't only want to be tightly-coupled to the data specification, you want it to be EXACTLY the same. The most common place this is used is in SOAP Web Service design. It's often called contract first or schema first design. It's not a bad thing to be tightly coupled to your data at that point because the whole idea is to be able to interoperate with an existing service. This is all about sharing, and it's nice to make things easy and language-neutral when you're going to share. (Cue up Mr. Rogers theme music.)
XSD schema (for all of its imperfections) has the ability to specify constraints on the data that help validate it. Up front your service can define things like:
(pseudo-XSD)
US Address:
Street1 = required
Street2 = optional
City = required
State = [A-Z]{2}
USZip = [0-9]{5}(-[0-9]{4})?
Those kinds of constraints can be done in code, but no language I know of can make an interface to a method that explicit.
--
Geoff Lane <geoff@xxxxxxxxxxx>
.
- Follow-Ups:
- Re: Creating Ruby Classes from XSD?
- From: Gregory Seidman
- Re: Creating Ruby Classes from XSD?
- From: Henrik Martensson
- Re: Creating Ruby Classes from XSD?
- References:
- Creating Ruby Classes from XSD?
- From: Justin Bailey
- Re: Creating Ruby Classes from XSD?
- From: Logan Capaldo
- Re: Creating Ruby Classes from XSD?
- From: Henrik Martensson
- Creating Ruby Classes from XSD?
- Prev by Date: Re: Everything's an object, right?
- Next by Date: Re: Ruby as First Language
- Previous by thread: Re: Creating Ruby Classes from XSD?
- Next by thread: Re: Creating Ruby Classes from XSD?
- Index(es):
Relevant Pages
|