C# XmlDocument is not being updated with respective XSD default attributes

Sirius

New Member
heres a example from a xsd and a xmlXML\[code\]<?xml version="1.0" encoding="UTF-8"?><config test2="true"></config>\[/code\]XSD\[code\]<?xml version="1.0" encoding="utf-8"?> <xs:schema targetNamespace="rules.xsd" xmlns="rules.xsd" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop"> <xs:element name="config"> <xs:complexType> <xs:attribute name="test1" type="xs:boolean" default="false" /> <xs:attribute name="test2" type="xs:string" default="mary123" /> </xs:complexType> </xs:element></xs:schema>\[/code\]I can use this xsd to validate this xml in C# using this block of code\[code\]XmlDocument doc = new XmlDocument();XmlTextReader schemaReader = new XmlTextReader(System.IO.Path.GetFullPath("Mi_XSD_here.xsd"));XmlSchema schema = XmlSchema.Read(schemaReader, ValidationCallBack);doc.Schemas.Add(schema);doc.Load("Mi_XML_here.xml");doc.Validate(ValidationCallBack);\[/code\]the problem is: I have two default attributes in xsd, but when i run this code he dont insert the attributes in XmlDocument, the result is the same xml that i passed to the system. The default attributes are not working and i cant figure why they arent working, i do belive that exists other forms to solve this problem, i did find this but didnt workedExtensions.Validate Methodobs: ValidationCallBack is some return on error function that i think isnt related to the problema
 
Back
Top