Hi
I'm having a problem where InfoPath kills my working schema mySchema.xsd. I have the following:
<xsd:element name="list">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="my:list-item" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="is-condition-list" type="xsd:string"/>
<xsd:attribute name="type" type="xsd:string"/>
</xsd:complexType>
</xsd:element>
I can easily populate these "lists" attributes easily in code like this:
Dim newListNode As IXMLDOMNode = sectionsNode.ownerDocument.createNode(DOMNodeType.NODE_ELEMENT, "my:list", myNameSpace)
Dim listType As IXMLDOMAttribute = sectionsNode.ownerDocument.createAttribute("my:type")
Dim isConditionList As IXMLDOMAttribute = sectionsNode.ownerDocument.createAttribute("my:is-condition-list")
listType.text = theDeterm.sections(i).list.type
isConditionList.text = theDeterm.sections(i).list.isconditionlist
newListNode.attributes.setNamedItem(listType)
newListNode.attributes.setNamedItem(isConditionList)
Problem is, whenever I save my form Infopath goes and changes my schema to
<xsd:element name="list">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="my:list-item" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute ref="my:is-condition-list"/>
<xsd:attribute ref="my:type"/>
</xsd:complexType>
</xsd:element>
Note the attribute ref's.
I'm not too fussed about that except it breaks my code. Everytime I try to create the attribute and attach it to the node in Managed code (as per above), InfoPath says the attribute doesnt belong.
This is an example (on another schema element).. and Yep I've checked that it exists and is fine.. it works fine before infopath molests it and changes it to ref=
System.Runtime.InteropServices.COMException
The attribute 'heading' on the element '
http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-10-31T06-47-55}section' is not defined in the DTD/Schema.
at Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMNode.appendChild(IXMLDOMNode newChild)
at Microsoft.Office.Interop.InfoPath.SemiTrust.DOMNodeWrapper.appendChild(IXMLDOMNode newChild)
at Microsoft.Office.Interop.InfoPath.SemiTrust.DOMNodeWrapper.appendChild(IXMLDOMNode newChild)
at PlanningDeterminationClient.PlanningDeterminationClient.populateDetermination(PlanningApplicationType thePlanningApp, DeterminationType theDeterm) in C:\Projects\Visual Studio Projects\PlanningDeterminationClient\PlanningDeterminationClient\FormCode.vb:line 294
at PlanningDeterminationClient.PlanningDeterminationClient.btnRetrieve_OnClick(DocActionEvent e) in C:\Projects\Visual Studio Projects\PlanningDeterminationClient\PlanningDeterminationClient\FormCode.vb:line 185
at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)