schemaElementDecl Method
Receives the ISchemaElement
object for each new element type that is declared and used in the document.
For example, suppose that an XSD schema document declares various element types, including the element type <book>
. You configure the SAX reader to register and use this schema when it validates additional documents. As the reader parses the other documents, this method will fire the first time the <book>
element appears in each document that is passed as input to the reader.
The same is true of other element types that are declared in the schema and used in a document parsed by the SAX reader.
Implementation Syntax
Sub schemaElementDecl(By Val oSchemaElement As MSXML2.ISchemaElement)
Parameters
- oSchemaElement
- The
ISchemaElement
object for the element being parsed.
Return Values
If failed, the schemaElementDecl
method raises a trappable error.
Syntax
HRESULT schemaElementDecl( [in] ISchemaElement* pSchemaElement);
Parameters
- ISchemaElement [in]
- The
ISchemaElement
object for the element being parsed.
Return Values
- S_OK
- The value returned if the
ISchemaElement
object for the element being parsed is returned successfully. - E_INVALIDARG
- The value returned if the argument provided is invalid.
Remarks
The SAX validator feature throws this event immediately prior to the startElement
event for the current element being parsed. When this method succeeds, it returns an ISchemaElement
object. This object remains valid until the end of the corresponding startElement
event. Accessing this information at any other time produces undefined results.
You can obtain attribute type information by getting the Type
object from the returned ISchemaElement
object and iterating through it for attribute declarations. For an example, see the Walk the SOM sample application.
Exceptional validation errors might sometimes occur during parsing. For example, suppose that you enable the exhaustive-errors
feature on the SAX reader. In this situation, an exceptional error is reported if the schema used to validate the document does not contain a type that corresponds to the current element. If this is the case, the schemaElementDecl
event handler still fires, but it points to an empty element type. When you write your handler procedure, you need to include code to handle this error. For an idea of how to handle element content types, see the Locate Declarations example in the SOM documentation.
To view reference information for Visual Basic or C/C++ only, click the Language Filter button in the upper-left corner of the page.
See Also
Applies to: IMXSchemaDeclHandler Interface