cloneNode, appendChild Not Working...

  • Thread starter Michael Thompson Isaac
  • Start date
M

Michael Thompson Isaac

I want to add a node (and set its attributes) to a repeating node based on
the blank value of a text box (non-repeating node) on my InfoPath form.

I have a main data source based on a SQL Server schema. Managed C# code is
fired after the OnAfterChange event. Here's a code snippet:

_________________________________________
IXMLDOMNodeList nodeList =
thisXDocument.DOM.selectNodes("/dfs:myFields/dfs:dataFields/d:Blue_Sheets/d:Summary_My_Position_RedFlags_Rpt");
IXMLDOMNode node;
if (nodeList.length == 1) //Either the blank default, or 1 populated red
flag.
{
if (nodeList[0].attributes[2].text=="") //This is the first red flag to
be added -- blank default.
{
nodeList[0].attributes[2].text = sFlagText; //Set the value of the
default, empty red flag.
}
else //The default red flag is alread populated, and this is the second
red flag. Add another.
{
node = nodeList[0].cloneNode(true);
node.attributes[2].text = sFlagText;
nodeList[0].parentNode.appendChild(node);
....
__________________________________________
I can set the value of the default node (if
(nodeList[0].attributes[2].text=="") ) but, when adding a node using the
cloneNode method, I get the following error upon the appendNode:


"System.Runtime.InteropServices.COMException
Element
'{http://schemas.microsoft.com/office/infopath/2003/ado/dataFields}Summary_My_Position_RedFlags_Rpt'
is unexpected according to content model of parent element
'{http://schemas.microsoft.com/office/infopath/2003/ado/dataFields}Blue_Sheets'.
Expecting:
{http://schemas.microsoft.com/office/infopath/2003/ado/dataFields}Best_Action_Plan_Info_Rpt."

Below is the appropriate part (I think!) of my XSD:

<xsd:element name="Summary_My_Position_RedFlags_Rpt">
<xsd:complexType>
<xsd:attribute name="Summary_My_Position_RedFlags_Rpt_ID"
type="d:eek:ptional_long"/>
<xsd:attribute name="Blue_Sheet_ID" type="d:eek:ptional_long"
use="required"/>
<xsd:attribute name="Summary_My_Position_RedFlags" use="optional">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="255"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="Summary_My_Position_RedFlags_Actions"
use="optional">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="255"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:anyAttribute
namespace="http://schemas.microsoft.com/office/infopath/2003/adomapping"
processContents="skip"/>
</xsd:complexType>
</xsd:element>

Your help is VERY appreciated!

MTI
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top