Class generation from xml schema

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

Class generation from xml schema

mikea59
I have an xml schema that I want to use to generate equivalent VW classes. I don't need WSDL's or Web Services, just want to create the classes and then marshal/unmarshal between VW and xml. The Web services docs are so wrapped around WSDL's and such, I don't need all that, just the classes. Anyone have a pointer to an example?

Thanks,
Mike
Reply | Threaded
Open this post in threaded view
|

RE: Class generation from xml schema

Kogan, Tamara
See if it helps:
        doc := (XML.XMLParser on: self myXMLSchemaString readStream)
                                validate: false;
                                scanDocument.
        xmlBinding := WebServices.XMLTypesParser
                                useObjectBindingReadFrom: doc
                                inNamespace: 'Test'.

        builder := WebServices.BindingClassBuilder new.
        builder package: 'My Package'.
        builder createClassesFromBinding: xmlBinding realElements.
        binding := WebServices.BindingBuilder loadFrom: xmlBinding
printString readStream.
        manager := WebServices.XMLObjectMarshalingManager on:
binding.
        manager useInlineType: false.

        xml := manager marshal: obj.

Tamara Kogan
Smalltalk development,
Cincom Systems

> -----Original Message-----
> From: mikea59 [mailto:[hidden email]]
> Sent: Monday, February 11, 2008 3:54 PM
> To: [hidden email]
> Subject: Class generation from xml schema
>
>
> I have an xml schema that I want to use to generate equivalent VW
classes.
> I
> don't need WSDL's or Web Services, just want to create the classes and
> then
> marshal/unmarshal between VW and xml. The Web services docs are so
wrapped
> around WSDL's and such, I don't need all that, just the classes.
Anyone
> have
> a pointer to an example?
>
> Thanks,
> Mike
> --
> View this message in context:
http://www.nabble.com/Class-generation-from-
> xml-schema-tp15420334p15420334.html
> Sent from the VisualWorks mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

RE: Class generation from xml schema

mikea59
   Thanks for the quick tip, very helpful. I've been doing this basic process and getting less than desirable results, which now  encourages me to look at my starting schema - I think it has some problems.

   Thanks,
   Mike
 
Kogan, Tamara wrote
See if it helps:
        doc := (XML.XMLParser on: self myXMLSchemaString readStream)
                                validate: false;
                                scanDocument.
        xmlBinding := WebServices.XMLTypesParser
                                useObjectBindingReadFrom: doc
                                inNamespace: 'Test'.

        builder := WebServices.BindingClassBuilder new.
        builder package: 'My Package'.
        builder createClassesFromBinding: xmlBinding realElements.
        binding := WebServices.BindingBuilder loadFrom: xmlBinding
printString readStream.
        manager := WebServices.XMLObjectMarshalingManager on:
binding.
        manager useInlineType: false.

        xml := manager marshal: obj.

Tamara Kogan
Smalltalk development,
Cincom Systems

> -----Original Message-----
> From: mikea59 [mailto:m-anderson@adventact.com]
> Sent: Monday, February 11, 2008 3:54 PM
> To: vwnc@cs.uiuc.edu
> Subject: Class generation from xml schema
>
>
> I have an xml schema that I want to use to generate equivalent VW
classes.
> I
> don't need WSDL's or Web Services, just want to create the classes and
> then
> marshal/unmarshal between VW and xml. The Web services docs are so
wrapped
> around WSDL's and such, I don't need all that, just the classes.
Anyone
> have
> a pointer to an example?
>
> Thanks,
> Mike
> --
> View this message in context:
http://www.nabble.com/Class-generation-from-
> xml-schema-tp15420334p15420334.html
> Sent from the VisualWorks mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

RE: Class generation from xml schema

mikea59
In reply to this post by Kogan, Tamara
I can't seem to make this work. I have an example, a simplified schema that illustrates the problems I've been working from a much larger schema. This example does not work - it gets an error in WebServices.XMLTypesParser useObjectBindingReadFrom: doc inNamespace: 'MyTest'.

See below: (Do I need to pre-treat this schema before I build the object binding - wrap it somehow?)

(
myXMLSchemaString := '<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:element name="anchorNameExpression">
                <xs:complexType mixed="true"/>
        </xs:element>
        <xs:element name="comparatorExpression">
                <xs:complexType mixed="true"/>
        </xs:element>
        <xs:element name="bucketExpression">
                <xs:complexType mixed="true">
                        <xs:attribute name="class" type="xs:NMTOKEN" use="required"/>
                </xs:complexType>
        </xs:element>
        <xs:element name="bucket">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element ref="bucketExpression" minOccurs="0"/>
                                <xs:element ref="comparatorExpression" minOccurs="0"/>
                        </xs:sequence>
                        <xs:attribute name="order" use="optional" default="Ascending">
                                <xs:simpleType>
                                        <xs:restriction base="xs:NMTOKEN">
                                                <xs:enumeration value="Ascending"/>
                                                <xs:enumeration value="Descending"/>
                                        </xs:restriction>
                                </xs:simpleType>
                        </xs:attribute>
                </xs:complexType>
        </xs:element>
       
        <xs:element name="property">
                <xs:complexType>
                        <xs:attribute name="name" type="xs:string" use="required"/>
                        <xs:attribute name="value" type="xs:string" use="optional"/>
                </xs:complexType>
        </xs:element>
        <xs:element name="jasperReport">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element ref="bucket" minOccurs="0" maxOccurs="unbounded"/>
                                <xs:element ref="property" minOccurs="0"/>
                        </xs:sequence>
                        <xs:attribute name="name" type="xs:NMTOKEN" use="required"/>
                </xs:complexType>
        </xs:element>
</xs:schema>
'.
doc := (XML.XMLParser on:  myXMLSchemaString readStream)
                                validate: false;
                                scanDocument.
        xmlBinding := WebServices.XMLTypesParser
                                useObjectBindingReadFrom: doc
                                inNamespace: 'MyTest'.
)


Kogan, Tamara wrote
See if it helps:
        doc := (XML.XMLParser on: self myXMLSchemaString readStream)
                                validate: false;
                                scanDocument.
        xmlBinding := WebServices.XMLTypesParser
                                useObjectBindingReadFrom: doc
                                inNamespace: 'Test'.

        builder := WebServices.BindingClassBuilder new.
        builder package: 'My Package'.
        builder createClassesFromBinding: xmlBinding realElements.
        binding := WebServices.BindingBuilder loadFrom: xmlBinding
printString readStream.
        manager := WebServices.XMLObjectMarshalingManager on:
binding.
        manager useInlineType: false.

        xml := manager marshal: obj.

Tamara Kogan
Smalltalk development,
Cincom Systems

> -----Original Message-----
> From: mikea59 [mailto:m-anderson@adventact.com]
> Sent: Monday, February 11, 2008 3:54 PM
> To: vwnc@cs.uiuc.edu
> Subject: Class generation from xml schema
>
>
> I have an xml schema that I want to use to generate equivalent VW
classes.
> I
> don't need WSDL's or Web Services, just want to create the classes and
> then
> marshal/unmarshal between VW and xml. The Web services docs are so
wrapped
> around WSDL's and such, I don't need all that, just the classes.
Anyone
> have
> a pointer to an example?
>
> Thanks,
> Mike
> --
> View this message in context:
http://www.nabble.com/Class-generation-from-
> xml-schema-tp15420334p15420334.html
> Sent from the VisualWorks mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

RE: Class generation from xml schema

Kogan, Tamara
If you add default namespace it would have to resolve not qualified
types:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://myschema/">
        <xs:element name="anchorNameExpression">
                <xs:complexType mixed="true"/>
        </xs:element>....

Tamara Kogan
Smalltalk development,
Cincom Systems

> -----Original Message-----
> From: mikea59 [mailto:[hidden email]]
> Sent: Tuesday, February 12, 2008 5:50 PM
> To: [hidden email]
> Subject: RE: Class generation from xml schema
>
>
> I can't seem to make this work. I have an example, a simplified schema
> that
> illustrates the problems I've been working from a much larger schema.
This
> example does not work - it gets an error in WebServices.XMLTypesParser
> useObjectBindingReadFrom: doc inNamespace: 'MyTest'.
>
> See below: (Do I need to pre-treat this schema before I build the
object

> binding - wrap it somehow?)
>
> (
> myXMLSchemaString := '<?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <xs:element name="anchorNameExpression">
> <xs:complexType mixed="true"/>
> </xs:element>
> <xs:element name="comparatorExpression">
> <xs:complexType mixed="true"/>
> </xs:element>
> <xs:element name="bucketExpression">
> <xs:complexType mixed="true">
> <xs:attribute name="class" type="xs:NMTOKEN"
> use="required"/>
> </xs:complexType>
> </xs:element>
> <xs:element name="bucket">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="bucketExpression"
minOccurs="0"/>
> <xs:element ref="comparatorExpression"
> minOccurs="0"/>
> </xs:sequence>
> <xs:attribute name="order" use="optional"
> default="Ascending">
> <xs:simpleType>
> <xs:restriction
base="xs:NMTOKEN">
> <xs:enumeration
value="Ascending"/>
> <xs:enumeration
value="Descending"/>

> </xs:restriction>
> </xs:simpleType>
> </xs:attribute>
> </xs:complexType>
> </xs:element>
>
> <xs:element name="property">
> <xs:complexType>
> <xs:attribute name="name" type="xs:string"
> use="required"/>
> <xs:attribute name="value" type="xs:string"
> use="optional"/>
> </xs:complexType>
> </xs:element>
> <xs:element name="jasperReport">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="bucket" minOccurs="0"
> maxOccurs="unbounded"/>
> <xs:element ref="property"
minOccurs="0"/>

> </xs:sequence>
> <xs:attribute name="name" type="xs:NMTOKEN"
> use="required"/>
> </xs:complexType>
> </xs:element>
> </xs:schema>
> '.
> doc := (XML.XMLParser on:  myXMLSchemaString readStream)
>                                 validate: false;
>                                 scanDocument.
>         xmlBinding := WebServices.XMLTypesParser
>                                 useObjectBindingReadFrom: doc
>                                 inNamespace: 'MyTest'.
> )
>
>
>
> Kogan, Tamara wrote:
> >
> > See if it helps:
> > doc := (XML.XMLParser on: self myXMLSchemaString readStream)
> > validate: false;
> > scanDocument.
> > xmlBinding := WebServices.XMLTypesParser
> > useObjectBindingReadFrom: doc
> > inNamespace: 'Test'.
> >
> > builder := WebServices.BindingClassBuilder new.
> > builder package: 'My Package'.
> > builder createClassesFromBinding: xmlBinding realElements.
> > binding := WebServices.BindingBuilder loadFrom: xmlBinding
> > printString readStream.
> > manager := WebServices.XMLObjectMarshalingManager on:
> > binding.
> > manager useInlineType: false.
> >
> > xml := manager marshal: obj.
> >
> > Tamara Kogan
> > Smalltalk development,
> > Cincom Systems
> >
> >> -----Original Message-----
> >> From: mikea59 [mailto:[hidden email]]
> >> Sent: Monday, February 11, 2008 3:54 PM
> >> To: [hidden email]
> >> Subject: Class generation from xml schema
> >>
> >>
> >> I have an xml schema that I want to use to generate equivalent VW
> > classes.
> >> I
> >> don't need WSDL's or Web Services, just want to create the classes
and

> >> then
> >> marshal/unmarshal between VW and xml. The Web services docs are so
> > wrapped
> >> around WSDL's and such, I don't need all that, just the classes.
> > Anyone
> >> have
> >> a pointer to an example?
> >>
> >> Thanks,
> >> Mike
> >> --
> >> View this message in context:
> > http://www.nabble.com/Class-generation-from-
> >> xml-schema-tp15420334p15420334.html
> >> Sent from the VisualWorks mailing list archive at Nabble.com.
> >
> >
> >
>
> --
> View this message in context:
http://www.nabble.com/Class-generation-from-
> xml-schema-tp15420334p15445104.html
> Sent from the VisualWorks mailing list archive at Nabble.com.