Share via


maxOccurs Property1

 

[This feature was only implemented for MSXML 6.0.]

Returns a variant of type VT_BSTR that indicates the maximum number of times an item can occur in the current context of a document. If MaxOccurs returns 0, the schema item should not appear. If maxOccurs returns UNBOUNDED(-1), the number of appearances of the schema item is unlimited.

The maximum value for this property is 4294967296 (2^32).

Example

The following is an example of the maxOccurs attribute used in a schema.

<schema xmlns="http://www.w3.org/2001/XMLSchema">
   <complexType name="someelement">
      <choice>
         <element name="book" minOccurs="1" maxOccurs="4"/>
         <element name="magazine" minOccurs="1" maxOccurs="1"/>
      </choice>
   </complexType>
</schema>

JScript Syntax

var varMaxOccurs = oISchemaParticle.maxOccurs;  

Parameters

None.

Return Values

varMaxOccurs
A variant. The maximum number of times this item can appear in an instance document of this XML Schema document. If the maxOccurs property is unbounded (-1), there is no limit to the number of occurrences.

Example

The following snippet is taken from the Walk the SOM sample application. In this snippet, the maxOccurs property is retrieved from the ISchemaParticle object.

If oParticle.maxOccurs <> 1 Then 
            If oParticle.maxOccurs = -1 Then 
                res = res + " maxOccurs='unbounded'"
            Else
                res = res + " maxOccurs='" & oParticle.maxOccurs & "'"
            End If

Visual Basic Syntax

varMaxOccurs = oISchemaParticle.maxOccurs  

Parameters

None.

Return Values

varMaxOccurs
A variant. The maximum number of times this item can appear in an instance document of this XML Schema document. If the maxOccurs property is unbounded (-1), there is no limit to the number of occurrences.

C/C++ Syntax

HRESULT get_maxOccurs(VARIANT* maxOccurs);  

Parameters

maxOccurs[out,retval]
A variant. The maximum number of times this item can occur in an instance document of this XML Schema document.

Return Values

S_OK
The value returned if successful.

E_POINTER
The value returned if the maxOccurs parameter is NULL.

Versioning

Implemented in: MSXML 6.0

Applies to

ISchemaParticle Interface

See Also

minOccurs Property1
element Element