Class XMLSchemaReferences (Word VBA)

A collection of XMLSchemaReference objects that represent the unique namespaces that are attached to a document. To use a XMLSchemaReferences class variable it first needs to be instantiated, for example


Dim xmls as XMLSchemaReferences
Set xmls = ActiveDocument.XMLSchemaReferences

For Each

Here is an example of processing the XMLSchemaReferences items in a collection.


Dim xml As XMLSchemaReference
For Each xml In ActiveDocument.XMLSchemaReferences
	
Next xml

Add

Returns an XMLSchemaReference that represents a schema applied to a document.

Add (NamespaceURI, Alias, FileName, InstallForAllUsers)


Sub AddSchema() 
 Dim objSchema As XMLSchemaReference 
 
 Set objSchema = ActiveDocument.XMLSchemaReferences _ 
 .Add(, , "c:\schemas\simplesample.xsd", True) 
End Sub

Arguments

Optional arguments

The following arguments are optional

NamespaceURI (String) - The name of the schema as defined in the schema. The Namespace parameter is case-sensitive and must be spelled exactly as it appears in the schema. If the specified namespace cannot be found in any of the schemas attached to the document, an error is displayed.

Alias (String) - The name of the schema as it appears on the Schemas tab in the Templates and Add-ins dialog box.

FileName (String) - The path and file name of the schema. This may be a local file path, a network path, or an Internet address.

InstallForAllUsers (Boolean) - True if all users that log on to a computer can access and use the new schema. The default is False.

Count

Returns a Long that represents the number of XML schemas in the collection.


Dim lngCount As Long
lngCount = ActiveDocument.XMLSchemaReferences.Count

HideValidationErrors

Returns a Boolean indicating whether Word displays schema validation errors for the current XML document.

True causes Word to hide schema validation errors for the current XML document. False causes schema validation errors to be displayed in the XML Structure task pane.


ActiveDocument.XMLSchemaReferences _ 
 .HideValidationErrors = True

IgnoreMixedContent

Returns a Boolean that represents whether Microsoft Word preforms validation on text nodes that have element siblings and specifies whether these text nodes are saved in XML when the XMLSaveDataOnly property is True.

True causes Word to ignore schema violations caused by text nodes that have element siblings; it also prevents these text nodes from being saved in XML when the XMLSaveDataOnly property is True, which helps to prevent text that was inserted by an Extensible Stylesheet Language Transformation (XLST) from being saved as part of the data. False raises validation errors on text nodes with element siblings.


ActiveDocument.XMLSchemaReferences _ 
 .IgnoreMixedContent = True

Item

Returns an individual XMLSchemaReference object in a collection.

Item (Index)

Index: The individual object to be returned. Can be a Long indicating the ordinal position or a String representing the name of the individual object.


Dim xml As XMLSchemaReference
Set xml = ActiveDocument.XMLSchemaReferences(Index:=1)

ShowPlaceholderText

Returns or sets a Boolean that represents whether automatic placeholder text is displayed for XML elements in a document.

True displays placeholder text. False hides placeholder text.


ActiveDocument.XMLSchemaReferences.ShowPlaceholderText = _ 
 Not ActiveDocument.XMLSchemaReferences.ShowPlaceholderText

Validate

Validates all the XML schemas that are attached to a document.

When you run the Validate method, Microsoft Word populates the XMLSchemaViolations property of the Document object with a collection of the XML nodes that have validation errors.


ActiveDocument.XMLSchemaReferences.Validate