A
Aldrin Leal
Hello,
I'm having some trouble when using InfoPath with managed Code. It's
meant to add a revision history entry to a Purchase Order document.
My code is written this way:
[InfoPathEventHandler(MatchPath="btnSubmit",
EventType=InfoPathEventType.OnClick)]
public void btnSubmit_OnClick(DocActionEvent e) {
String thisDocNSURI =
@"http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-04-09T02-30-31";
if (this.document.IsDirty) {
if (XdConfirmChoice.xdYes == this.document.UI.Confirm("Deseja
publicar sua revisão?", XdConfirmButtons.xdYesNo)) {
IXMLDOMNode rootHistóricos =
this.document.DOM.selectSingleNode("/my
edido/my:HistóricoRevisões");
if (null == rootHistóricos) {
IXMLDOMNode parentNode =
this.document.DOM.selectSingleNode("/my
edido");
IXMLDOMNode newElement =
this.document.DOM.createNode(DOMNodeType.NODE_ELEMENT,
"my:HistóricoRevisões", thisDocNSURI);
rootHistóricos = parentNode.appendChild(newElement);
}
IXMLDOMNode newHistórico =
this.document.DOM.createNode(DOMNodeType.NODE_ELEMENT,
"my:HistóricoRevisão", thisDocNSURI);
int numRevisão = 1;
if (null != rootHistóricos.childNodes)
numRevisão += rootHistóricos.childNodes.length;
IXMLDOMAttribute curAttribute = null;
curAttribute = (IXMLDOMAttribute)
this.document.DOM.createNode(DOMNodeType.NODE_ATTRIBUTE,
"my:NúmeroRevisão", thisDocNSURI);
curAttribute.value = numRevisão;
((IXMLDOMElement)
newHistórico).setAttributeNode(curAttribute);
curAttribute = (IXMLDOMAttribute)
this.document.DOM.createNode(DOMNodeType.NODE_ATTRIBUTE,
"my
ataRevisão", thisDocNSURI);
curAttribute.value = System.DateTime.UtcNow;
((IXMLDOMElement)
newHistórico).setAttributeNode(curAttribute);
curAttribute = (IXMLDOMAttribute)
this.document.DOM.createNode(DOMNodeType.NODE_ATTRIBUTE,
"my:ResponsávelRevisão", thisDocNSURI);
curAttribute.value = System.Environment.UserName;
((IXMLDOMElement)
newHistórico).setAttributeNode(curAttribute);
this.document.UI.Alert(rootHistóricos.xml);
this.document.UI.Alert(newHistórico.xml);
rootHistóricos.appendChild(newHistórico);
this.document.Save();
}
}
Whenever i reach the last appendChild call, i get this exception:
System.Runtime.InteropServices.COMException
The attribute
'{http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-04-09T02-30-31}ResponsávelRevisão'
on the element
'{http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-04-09T02-30-31}HistóricoRevisão'
is not defined in the DTD/Schema.
Tips are welcome![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
-- Aldrin Leal
I'm having some trouble when using InfoPath with managed Code. It's
meant to add a revision history entry to a Purchase Order document.
My code is written this way:
[InfoPathEventHandler(MatchPath="btnSubmit",
EventType=InfoPathEventType.OnClick)]
public void btnSubmit_OnClick(DocActionEvent e) {
String thisDocNSURI =
@"http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-04-09T02-30-31";
if (this.document.IsDirty) {
if (XdConfirmChoice.xdYes == this.document.UI.Confirm("Deseja
publicar sua revisão?", XdConfirmButtons.xdYesNo)) {
IXMLDOMNode rootHistóricos =
this.document.DOM.selectSingleNode("/my
if (null == rootHistóricos) {
IXMLDOMNode parentNode =
this.document.DOM.selectSingleNode("/my
IXMLDOMNode newElement =
this.document.DOM.createNode(DOMNodeType.NODE_ELEMENT,
"my:HistóricoRevisões", thisDocNSURI);
rootHistóricos = parentNode.appendChild(newElement);
}
IXMLDOMNode newHistórico =
this.document.DOM.createNode(DOMNodeType.NODE_ELEMENT,
"my:HistóricoRevisão", thisDocNSURI);
int numRevisão = 1;
if (null != rootHistóricos.childNodes)
numRevisão += rootHistóricos.childNodes.length;
IXMLDOMAttribute curAttribute = null;
curAttribute = (IXMLDOMAttribute)
this.document.DOM.createNode(DOMNodeType.NODE_ATTRIBUTE,
"my:NúmeroRevisão", thisDocNSURI);
curAttribute.value = numRevisão;
((IXMLDOMElement)
newHistórico).setAttributeNode(curAttribute);
curAttribute = (IXMLDOMAttribute)
this.document.DOM.createNode(DOMNodeType.NODE_ATTRIBUTE,
"my
curAttribute.value = System.DateTime.UtcNow;
((IXMLDOMElement)
newHistórico).setAttributeNode(curAttribute);
curAttribute = (IXMLDOMAttribute)
this.document.DOM.createNode(DOMNodeType.NODE_ATTRIBUTE,
"my:ResponsávelRevisão", thisDocNSURI);
curAttribute.value = System.Environment.UserName;
((IXMLDOMElement)
newHistórico).setAttributeNode(curAttribute);
this.document.UI.Alert(rootHistóricos.xml);
this.document.UI.Alert(newHistórico.xml);
rootHistóricos.appendChild(newHistórico);
this.document.Save();
}
}
Whenever i reach the last appendChild call, i get this exception:
System.Runtime.InteropServices.COMException
The attribute
'{http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-04-09T02-30-31}ResponsávelRevisão'
on the element
'{http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-04-09T02-30-31}HistóricoRevisão'
is not defined in the DTD/Schema.
Tips are welcome
-- Aldrin Leal