.net - The 'ref' attribute cannot be present. validation error in C# -


i did xml xsd validation according following method: xml validation using xsd schema

 .......................................................  xmlreadersettings settings = new xmlreadersettings();  settings.schemas.add(null, xsdfilepath);  settings.validationtype = validationtype.schema;  settings.validationeventhandler += new system.xml.schema.validationeventhandler(settings_validationeventhandler);  xmldocument document = new xmldocument();  document.load(xmlfilepath);  xmlreader rdr = xmlreader.create(new stringreader(document.innerxml), settings);   while (rdr.read())  {   }  ........................................................... 

and gives me error saying: "the 'ref' attribute cannot present"

my xsd looks :

........... <xs:element name="totals" minoccurs="0" ref="doctotal"/> ..................................  <xs:element name="doctotal">     <xs:complextype>         <xs:sequence>             <xs:element name="totalqty" minoccurs="0" type="xs:decimal"/>             <xs:element name="totaltax" minoccurs="0" type="xs:decimal"/>         </xs:sequence>         <xs:attribute name="id" type="xs:string" use="required"/>     </xs:complextype> </xs:element> 

and xml looks like:

<totals>     <totalqty>800</totalqty>     <totaltax>0.00<totaltax> </totals> 

i believe error occurs because of both "name" , "ref": attributes exists in same elements: think not wrong in xsd(appreciate comments on this): in case there way validate xsd xml:

it looks me doctotal ought type, not element:

<xs:element name="totals" minoccurs="0" type="doctotal"/> ..................................  <xs:complextype name="doctotal">     <xs:sequence>       <xs:element name="totalqty" minoccurs="0" type="xs:decimal"/>       <xs:element name="totaltax" minoccurs="0" type="xs:decimal"/>     </xs:sequence>     <xs:attribute name="id" type="xs:string" use="required"/> </xs:complextype> 

if want define structure of element somewhere (but not name), , reference elsewhere, should type.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -