Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

maxOccurs 1

Status
Not open for further replies.

sunaj

Technical User
Feb 13, 2001
1,474
DK
Hi,

Why does this not work?
-------------------------------------
<?xml version=&quot;1.0&quot;?>
<xs:schema xmlns:xs=&quot; targetNamespace = &quot;test&quot; elementFormDefault = &quot;qualified&quot;>
<xs:element name=&quot;datafile&quot;></xs:element>
<xs:element name=&quot;hi&quot; maxOccurs=&quot;unbounded&quot;/>
</xs:schema>
-------------------------------------
But if I leave out the 'maxOccurs=&quot;unbounded&quot;' it works fine.

I am validating a xml file against the scheme using the validateOnParse property of the MSXML2.DOMDocument.4.0 object. the returned error says that the root element is not defined (which it is) - so that is not very informative...

Any help appreciated Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
This will produce an XML file with multiple root nodes. You'll need to nest your &quot;hi&quot; element within the &quot;datafile&quot; element, or encapsulate both of them in another element:
Code:
<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<xs:schema xmlns:xs=&quot;[URL unfurl="true"]http://www.w3.org/2001/XMLSchema&quot;[/URL] elementFormDefault=&quot;qualified&quot; attributeFormDefault=&quot;unqualified&quot;>
	<xs:element name=&quot;ROOT_ELEMENT&quot;>
		<xs:complexType>
			<xs:sequence>
				<xs:element name=&quot;datafile&quot;/>
				<xs:element name=&quot;hi&quot; maxOccurs=&quot;unbounded&quot;/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
</xs:schema>
Chip H.
 
Of course...
Thx Chiph - I must be growing blind... Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top