Validating Edited Instances

wxdqz

New Member
I've sucessfully created an .xdr schema and have validated an instanceagainst it. However, it appears that subsequent edits of the instance donot continue to validate against the schema. Is there any way to enforceschema validation upon edits? I would rather not reparse the whole documentupon every edit.-----------------example schema:<Schema xmlns="urn:schemas-microsoft-com:xml-data"xmlns:dt="urn:schemas-microsoft-com:datatypes"><ElementType name="wine" content="empty"><AttributeType name="id" dt:type="int"/><AttributeType name="name" dt:type="string"/><AttributeType name="type" dt:type="enumeration" dt:values="cabernetpinot port merlot"/><attribute type="id"/><attribute type="name"/><attribute type="type"/></ElementType><ElementType name="cellar" content="eltOnly"><element type="wine" minOccurs="0" maxOccurs="*"/></ElementType></Schema>-----------------example instance:<cellar><wine id="12" name="Kendall Jackson" type="port"/></cellar>-----------------example code:Dim xmldoc As MSXML2.DOMDocumentDim xmlSchema As MSXML2.XMLSchemaCacheDim oE As MSXML2.IXMLDOMElementDim strXPath As StringSet xmldoc = New MSXML2.DOMDocumentSet xmlSchema = New MSXML2.XMLSchemaCache' add schema to collectionCall xmlSchema.Add(NAMESPACE, SCHEMA)With xmldocSet .schemas = xmlSchema.async = FalseIf Not .Load(XML_INSTANCE) ThenCall MsgBox("Error parsing:" & vbCrLf & .parseError.reason)End IfstrXPath = "//wine[@id='12']"Set oE = .documentElement.selectSingleNode(strXPath)End With' this is an invalid value according to the allowed values' of the schema defined attibute' but there is no indication of thisCall oE.setAttribute("type", "cranberry")-----------the instance validates fine against the schema when loading, hydrating..parseError if an attribute value violates a datatype definition (includingenumerations). but when the doc is edited there is no way of determiningthe edit violates the schema without loading the whole doc's string into anew doc instance, that I know of. Do you?any help is greatly appreciated~ps. please don't tell me i should be using .xsd instead of .xdr unless youcan show me how ican easily duplicate the .dataType property and .definition property thatallows me to access metadata such as dataTypes, minlength, maxLength,enumerated values, etc. thanks
 
Back
Top