Manifest xsf Schema validation error - InfoPath Dev
in

InfoPath Dev

Manifest xsf Schema validation error

Last post 03-14-2012 09:43 PM by kannabirank. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 03-14-2012 09:43 PM

    Manifest xsf Schema validation error

    Form template: C:\Users\Administrator\AppData\Local\Temp\v4tyi4yi.gfk.xsn The form definition (.xsf) file cannot be opened because of an error. The file cannot be validated by the XML Schema. Text is not allowed in the context of element '{http://schemas.microsoft.com/office/infopath/2003/solutionDefinition}property' according to DTD/Schema. Line 12, Position 140 -------------------------------------------------------------------------------------------------------------------------------------------^

    I'm trying to upload a admin approved infopath template to central admin programmatically... And before uploading to central admin i'm modifying the internal file name to a unique name (like appending the version of the file) so that files are unique in form templates in central admin. Below is the partial C# code.

    XmlNamespaceManager nameSpaceManager = new XmlNamespaceManager(xdocManifest.NameTable);
                nameSpaceManager.AddNamespace("xsf", "http://schemas.microsoft.com/office/infopath/2003/solutionDefinition");

                XmlNode node = xdocManifest.SelectSingleNode("//xsf:xDocumentClass", nameSpaceManager);
                //Since we append version number as underscores to the XSN files, we should convert underscores to hypens(that's how infopath does internally)
                templateNameWithNewVersion = templateNameWithNewVersion.Replace("_", "-");
                node.Attributes["name"].Value = string.Format("urn:schemas-microsoft-com:office:infopath:{0}:-myXSD-2010-08-08T23-16-43", templateNameWithNewVersion); //node.Attributes["name"].Value.Replace(parentTemplateName.Replace("_","-"), templateNameWithNewVersion);
                xdocManifest.Save(string.Format("{0}\\manifest.xsf", @newFolder));

                //Update template.xml file
                XmlDocument xdocTemplateFile = new XmlDocument();
                using (Stream stream = File.Open(string.Format("{0}\\template.xml", @newFolder), FileMode.Open))
                {
                    xdocTemplateFile.Load(stream);
                }
               
                XmlProcessingInstruction processInstruction = xdocTemplateFile.SelectSingleNode("processing-instruction('mso-infoPathSolution')") as XmlProcessingInstruction;
               
                //read the name attribute from this xmlnode <?mso-infoPathSolution name="urn:schemas-microsoft-com:office:infopath:EF001:-myXSD-2010-08-08T23-16-43" solutionVersion="1.0.0.535" productVersion="14.0.0" PIVersion="1.0.0.0" ?>
                //name attribute should be at position 0
                string psuedoAttributesNameTag = processInstruction.Data.Split(' ')[0];

                string templateFileContent = xdocTemplateFile.OuterXml.Replace(psuedoAttributesNameTag, string.Format("name=\"urn:schemas-microsoft-com:office:infopath:{0}:-myXSD-2010-08-08T23-16-43\"", templateNameWithNewVersion));

                File.WriteAllText(string.Format("{0}\\template.xml", @newFolder), templateFileContent); 

     ----------------------

    Form template: C:\Users\Administrator\AppData\Local\Temp\v4tyi4yi.gfk.xsn The form definition (.xsf) file cannot be opened because of an error. The file cannot be validated by the XML Schema. Text is not allowed in the context of element '{http://schemas.microsoft.com/office/infopath/2003/solutionDefinition}property' according to DTD/Schema. Line 12, Position 140 -------------------------------------------------------------------------------------------------------------------------------------------^

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