Question

I'm writing down some XSD file for webservice communication between an application and sharepoint.. I'm trying to make my parameters "REQUIRED" but even if i put minOccurs to 1, they could be not specified..

How can i resolve this problem? Here's one of mine XSD:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="RemoveGroup"
targetNamespace="http://tempuri.org/RemoveGroup.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/RemoveGroup.xsd"
xmlns:mstns="http://tempuri.org/RemoveGroup.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:element name="RemoveGroup">
<xs:complexType>
  <xs:sequence>
    <xs:element name="tt_group_id" type="xs:long" />
    <xs:element name="tt_network_id" type="xs:string"/>
  </xs:sequence>
  </xs:complexType>
 </xs:element>
 </xs:schema>

I hope there's a way not to write down houndred of "if (input.Parameter != null)" ...

Was it helpful?

Solution

Using minOccurs="1" at either the <element/> or <sequence/> level is the correct thing to do. What specific error are you getting?

UPDATE

Actually within a <sequence/> parsers should expect exactly one instance of an element

UPDATE

Your parser may be emitting errors as events which you need to handle in order to capture the errors - many common parsers have this behaviour.

Something which could cause an error is a null value in the long simple type - this type does not allow blanks. If you want to indicate that nulls are allowed you should use nil=true from namespace http://www.w3.org/2001/XMLSchema-instance.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top