Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
Performs run-time validation on the currently loaded document using the currently loaded document type definition (DTD), schema, or schema collection.
Script Syntax
Copy Code | |
---|---|
objXMLDOMDocument2.validate(); |
Remarks
Script Parameters
None.
Script Return Value
A ParseErrorobject indicating exactly what error occurred, if any.
C/C++ Syntax
Copy Code | |
---|---|
HRESULT validate( IXMLDOMParseError** errorObj ); |
Remarks
C/C++ Parameters
- errorObj
-
[retval, out] IErrorInfocontaining a formatted error message indicating exactly what went wrong and one of the following HRESULTs (also returned in the ErrorInfo.Numberproperty).
C/C++ Return Values
Return value | Hexadecimal value | Description |
---|---|---|
E_PENDING |
0x8000000A |
Document readyState Property (DOMDocument)is not 4, indicating the document is not completely loaded. |
S_OK |
0 |
The document is valid according to DTD or schemas. |
S_FALSE |
1 |
The document is invalid according to DTD or schemas. For error information, see the returned IXMLDOMParseErrorobject. |
The following possible validation errors returned with S_FALSE are listed, together with the errorCodevalue.
Message ID | Error Code (Hex Value) | Message |
---|---|---|
XML_E_NODTD |
0xC00CE224 |
Validate failed because a DTD or schema was not specified in the document. |
XML_E_NOTWF |
0xC00CE223 |
Validate failed because the document does not contain exactly one root node. |
XML_ENTITY_UNDEFINED |
0xC00CE002 |
Reference to undefined entity '%1'. |
XML_INFINITE_ENTITY_LOOP |
0xC00CE003 |
Entity '%1' contains an infinite entity reference loop. |
XML_NDATA_INVALID_PE |
0xC00CE004 |
Cannot use the NDATA keyword in a parameter entity declaration. |
XML_REQUIRED_NDATA |
0xC00CE005 |
Cannot use a general parsed entity '%1' as the value for attribute '%2'. |
XML_NDATA_INVALID_REF |
0xC00CE006 |
Cannot use unparsed entity '%1' in an entity reference. |
XML_EXTENT_IN_ATTR |
0xC00CE007 |
Cannot reference an external general parsed entity '%1' in an attribute value. |
XML_ELEMENT_UNDECLARED |
0xC00CE00D |
The element '%1' is used but not declared in the DTD or schema. |
XML_ELEMENT_ID_NOT_FOUND |
0xC00CE00E |
The attribute '%1' references the ID '%2', which is not defined in the document. |
XML_EMPTY_NOT_ALLOWED |
0xC00CE011 |
Element cannot be empty according to the DTD or schema. |
XML_ELEMENT_NOT_COMPLETE |
0xC00CE012 |
Element content is incomplete according to the DTD or schema. |
XML_ROOT_NAME_MISMATCH |
0xC00CE013 |
The name of the top-most element must match the name of the DOCTYPE declaration. |
XML_INVALID_CONTENT |
0xC00CE014 |
Element content is invalid according to the DTD or schema. |
XML_ATTRIBUTE_NOT_DEFINED |
0xC00CE015 |
The attribute '%1' on this element is not defined in the DTD or schema. |
XML_ATTRIBUTE_FIXED |
0xC00CE016 |
Attribute '%1' has a value that does not match the fixed value defined in the DTD or schema. |
XML_ATTRIBUTE_VALUE |
0xC00CE017 |
Attribute '%1' has an invalid value according to the DTD or schema. |
XML_ILLEGAL_TEXT |
0xC00CE018 |
Text is not allowed in this element according to DTD or schema. |
XML_MULTI_FIXED_VALUES |
0xC00CE019 |
An attribute declaration cannot contain multiple fixed values: '%1'. |
XML_ELEMENT_UNDEFINED |
0xC00CE01C |
Reference to undeclared element: '%1'. |
XML_XMLNS_FIXED |
0xC00CE01E |
Attribute '%1' must be a #FIXED attribute. |
XML_REQUIRED_ATTRIBUTE_MISSING |
0xC00CE020 |
Required attribute '%1' is missing. |
XML_DTD_EXPECTING |
0xC00CE026 |
Expecting: %1. |
XML_E_NODTD |
0xC00CE224 |
Validate failed because a DTD or schema was not specified in the document. |
Requirements
Header | msxml2.h, msxml2.idl |
Library | uuid.lib |
Windows Embedded CE | Windows CE .NET 4.0 and later |
General Remarks
This method only validates fully loaded documents (readyState == 4).
The validatemethod returns IXMLDOMParseErrorthat is independent of the value returned by the parseErrorproperty on a document. Only the errorCodeand reasonproperties of the returned value are set.
Unlike load, validatewill fail if there is no DTD or schema applied to the document element. Therefore, validatewill not be able tell you whether the document is just well-formed.
The validatemethod does not parse new schemas, but can import a schema from a SchemaCacheassociated with the document through the schemasproperty. If there is no schema for a given namespace, the elements in that namespace will not be validated.
This method applies to the following interface: