Startindex cannot be less than zero when trying to create a sample xml file from a xsd file RRS feed

  • Question

  • Using Visual studio pro 2015

    I have a xsd file and need to generate a xml sample file from it.
    Ive opened the file with the XML editor. When i Try to "Generate Sample XML", I'm met with the following:

    Have anyone experienced this?

    Any hints or tips on how to find the fault are welcome!



    Tuesday, June 28, 2016 1:34 PM

All replies

  • Hi Bjørn,

    Please provide your XSD file to reproduce the issue.

    Tuesday, June 28, 2016 1:44 PM
  • Hi Yitzhak and Bjorn,

    Sorry to come in between this discussion, but I experience the same issue. The XSD is provided by a third party, so I have no influence on it's content. I send an example of the XSD from which I receive this same error message when trying to build sample XML from the root element

      example of XSD

    Looking forward to any / your reaction!

    "Every misfortune is a new challenge"

    Thursday, July 7, 2016 6:43 AM
  • Hi WAyPoint7,

    I found another way to generate an xml file based on the Xsd, using xmlspy. Very easy to use.

    in xmlspy, open your xsd file. From top menu click DTD/Schema - Generate Sample XML/JSON File..

    There's a free 30day trial on the



    Thursday, July 7, 2016 10:06 AM
  • Hi Bjorn,

    Thanks for your reaction. I knew this, but I love to use Visual Studio whenever possible. I know that there is a free trial period for XMLSpy, but I'm convinced that I will need it in the future, after the trial period.

    Besides: There must be a way yo get this running, other XSD's produce sample XML files without hesitation. So... still waiting for a REAL solution, not just figting the symptoms (no offence! :-))

    "Every misfortune is a new challenge"

    Thursday, July 7, 2016 10:29 AM
  • Oki, lets see if we get a response.
    Thursday, July 7, 2016 10:46 AM
  • Hi WAyPoint7,

    Thanks for providing your AW33.xsd file.

    I wanted to validate it in Stylus Studio, but couldn't do it.

    The AW33.xsd has an import statement.

    <xs:import namespace="" schemaLocation="basisschema.xsd"/>

    Without the basisschema.xsd file it is impossible to validate your main XSD.

    Please provide the basisschema.xsd file.

    Also, it is possible that VS2015 cannot handle xs:import statement.

    I am getting the following error in VS2015 while trying to "Generate Sample XML":

    Microsoft Visual Studio
    Imported schema for namespace '' was not resolved.

    Thursday, July 7, 2016 12:52 PM
  • Hi Yitzak,

    Thanks for taking the trouble to see what's happening here. I doubt if the cause is in VS, as I have comparable XSD's that use the same besisschema.xsd and they render sample XML files flawlessly.

    Here's the link to the requested XSD. I have this xsd in the same folder as the other xsd files. If the reference to other (imported) namespaces would be the cause of this, what would be the correct syntax to enclose that into an XSD?


    "Every misfortune is a new challenge"

    Thursday, July 7, 2016 2:08 PM
  • Hi WAyPoint7,

    Thanks for providing your Basisschema.xsd file.

    The Stylus Studio validates both files without any problem by using the Saxonica validator.

    Here is what Saxon reports:

    Running custom validation engine Saxonica Validator...
    Saxonica validation complete.

    Also, I was able to reproduce the error in the VS2015 Enterprise edition Update 2.

    Microsoft Visual Studio
    StartIndex cannot be less than zero.
    Parameter name: startIndex

    So it looks like a VS2015 bug.

    Friday, July 8, 2016 2:20 PM
  • Thanks Yitzhak,

    In het mean time I have posted this on a MS / XML forum, hopefully it will yield some positive results. Anyway, I am grateful that you have invested some time in this issue. Eventhough it does not help me further. I have some extra assurance that I'm not completely mad or mistaken... :-)

    "Every misfortune is a new challenge"

    Friday, July 8, 2016 5:10 PM
  • I ran in to this issue, which turned out to be caused by an xsd:union in the schema. When I removed that it worked. Not much help of course if you don't control the schema or there is no way around it. Still definitely a VS 2015 bug.

    I did a similar analysis on your schemas and found the culprit is

      <xs:simpleType name="LDT_Huisletter">
          <xs:documentation>Een alfabetisch teken achter het huisnummer zoals dit door het gemeentebestuur is toegekend.</xs:documentation>
        <xs:restriction base="xs:string">
          <xs:maxLength value="1"/>

    It seems that if you change maxLength to 2 it is ok. Very strange.

    Tuesday, January 10, 2017 11:38 AM
  • I'm grateful for your precise poiting out where the problem is. I will be a VS bug, but unfortunately both the XSD and VS are out of my control to have them changed.

    Now that this is the most likely explanation, the stranger the error message is: "Startindex canot be less than zero" AFAIK 1 is not less than 0 :-)

    Thanks anyhow for your time!


    "Every misfortune is a new challenge"

    Tuesday, January 10, 2017 12:12 PM
  • This issue is reproducible with VS 2017 using the IDOC schema files generated by SAP (specifically reproduced with ORDERS05) -> SAP Logon GUI, T-code WE60 for IDoc documentation, generate XML schema from the menu.

    Senior Soft. Dev. Eng. | Microsoft IT | Microsoft Corporation

    Friday, June 14, 2019 11:49 PM