Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C# Programming

How to inherit the child elements of base type


Hi guys,

Hope you can help me.I'm new in using C# and Xml Schema.
I have a problem in getting the child element of the base type..
Here is the sample of my xsd file:

<xs:complexType name="Magazine" abstract="true">
                <xs:sequence>
                        <xs:element name="Title" type="xs:string"/>
                        <xs:element name="Editor" type="xs:string"/>
                </xs:sequence>
        </xs:complexType>

        <xs:complexType name="WomensMagazine">
                <xs:complexContent>
                        <xs:extension base="Magazine">
                                <xs:sequence maxOccurs="unbounded">
                                        <xs:element name="CosmeticsAdvert"
                                           type="xs:string"/>
                                </xs:sequence>
                        </xs:extension>
                </xs:complexContent>
        </xs:complexType>

I want that my output uld look like this:

struct WomensMagazine
{
 string Title;
 string Editor;
 string CosmeticsAdvert;

};

Here is my code:
if (ct.ContentModel == null)
{
    //Navigate to sequence particle of complex type without an
extension base
   if (ct.Particle is XmlSchemaSequence)
   {
        //Get to sequence element and Walk through elements in
sequence tag
       XmlSchemaSequence seq = (XmlSchemaSequence)ct.Particle;
       foreach (XmlSchemaObject childElem in seq.Items)
       {
          idlContent += getStructField1(childElem, idlClass);
      }
  }
}

else
{
    if (ct.ContentModel.Content is XmlSchemaComplexContentExtension)
    {
        XmlSchemaComplexContentExtension xscce =
ct.ContentModel.Content as
XmlSchemaComplexContentExtension;
       //Navigate to a complex type with extension base
       if (xscce.Particle is XmlSchemaSequence)
       {
        //Get to sequence element and Walk through elements in sequence tag
        XmlSchemaSequence sequence= (XmlSchemaSequence)xscce.Particle;
        foreach(XmlSchemaObject obj in sequence.Items)
        {
                        idlContent += getStructField1(obj, idlClass);                           }
     }
  }

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc