writeAnnotation Method
Writes a top-level annotation or an annotation for an XML Schema <element>
declaration. The following objects can have annotations written to them: IXMLDOMDocument
, IXMLDOMNode
, IVBSAXContentHandler
, and ISAXContentHandler
. Any one of these four object types can be passed in the annotationSink
parameter.
If the object passed in the annotationSink
parameter is an IXMLDOMDocument
(schema) object, the annotation for the item is written to the top-level <annotations>
for the XML Schema. If a top-level annotation exists, an <annotations>
root element is created, and all <annotation>
declarations are located inside it.
For the other three object types, the <annotation>
node of the object that is passed in is considered the root node. The DOMDocument
will have the annotation node appended to the IXMLDOMnode
.
Example
The po.xsd XML Schema that is referred to in these examples can be found in XML Schema Examples.
The following VBScript example shows how to write a top-level schema annotation into a DOM document.
Set oSchemaCache = CreateObject("Msxml2.XMLSchemaCache.5.0") Set oAnnotationDoc = CreateObject("Msxml2.DOMDocument.5.0") oSchemaCache.add "", "po.xsd" Set oSchema = oSchemaCache.getSchema("") oSchema.writeAnnotation(oAnnotationDoc) WScript.Echo oAnnotationDoc.documentElement.xml
The following VBScript example shows how to write an annotation for a schema item into a DOM document.
Set oSchemaCache = CreateObject("Msxml2.XMLSchemaCache.5.0") Set oAnnotationDoc = CreateObject("Msxml2.DOMDocument.5.0") oSchemaCache.add "", "po.xsd" Set oSchema = oSchemaCache.getSchema("") Set ua = oSchema.types.itemByName("USAddress") ua.writeAnnotation(oAnnotationDoc) WScript.Echo oAnnotationDoc.documentElement.xml
Implementation Syntax
var bolIsWritten = oISchemaItem.annotation(oAnnotationSink);
Parameters
- oAnnotationSink
- An object. A pointer to the annotation target object. The following interfaces can be sent:
IXMLDOMDocument
,IXMLDOMNode
,IVBSAXContentHandler
, andISAXContentHandler
.
Return Values
- bolIsWritten
- A Boolean value. True if there is any annotation information for this schema item. False if there are no annotations for this schema item.
Implementation Syntax
bolIsWritten = oISchemaItem.annotation(oAnnotationSink);
Parameters
- oAnnotationSink
- An object. A pointer to the annotation target object. The following interfaces can be sent:
IXMLDOMDocument
,IXMLDOMNode
,IVBSAXContentHandler
, andISAXContentHandler
.
Return Values
- bolIsWritten
- A Boolean value. True if there is any annotation information for this schema item. False if there are no annotations for this schema item.
Implementation Syntax
HRESULT writeAnnotation( IUnknown* annotationSink, VARIANT_BOOL* isWritten );
Parameters
- annotationSink [in]
- A pointer to the annotation target object. The following interfaces can be sent:
IXMLDOMDocument
,IXMLDOMNode
,IVBSAXContentHandler
, andISAXContentHandler
. - isWritten [out, retval]
- A Boolean value. VARIANT_TRUE if there is any annotation information for this schema item. VARIANT_FALSE if there are no annotations for this schema item.
Return Values
- S_OK
- The value returned if successful.
- E_INVALIDARG
- The value returned if the
annotationSink
is not one of the following types:XMLDOMDocument
,IXMLDOMNOde
,IVBSAXContentHandler
, orISAXContentHandler
. - E_POINTER
- The value returned if the
isWritten
parameter is NULL. - E_FAIL
- The value returned if something else is wrong.
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: ISchemaItem Interface