[xsd-users] Need help with creating Object Model from scratch

Laura E Fowler Laura_E_Fowler at raytheon.com
Tue Sep 23 15:57:49 EDT 2008


I'm fairly new to XML and really new to XSD, so place have patience. 

I have been trying to figure out how to create an object model from 
scratch with our specific schema. I can't find an example that is similar 
to what we need to do. 

I have taken our schema and made it generic and it is below.  I have been 
running xsd as follows:
xsd cxx-tree --type-naming ucc --generate-inline --generate-ostream 
--generate-serialization <filename>

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema 
        xmlns:xs="http://www.w3.org/2001/XMLSchema" 
        xmlns:lib="http://www.codesynthesis.com/library"
    targetNamespace="http://www.codesynthesis.com/library">
        <xs:element name="Marker">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="id" type="xs:string">
                                        <xs:annotation>
                                                <xs:documentation> ID is 
the S# of a carrier board or Unique ID for servers</xs:documentation>
                                        </xs:annotation>
                                </xs:element>
                                <xs:element name="deviceType">
                                        <xs:simpleType>
                                                <xs:restriction 
base="xs:string">
                                                        <xs:enumeration 
value="TYPEA"/>
                                                        <xs:enumeration 
value="TYPEB"/>
                                                        <xs:enumeration 
value="TYPEC"/>
                                                </xs:restriction>
                                        </xs:simpleType>
                                </xs:element>
                                <xs:element name="changed" 
type="xs:boolean">
                                        <xs:annotation>
                                                <xs:documentation>set to 
true if first time sent of any info has changed since last time 
sent.</xs:documentation>
                                        </xs:annotation>
                                </xs:element>
                                <xs:element ref="lib:DeviceDescription"/>
                        </xs:sequence>
                </xs:complexType>
        </xs:element>
        <xs:element name="DeviceDescription">
                <xs:complexType>
                        <xs:choice>
                                <xs:element 
ref="lib:DeviceDescriptionTypeA"/>
                                <xs:element 
ref="lib:DeviceDescriptionTypeB"/>
                                <xs:element 
ref="lib:DeviceDescriptionTypeC"/>
                        </xs:choice>
                </xs:complexType>
        </xs:element>
        <xs:element name="DeviceDescriptionTypeA">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="id" type="xs:string"/>
                        </xs:sequence>
                </xs:complexType>
        </xs:element>
        <xs:element name="DeviceDescriptionTypeB">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="id" type="xs:string"/>
                        </xs:sequence>
                </xs:complexType>
        </xs:element>
        <xs:element name="DeviceDescriptionTypeC">
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="id" type="xs:string"/>
                        </xs:sequence>
                </xs:complexType>
        </xs:element>
</xs:schema>

Please let me know if I haven't given you enough information.

Any help that you can provide would be appreciated. 
Laura 


 


More information about the xsd-users mailing list