<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>General</title><link>https://www.infopathdev.com:443/forums/41.aspx</link><description>If you're not sure where to ask your question, ask it here. If necessary, our moderators will make sure it gets classified in the correct board.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Problems with xsi:nil</title><link>https://www.infopathdev.com:443/forums/thread/39482.aspx</link><pubDate>Fri, 13 Mar 2009 03:23:36 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:39482</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/39482.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=39482</wfw:commentRss><description>&lt;p&gt;Hello again,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Glad you got it worked out.&amp;nbsp; Your solution seems like a pretty good one and I think cloning the attribute is probably as good as any other approach.&lt;/p&gt;
&lt;p&gt;Just so you know, you can manually create an xsi:nil attribute like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IXMLDOMNode&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; nilAttr = thisXDocument.DOM.createNode(&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;DOMNodeType&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.NODE_ATTRIBUTE&lt;/font&gt;, &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;nil&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;br /&gt;nilAttr.nodeValue = &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;true&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;</description></item><item><title>Re: Problems with xsi:nil</title><link>https://www.infopathdev.com:443/forums/thread/39468.aspx</link><pubDate>Thu, 12 Mar 2009 19:22:38 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:39468</guid><dc:creator>b.harrison</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/39468.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=39468</wfw:commentRss><description>&lt;p&gt;Hi Jimmy,&lt;/p&gt;
&lt;p&gt;Thanks for your response, and sorry for my delayed reply.&amp;nbsp; I&amp;#39;m sure you were eagerly watching and waiting.&amp;nbsp; :)&lt;/p&gt;
&lt;p&gt;The schema does contain nillable=&amp;quot;true&amp;quot; for the elements in question, and all documents and schemas contain that namespace.&amp;nbsp; But your hint about the namespace did help me track down a solution!&lt;/p&gt;
&lt;p&gt;Our form update process obviously needs to be worked on, but currently it works like this:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;When a user opens an xml document, we check the XDocument.Solution.URI with the URI of the most recent form template.&amp;nbsp; If they do not match, we perform the custom upgrade in code.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;We then recursively walk through the new schema and the existing xml document node by node and compare, copying over any existing information.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;To know the structure of the new schema, we are loading sample.xml into an IXMLDOMDocument2&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;In the scenarios when a BOOL, DATE, INT etc was in the schema with no value, the xsi:nil attribute would show up on the old node (from the xml document), but not the new node (from sample.xml).&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;When I tried manually adding an attribute to the new node I would get validation errors, as stated above.&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;What clued me in was that when I created the new attribute, the IXMLDOMNode.namespaceURI was null and not ...XMLSchema-instance as you pointed out.&amp;nbsp; Since this member is read only, I cloned the old attribute and then added it to the new node.&lt;/p&gt;
&lt;p&gt;if (OldNode.attributes.getNamedItem(&amp;quot;xsi:nil&amp;quot;) != null)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IXMLDOMNode xsinil = OldNode.attributes.getNamedItem(&amp;quot;xsi:nil&amp;quot;).cloneNode(true);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; NewNode.attributes.setNamedItem(xsinil);&lt;br /&gt;}&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;This seemed to do the trick!&amp;nbsp; Thanks again for the help and getting me in the right direction.&lt;/p&gt;</description></item><item><title>Re: Problems with xsi:nil</title><link>https://www.infopathdev.com:443/forums/thread/38995.aspx</link><pubDate>Fri, 27 Feb 2009 02:59:05 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:38995</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/38995.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=38995</wfw:commentRss><description>&lt;p&gt;Typically in XML, it is illegal for a field designated as a numerical value in the schema to not have a value.&amp;nbsp; There is no such thing as a &amp;quot;blank&amp;quot; number.&amp;nbsp; InfoPath manages to work around this by using a little trick in the schema:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;nbsp;&amp;lt;xsd:element name=&amp;quot;field1&amp;quot; &lt;strong&gt;nillable=&amp;quot;true&amp;quot;&lt;/strong&gt; type=&amp;quot;xsd:integer&amp;quot;/&amp;gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This means that if the node is given the xsi:nil=&amp;quot;true&amp;quot; attribute in the actual XML, it is allowed to be blank.&lt;/p&gt;
&lt;p&gt;That&amp;#39;s a little background, now as for your actual issue.&amp;nbsp; It is in fact possible to manually add the xsi:nil attribute and have the form pass schema validation, but there are two things to make sure when you do this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;The field can&amp;#39;t be set as &amp;quot;cannot be blank&amp;quot; in InfoPath.&amp;nbsp; That is, it should have nillable=&amp;quot;true&amp;quot; in the schema as above.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;The attribute must have the correct namespace.&amp;nbsp; It is not enough to just add nil=&amp;quot;true&amp;quot; as an attribute or xsi:nil=&amp;quot;true&amp;quot; without specifying the correct namespace.&amp;nbsp; The namespace URI should be &lt;a href="http://www.w3.org/2001/XMLSchema-instance"&gt;http://www.w3.org/2001/XMLSchema-instance&lt;/a&gt;.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Is there perhaps one of these items that is not being satisfied in your code?&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Problems with xsi:nil</title><link>https://www.infopathdev.com:443/forums/thread/38987.aspx</link><pubDate>Thu, 26 Feb 2009 17:52:59 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:38987</guid><dc:creator>b.harrison</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/38987.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=41&amp;PostID=38987</wfw:commentRss><description>&lt;p&gt;My schema contains some nillable fields (integer, datetime, and others mentioned in &lt;a href="http://blogs.msdn.com/infopath/archive/2006/11/28/the-xsi-nil-attribute.aspx"&gt;http://blogs.msdn.com/infopath/archive/2006/11/28/the-xsi-nil-attribute.aspx&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;In my template.xml, these fields contain the attribute xsi:nil=&amp;quot;true&amp;quot;, but the xsi:nil is not present in sampledata.xml.&amp;nbsp; This makes sense becase the arribute is not truly an attribute of my schema (I did not add it via code or in Design).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;However, after I submit a form, the xsi:nil=&amp;quot;true&amp;quot; is present in the raw xml file that is saved.&amp;nbsp; Why is it here if it&amp;#39;s not part of the true schema?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I have custom code that I use to update a file to the new form template.&amp;nbsp; I use sampledata.xml as my template, so xsi:nil is not there.&amp;nbsp; Then, after I update the form, when I try to submit an error is thrown on the date or integer or whatever because a value is expected.&amp;nbsp; So, in my update code, I tried manually adding an xsi:nil attribute to the field, but then I get an error that nil is unexpected according to the schema.&lt;/p&gt;
&lt;p&gt;When I step through the old xml file when it is being uploaded, xsi:nil is treated as an attribute, and is contained in IXMLDOMNode.attributes, so why doesn&amp;#39;t it throw an error under this circumstance?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I guess I am just at a loss on how this &amp;quot;attribute&amp;quot; should be treated.&amp;nbsp; How can it be in the xml and treated exactly like attribute in one scenario but not another?&lt;/p&gt;
&lt;p&gt;Any clarification anyone can give is much appreciated.&amp;nbsp; Thanks!&lt;/p&gt;</description></item></channel></rss>