I am attempting to "Generate Sample XML" in Visual Studio 2012 (via XML Schema Designer, Content View) from the XML Schema (.xsd) below but am getting the following error
StartIndex cannot be less than zero. Parameter name: startIndex
The error results from a maxLength="1" restriction on an element included in a 3-level nested list.
root
Level 0 List
Level 1 List
Level 2 List
Level 2 Item Element (maxLength=1)
If I change maxLength to 2 or greater the error goes away, or if I remove a list level the error goes away. (If I instead push the maxLength=1 item to a deeper level list, the error still occurs.)
Any idea what I might be doing wrong? Is there a schema concept I am missing? Or, is it possible it is a VS 2012 bug?
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Test"
targetNamespace="http://tempuri.org/Test.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/Test.xsd"
xmlns:mstns="http://tempuri.org/Test.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="level0List">
<xs:complexType>
<xs:sequence>
<xs:element name="level0Item" type="level0Item" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="level0Item">
<xs:sequence>
<xs:element name="level1List">
<xs:complexType>
<xs:sequence>
<xs:element name="level1Item" type="level1Item" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="level1Item">
<xs:sequence>
<xs:element name="level2List">
<xs:complexType>
<xs:sequence>
<xs:element name="level2Item" type="level2Item" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="level2Item">
<xs:sequence>
<xs:element name="level2Element">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="1" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
The Saxon schema processor reports no errors for this document. It looks fine to me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With