The following are some frequently asked questions about the SOM.
You obtain a schema object from a schema cache. The schema cache is created with the IXMLDOMSchemaCollection2 interface. For more information, see Loading a Schema for Use with the ISchema Interface, and the ISchema interface reference topic.
The schema cache is an object created with the IXMLDOMSchemaCollection2 interface. The schema cache stores XML Schema documents according to an associated target namespace. The target namespace must be unique for each XML Schema in the cache.
The schema cache was designed to support two types of use. First, it was designed to improve performance through schema caching. This can significantly reduce the overhead when using external schemas for validation. Secondly, it can be used to override schemas referenced or included inline.
The SOM uses the XML Schema definition language (XSD) as its schema platform. The W3C recommendation for the XML Schema is found at http://www.w3.org/2001/XMLSchema#intro. This recommendation includes a link to http://www.w3.org/2001/XMLSchema.xsd, the XML Schema that is used to validate XML Schema elements, attributes, and data types.
The SOM conforms to the W3C specifications, which are available at the Web site www.w3.org/TR/xmlschema-0/. SOM interfaces are created from the schema component definitions. For an example of the definitions for an element, see the specifications document, at URL http://www.w3.org/TR/xmlschema-1/#Element_Declaration_details.
The rest of the definitions can be found throughout the specifications document.
The DOM has two methods that return a schema object. The first is the getDeclaration method of the IXMLDOMSchemaCollection2 interface. The second is the getSchema method of the IXMLDOMSchemaCollection2 interface. For more information, see Using the DOM with the SOM.
SAX has two functions that return a schema object. The first is the schemaElementDecl method of the IMXSchemaDeclHandler interface. The second is the getTypeFromName method of the ISAXAttributes interface. For more information, see Using SAX with the SOM.
An item collection is used throughout the SOM for object storage. Many of the interface functions return item collections that contain an array of specific or mixed objects. The item collection is indexed, and begins with the index of zero. The objects returned in the collection implement their specified interface when they are queried individually. Use the itemType property of the ISchemaItem interface to get the type of the items in the collection.
ISchema Item Collection Interface
Yes, the SOM does support the multi-thread apartment model. You can marshal between rental mode and free threaded model in your application.
Note In MSXML, "free-threaded" means ThreadingModel='Both'
, and cross-thread marshalling is supported.
In MSXML 4.0 Beta 2, the getDeclaration
method was called using an XMLSchemaCache
object. Because of some inconsistencies related to this design, the getDeclaration
call was changed for MSXML 4.0 final release.
The following Visual Basic example shows the syntax used in MSXML 4.0 Beta 2 to make the getDeclaration
method call.
set oSchemaCache = CreateObject("Msxml2.XMLSchemaCache.5.0") nsTarget="http://www.example.microsoft.com/po" oSchemaCache.add nsTarget, "po.xsd" set oDoc = CreateObject("Msxml2.DOMDocument.5.0") oDoc.async = false oDoc.load "po.xml" oDoc.setProperty "SelectionLanguage", "XPath" Set oDecl = oSchemaCache.getDeclaration(oNode)
In this design, the appropriate schema was only looked for using the XMLSchemaCache
object, ignoring the possibility that the information returned might not have any relationship to the actual schema information used in document validation or default attribute lookup.
For the final 4.0 release and later versions, the getDeclaration
method has been changed in the following ways:
XMLSchemaCache
object, the getDeclaration
method will now return a result of "E_NOTIMPL", indicating it is not implemented.getDeclaration
method is still part of the IXMLDOMSchemaCollection2
interface, but will return "E_NOTIMPL" when called from the IXMLDOMSchemaCollection
interface.getDeclaration
method is now implemented through the namespaces
property of the DOMDocument2
object. getDeclaration
method has also been modified to include the declarations of XML schemas used by the associated document. This provides access to XML schemas loaded using xsi:schemaLocation
, as well as XML schemas loaded from a schema cache object.The following modified example contains the syntax used to get a declaration in MSXML 5.0.
set oDoc = CreateObject("Msxml2.DOMDocument.5.0") oDoc.async = false oDoc.load "po.xml" ' Retrieve the declaration for country attribute of the shipTo element. Set oDecl = oDoc.namespaces.getDeclaration(oDoc.documentElement) WScript.Echo oDecl.namespaceURI