XML Creation and Parsing

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
pax
Reply | Threaded
Open this post in threaded view
|

XML Creation and Parsing

pax
Hi,

at present I have implemented methods in my domain classess which allow
each instance of a given class to output itself as an XML string aka
document.

Customer>>asXMLDocument

"Return an representation of the receiver as an XML document"

        | aStream |
        aStream := WriteStream on: String new.
        aStream nextPutAll: '<?xml version="1.0"?>cr; tab;
        aStream nextPutAll: '<Customer>';
        aStream nextPutAll: '<First_Name>';
        aStream nextPutAll: self firstName;
        aStream nextPutAll: '</First_Name>'; cr; tab;
        aStream nextPutAll: '<Last_Name>';
        aStream nextPutAll: self lastName;
        aStream nextPutAll: '</Last_Name>'; cr; tab;
        aStream nextPutAll: '<Account_NUmber>';
        aStream nextPutAll: self accountNumber;
        aStream nextPutAll: '</Account_NUmber>'; cr; tab;
        aStream nextPutAll: '<Balance>';
        aStream nextPutAll: self accountBalance;
        aStream nextPutAll: '</Balance>'; cr; tab;
        aStream nextPutAll: '</Customer>'.


        ^aStream contents


My question is, Is this standard procedure for implementing XML
capability for domain objects? Any points, tips or suggestions from
others that have implemented XML in domain classes would be
appreciated.

I plan to use the MSXML engine via ActiveX to read/parse the XML from
which I should be able to instantiate objects and set their attributes.

One item of interest is sending the XML string to a webserver where it
will be processed by a fast cgi application running in Dolphin. Anyone
with experience in this area regarding the packages from Steve Waring?

Thanks,

Pax


Reply | Threaded
Open this post in threaded view
|

Re: XML Creation and Parsing

Chris Uppal-3
Pax wrote:

> My question is, Is this standard procedure for implementing XML
> capability for domain objects? Any points, tips or suggestions from
> others that have implemented XML in domain classes would be
> appreciated.

You might find it useful to take a look at SIXX, either as an implementation or
as a source of ideas.

    http://www.mars.dti.ne.jp/~umejava/smalltalk/sixx/

BTW, whenever accepting /arbitrary/ Smalltalk objects from the Net (or any
other untrusted source) you should consider the security implications pretty
seriously.  A roll-you-own approach that only handled your own domain objects
might be safer even if it is more effort to get started.

    -- chris


pax
Reply | Threaded
Open this post in threaded view
|

Re: XML Creation and Parsing

pax
Chris, thanks for the information. I will have a look at SIXX.

The Server(s) will always come from trusted sources. Digital Signatures
will also be applied to ensure that the data stream has not been
tampered with during transit. I was planning on making use of the
Dolphin Sure features which is quite adequate. Also, the implementation
may include SSL encryption for additional security.

It would be interesting to hear if others are doing this and if they
are making use of XML Namespaces as well.

Pax