When attempting to remove the xsi:nil attribute in IP2003, I receive the
following error:
System.Runtime.InteropServices.COMException
Exception from HRESULT: 0x80043001
at
Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMNamedNodeMap.removeNamedItem(String name)
at
Microsoft.Office.Interop.InfoPath.SemiTrust.IXMLDOMNamedNodeMapWrapper.removeNamedItem(String name)
at
ProductExpiryMaintenance.ProductExpiryMaintenance.ReplaceMainProductListWithSecondary()
at
ProductExpiryMaintenance.ProductExpiryMaintenance.OnLoad(DocReturnEvent e)
at
Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper.OnLoad(DocReturnEvent pEvent)
This is the piece of code causing the issue:
IXMLDOMNode productListMain =
thisXDocument.DOM.selectSingleNode("//products/retail");
if (productListMain.attributes.getNamedItem("xsi:nil") != null)
{
productListMain.attributes.removeNamedItem("xsi:nil");
}
This is an example of XML:
<ns1:productExpiryMaintenance
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns1="http://Schemas.Company.productExpiryMaintenance"
xmlns:pl="http://Schemas.DataServices.ProductList"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-09-04T09-41-22" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003">
<companyLegalName></companyLegalName>
<contactName xsi:nil="true"></contactName>
<pl:productList>
<companyCode></companyCode>
<documentRefNo xsi:nil="true"></documentRefNo>
<contractNo xsi:nil="true"></contractNo>
<products>
<retail xsi:nil="true"></retail>
<foodservice xsi:nil="true"></foodservice>
</products>
</pl:productList>
...
</ns1:productExpiryMaintenance>
Anyone got any ideas what causes this?
(I've attempted to provide the selectionNamespaces for the "pl" namespace
prefix but with no luck).
Thanks.
PeterB - 15 Nov 2007 01:13 GMT
I think InfoPath cannot un-nil a complex type or one with a repeating node
beneath it. You can happily run removeNamedItem("xsi:nil") on an element, but
if it's a record/complex type, it dies.
So perhaps you need to contruct your own fully-expanded complex type and
replace the existing nillable one with this one. I've worked around the issue
by forcing a BizTalk Map to create 1 item in the repeating list and injecting
nil (functoid) into each of its elements, thus expanding the complex type.
> When attempting to remove the xsi:nil attribute in IP2003, I receive the
> following error:
[quoted text clipped - 49 lines]
>
> Thanks.