Inexplicable schema validation error - InfoPath Dev
in

InfoPath Dev

Inexplicable schema validation error

Last post 07-11-2014 12:38 AM by Trevor Arter. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 07-08-2014 04:26 AM

    Inexplicable schema validation error

    Hi experts

    This problem has me stumped, any help would be greatly appreciated.

    I am creating XML documents using C# code (behind an InfoPath 2007 form), which are uploaded to a SharePoint 2007 document library where they will be edited using another InfoPath form.

    This method has been working fine before.

    The schema for the documents is defined in InfoPath, the part which is causing the problem looks like this (image attached)

     Below is an excerpt from the  myschema.xsd file

    <xsd:element name="LicensePriceInfo">

    <xsd:complexType>

    <xsd:sequence>

    <xsd:element ref="my:LicensePriceTotal" minOccurs="0"/>

    <xsd:element ref="my:Currency" minOccurs="0"/>

    <xsd:element ref="my:InterCompanyDiscount" minOccurs="0"/>

    <xsd:element ref="my:LicencePriceTotalListEUR" minOccurs="0"/>

    <xsd:element ref="my:LicensePriceTotalListUSD" minOccurs="0"/>

    <xsd:element ref="my:LicencePriceTotalNetEUR" minOccurs="0"/>

    <xsd:element ref="my:LicencePriceTotalNetUSD" minOccurs="0"/>

    <xsd:element ref="my:LicensePriceTotalNet" minOccurs="0"/>

    </xsd:sequence>

    </xsd:complexType>

    </xsd:element>

    <xsd:element name="LicensePriceTotal" nillable="true" type="xsd:double"/>

    <xsd:element name="Currency" type="xsd:string"/>

    <xsd:element name="InterCompanyDiscount" nillable="true" type="xsd:integer"/>

    <xsd:element name="LicencePriceTotalListEUR" nillable="true" type="xsd:double"/>

    <xsd:element name="LicensePriceTotalListUSD" nillable="true" type="xsd:double"/>

    <xsd:element name="LicencePriceTotalNetEUR" nillable="true" type="xsd:double"/>

    <xsd:element name="LicencePriceTotalNetUSD" nillable="true" type="xsd:double"/>

    <xsd:element name="LicensePriceTotalNet" nillable="true" type="xsd:double"/>

    <xsd:element name="CurrentLicenseDetails">

     

     There are 2 fields for prices in USD and EUR, defined identically as below:

    LicencePriceTotalListEUR (Field)

    Namespace: http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-06-24T14:26:57
    Minimum occurrences: 0
    Maximum occurrences: 1
    Data type: double
    Default value: [none]


    LicensePriceTotalListUSD (Field)

    Namespace: http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-06-24T14:26:57
    Minimum occurrences: 0
    Maximum occurrences: 1
    Data type: double
    Default value: [none]

    The code which creates them is below:

    //Create an XML doc

    doc = new XmlDocument();

    //Create the declaration

    XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);

    doc.AppendChild(dec);

     

    //Create the processing instrucations - InfoPath

    XmlProcessingInstruction pi = doc.CreateProcessingInstruction(

    "mso-infoPathSolution", "href=\"http://cph-sps-dev02/sites/ASbuiltV4-0-Test/FormSource/PXP.xsn\" " +

    "PIVersion = \"1.0.0.0\" " +

    "name=\"urn:schemas-microsoft-com:office:infopath:PXP:-myXSD-2013-06-24T14-26-57\" " +

    "solutionVersion = \"1.0.0.2262\" " +"productVersion = \"12.0.0\" ");

    doc.AppendChild(pi);

    //create the processing instruction mso-application

    pi = doc.CreateProcessingInstruction(

    "mso-application","progid=\"InfoPath.Document\" versionProgid=\"InfoPath.Document.2\"");

    doc.AppendChild(pi);

     

    XmlElement elem;

    XmlElement ChildElem;

    elem = doc.CreateElement("my", "LicensePriceInfo", xns);

    //....

    try

    {

    ChildElem = doc.CreateElement(
    "my", "LicencePriceTotalListEUR", xns);
    ChildElem.InnerText = "0";

    elem.AppendChild(ChildElem);

    }

    catch { }

    try

    {

    ChildElem = doc.CreateElement(
    "my", "LicencePriceTotalListUSD", xns);ChildElem.InnerText = "0";

    elem.AppendChild(ChildElem);

    }

    catch { }

    //add the group to the document element

    doc.DocumentElement.AppendChild(elem);

    //upload to SharePoint....

     

    This works fine, but when I try to open the newly created document in the InfoPath form, I get a validation error, apparently caused by the LicensePriceTotalListUSD field:

    "Info Path cannot open the file...schema validation error..

    Details:

    Element '{http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-06-24T14:26:57}LicencePriceTotalListUSD' is unexpected according to content model of parent element '{http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-06-24T14:26:57}LicensePriceInfo'.
    Expecting: {http://schemas.microsoft.com/office/infopath/2003/myXSD/2013-06-24T14:26:57}LicensePriceTotalListUSD, {http://schemas.micro....

     The names of the expected and actual elements are the same.

    The LicensePriceTotalListEUR field which is identical except for the name, gives no error

    The only clue is that according to the error details, the LicensePriceTotalListUSD schema definition appears to be expecting a namespace definition, but it was defined in the schema and created in the code using the same namespace as the the LicensePriceTotalListEUR field, which gives no error.

     

    Does anybody have any clue to help me find out what's going wrong here?

     

    Thanks

    Trevor


  • 07-11-2014 12:38 AM In reply to

    Re: Inexplicable schema validation error

    If anyone is interested I never found the cause of this, but I deleted the problem node from the main data source and re-created it again with exactly the same name and properties and then it worked

Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.