From: Justin Bailey Date: 2006-03-23T06:08:31+09:00 Subject: Re: [ANN] XmlStruct-1.0.0 released ------=_Part_5958_7421222.1143061694870 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Have you seen the xml builder project? It's along the same lines but gives = a much cleaner syntax. Your example could be done along these lines: xml.GovTalkMessage :xmlns =3D> "http ..." { |xml| xml.EnvelopeVersion "2.0" xml.Header { xml.MessageDetails { etc, etc } } } Check it out http://rubyforge.org/projects/builder/ On 3/22/06, NeilW wrote: > > XmlStruct > =3D=3D=3D=3D=3D=3D=3D=3D=3D > > http://rubyforge.org/projects/xmlstruct/ > > Documentation > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > http://xmlstruct.rubyforge.org/ > > About > =3D=3D=3D=3D=3D > > XML Markup the simple way. > > I've uploaded a small library to Rubyforge that allows you > to markup data using XML tags using direct Ruby assignment > following the example of OpenStruct. > > The library supports attributes and simple text elements - > all of which are XML escaped before output. The interface is > designed to be as simple as possible, with the least amount > of syntactic sugar. The general idea is that you mark up your > flat data and output a string containing the markup. > > The system works best when you have a small amount of data, > and a large amount of irritating XML structure to impose upon > it. The class came about to allow me to quickly draw up XML > messages to send to the UK Government Gateway. Boy can you > tell that that schema was designed by committee. > > I hope that it finds some use somewhere. > > Usage > =3D=3D=3D=3D=3D > > I hope the interface is intuitive. Very simply you use assignment > commands, e.g > > require 'rubygems' > require 'xml_struct' > @xmldoc =3D XmlStruct.new > @xmldoc.GovTalkMessage=3D{:xmlns =3D> > "http://www.govtalk.gov.uk/CM/envelope"} > @xmldoc.GovTalkMessage.EnvelopeVersion=3D"2.0" > md=3D@xmldoc.GovTalkMessage.Header.MessageDetails > md.Class=3D"MAFF-IACS-AAPS2001" > md.Qualifier=3D"request" > md.Function=3D"submit" > md.CorrelationID > md.Transformation=3D"XML" > md.GatewayTimeStamp > @xmldoc.GovTalkDetails.Keys.Key[0]=3D{:Type =3D> "VendorNumber"} > @xmldoc.GovTalkDetails.Keys.Key[0]=3D275687 > @xmldoc.GovTalkDetails.Keys.Key[1]=3D{:Type =3D> "MainCPH"} > @xmldoc.GovTalkDetails.Keys.Key[1]=3D"14/02/0327" > @xmldoc.GovTalkDetails.Body > print @xmldoc.to_s > > outputs > > > 2.0 >
> > MAFF-IACS-AAPS2001 > request > submit > > > XML > > > >
>
> > > 275687 > 14/02/0327 > > > > > > > Enjoy > =3D=3D=3D > Neil Wilson, Aldur Systems Ltd > > > ------=_Part_5958_7421222.1143061694870--