L
Laurie_Marsh
I have a main connection that looks like:
myFields
dataFields
d:COE_Employees
-- some stuff --
Comments
-- some attributes --
QF129
-- some attributes--
both Comments and QF129 are repeating. Here is the template.xml view:
<dfs:dataFields>
<d:COE_Employees EmployeeKey="" Name="">
-- other stuff --
<d:Comments CommentKey="" Engineer="" Date=""
Comment=""></d:Comments>
<d:QF129 Employee="" Date=""></d:QF129>
</d:COE_Employees>
</dfs:dataFields>
After the query is issued, there are no QF129 items in the DOM. During the
lifetime of the form, I want to add them programmatically but cannot use the
cloning method since there aren't any to clone from. Here is the code I have
to create the new node and add it to the DOM:
IXMLDOMNode rootNode = thisXDocument.DOM.selectSingleNode
("/dfs:myFields/dfs:dataFields/d:COE_Employees");
IXMLDOMNode QF129Node = thisXDocument.DOM.createNode(
DOMNodeType.NODE_ELEMENT, "d:QF129",
"http://schemas.microsoft.com/office/infopath/2003/ado/datafields");
IXMLDOMAttribute attr = thisXDocument.DOM.createAttribute
("Employee");
attr.value = rootNode.selectSingleNode("@EmployeeKey").text;
QF129Node.attributes.setNamedItem(attr);
attr = thisXDocument.DOM.createAttribute("Date");
attr.value = thisXDocument.DOM.selectSingleNode
("/dfs:myFields/my:WeekEnding").text;
QF129Node.attributes.setNamedItem(attr);
rootNode.appendChild(QF129Node);
The problem is that the call to appendChild fails with an error saying:
Element
'{http://schemas.microsoft.com/office/infopath/2003/ado/datafields}QF129' is
unexpected according to content model of parent element
'{http://schemas.microsoft.com/office/infopath/2003/ado/dataFields}COE_Employees'.
So, how do I add the first item for a repeating element programmatically?
myFields
dataFields
d:COE_Employees
-- some stuff --
Comments
-- some attributes --
QF129
-- some attributes--
both Comments and QF129 are repeating. Here is the template.xml view:
<dfs:dataFields>
<d:COE_Employees EmployeeKey="" Name="">
-- other stuff --
<d:Comments CommentKey="" Engineer="" Date=""
Comment=""></d:Comments>
<d:QF129 Employee="" Date=""></d:QF129>
</d:COE_Employees>
</dfs:dataFields>
After the query is issued, there are no QF129 items in the DOM. During the
lifetime of the form, I want to add them programmatically but cannot use the
cloning method since there aren't any to clone from. Here is the code I have
to create the new node and add it to the DOM:
IXMLDOMNode rootNode = thisXDocument.DOM.selectSingleNode
("/dfs:myFields/dfs:dataFields/d:COE_Employees");
IXMLDOMNode QF129Node = thisXDocument.DOM.createNode(
DOMNodeType.NODE_ELEMENT, "d:QF129",
"http://schemas.microsoft.com/office/infopath/2003/ado/datafields");
IXMLDOMAttribute attr = thisXDocument.DOM.createAttribute
("Employee");
attr.value = rootNode.selectSingleNode("@EmployeeKey").text;
QF129Node.attributes.setNamedItem(attr);
attr = thisXDocument.DOM.createAttribute("Date");
attr.value = thisXDocument.DOM.selectSingleNode
("/dfs:myFields/my:WeekEnding").text;
QF129Node.attributes.setNamedItem(attr);
rootNode.appendChild(QF129Node);
The problem is that the call to appendChild fails with an error saying:
Element
'{http://schemas.microsoft.com/office/infopath/2003/ado/datafields}QF129' is
unexpected according to content model of parent element
'{http://schemas.microsoft.com/office/infopath/2003/ado/dataFields}COE_Employees'.
So, how do I add the first item for a repeating element programmatically?