c# - Xsd schema generation - type 'string' is not declared, or is not a simple type -


i creating xml schema using schema object model, on step "set.compile()", above mentioned error. guess related base type name of simpletype elements, help!

is there method, can see giong in while set.compile() method compiles code??

        xmlschemasimpletype namesimpletype = new xmlschemasimpletype();         xmlschemasimpletyperestriction res = new xmlschemasimpletyperestriction();         res.basetypename = new xmlqualifiedname("string","");         xmlschemaminlengthfacet facet1 = new xmlschemaminlengthfacet();         facet1.value = "3";         xmlschemamaxlengthfacet facet2 = new xmlschemamaxlengthfacet();         facet2.value = "10";         res.facets.add(facet1);         res.facets.add(facet2);         namesimpletype.content = res;           xmlschemasimpletype phonetype = new xmlschemasimpletype();         xmlschemasimpletyperestriction phone_res = new xmlschemasimpletyperestriction();         phone_res.basetypename = new xmlqualifiedname("string", "");         xmlschemaminlengthfacet phone_facet1 = new xmlschemaminlengthfacet();         phone_facet1.value = "4";         xmlschemamaxlengthfacet phone_facet2 = new xmlschemamaxlengthfacet();         phone_facet2.value = "20";         phone_res.facets.add(phone_facet1);         phone_res.facets.add(phone_facet2);         phonetype.content = phone_res;           xmlschemasimpletype notetype = new xmlschemasimpletype();         xmlschemasimpletyperestriction note_res = new xmlschemasimpletyperestriction();         note_res.basetypename = new xmlqualifiedname("string", "");         xmlschemaminlengthfacet note_facet1 = new xmlschemaminlengthfacet();         note_facet1.value = "0";         xmlschemamaxlengthfacet note_facet2 = new xmlschemamaxlengthfacet();         facet2.value = "50";         note_res.facets.add(note_facet1);         note_res.facets.add(note_facet2);         notetype.content = note_res;            xmlschemacomplextype employeetype = new xmlschemacomplextype();         xmlschemasequence emp_seq = new xmlschemasequence();          xmlschemaelement firstname = new xmlschemaelement();         firstname.name = "firstname";         firstname.schematype = namesimpletype;          xmlschemaelement lastname = new xmlschemaelement();         lastname.name = "lastname";         lastname.schematype = namesimpletype;          xmlschemaelement homephone = new xmlschemaelement();         homephone.name = "homephone";         homephone.schematype = phonetype;          xmlschemaelement notes = new xmlschemaelement();         notes.name = "notes";         notes.schematype = notetype;           emp_seq.items.add(firstname);         emp_seq.items.add(lastname);         emp_seq.items.add(homephone);         emp_seq.items.add(notes);          employeetype.particle = emp_seq;         /* xmlschemaattribute employeeid = new xmlschemaattribute();         employeeid.name = "employeeid";         employeeid.schematypename = new xmlqualifiedname("int", "");         employeeid.use = xmlschemause.required;         employeetype.attributes.add(employeeid);         */          xmlschemacomplextype complextype = new xmlschemacomplextype();         complextype.name = "employees";          xmlschemaelement employee = new xmlschemaelement();         employee.name = "employee";         employee.schematype = employeetype;         employee.minoccurs = 0;         employee.maxoccursstring = "unbounded";          xmlschemasequence emps_seq = new xmlschemasequence();          emps_seq.items.add(employee);          complextype.particle = emps_seq;         xmlschema schema = new xmlschema();         schema.items.add(complextype);           xmlschemaset set = new xmlschemaset();         set.add(schema);          set.compile();         /* try         {             set.compile();         }         catch (exception ex)         {             messagebox.show(ex.message);         }  */         filestream stream = new filestream(textbox1.text, filemode.open);          xmltextwriter writer = new xmltextwriter(stream, null);         schema.write(writer);         writer.close(); 

try use full name namespace:

res.basetypename = new xmlqualifiedname("string", "http://www.w3.org/2001/xmlschema"); 

see example section on page http://msdn.microsoft.com/en-us/library/1c4sky9s(v=vs.110).aspx


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -