1. A method for updating an XML document in a computer and validating the update in an incremental fashion with respect to XML schema key and keyref constraints, said method comprising: (i) defining an XML schema comprising key and keyref constraints, wherein each keyref constraint refers to a key constraint in a scoping element, by specifying the key constraint's name; (ii) validating an XML document conforming to the XML schema and comprising a key element and a keyref element in accordance with the key and keyref constraints; (iii) building a data structure for capturing the state of the XML document with respect to key and keyref constraints to enable efficient monitoring as the XML document changes; (iv) specifying an update, including one or more operations, to be made to the XML document; (v) determining based on the data structure, specified update and relevant key or keyref constraints the parts of the XML document that may be affected by said update; (vi) verifying by scanning only the parts of the XML documents determined in step (v) that said update does not violate any key or keyref constraints; and (vii) performing said update only after the verification of (vi) is successful; and (viii) updating the data structure with the update information.