------ art_9371_3762546.1140716866738 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Well, what it really makes easy is the import of a given XML document into code. In .NET land, the XSD describes the format for a set of XML documents. The class generated is then used to import those XML documents into a structure that it's to work with in code than the raw DOM would be. On 2/23/06, Logan Capaldo <logancapaldo / gmail.com> wrote: > > > On Feb 23, 2006, at 12:12 PM, Justin Bailey wrote: > > > .NET ships with a tool that will generate classes directly from an XML > > schema (XSD) file. Does the Ruby standard library have anything > > similar? > > It's a great tool on the .NET side, and I bet Ruby could do it even > > better, > > if not. > > Ok, I'm going to be honest and say first I've never had occasion to > 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: > > <?xml version="1.0" encoding="ISO-8859-1" ?> > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> > <xs:element name="shiporder"> > <xs:complexType> > <xs:sequence> > <xs:element name="orderperson" type="xs:string"/> > <xs:element name="shipto"> > <xs:complexType> > <xs:sequence> > <xs:element name="name" type="xs:string"/> > <xs:element name="address" type="xs:string"/> > <xs:element name="city" type="xs:string"/> > <xs:element name="country" type="xs:string"/> > </xs:sequence> > </xs:complexType> > </xs:element> > <xs:element name="item" maxOccurs="unbounded"> > <xs:complexType> > <xs:sequence> > <xs:element name="title" type="xs:string"/> > <xs:element name="note" type="xs:string" minOccurs="0"/> > <xs:element name="quantity" type="xs:positiveInteger"/> > <xs:element name="price" type="xs:decimal"/> > </xs:sequence> > </xs:complexType> > </xs:element> > </xs:sequence> > <xs:attribute name="orderid" type="xs:string" use="required"/> > </xs:complexType> > </xs:element> > </xs:schema> > > When you can do one of these: > class Shipto < Struct.new(:name, :address, :city, :country) > end > > class Item < Struct.new(:orderid, :title, :note, :quantity, :price) > end > > class Shipment < Struct.new(:shipto, :item) > end > > shipments = [] > > I may have mangled some of the XSD, I'm admitedly not familiar with > it, but generating classes froma schema seems rife with problems > > > > ------ art_9371_3762546.1140716866738--