InfoPath IXMLDOMDocument: Reference to undeclared namespace prefixOctober 30, 2007 12:00
Trying to set a query property in the DOM of a data source I received the error “Reference to undeclared namespace prefix: ‘tns’”. The reason of this error is that the xml contains multiple namespaces and that you have to explicitly define the namespace to use. By default the DOM property you can access from the XDocument are of the type IXMLDOMDocument. But working with this type, does not allow you to set the required namespace for your selections. To get around the issue convert the IXMLDOMDocument to a IXMLDOMDocument2 which makes it possible to define a “SelectionNamespaces” property. If you fill this property with the required documentElement’s namespace, the xpath selection of your node will succeed and the error is gone. Below is an example of the Data source’s IXMLDOMDocument2 content (xml) and some demo code to select the required node. Tags: data source, Infopath, interop, IXMLDOMDocument, namespace prefix, node, xml.Connecting a web part with a standard SharePoint listOctober 9, 2007 11:22
You’ll only have to add 3 extra functions to your web-part to make it work. After adding those functions you are able to connect the web part with a standard list in SharePoint. The required functions are the GetRowData & SetConnectionInterface and you will have to override the OnPreRender. Inside the GetRowData function you can write your personal code to read out the received row. The easiest way to figure out how to access the information from the returned rowData is to debug the code and then view the contents of the rowData object. In my example it turned out that the rowData is of the type DataRowView and that the document url can be extracted from the first position in the array. Tags: connect, Connection Interface, document list, GetRowData, IWebPartRow, OnPreRender, provider, Sharepoint. |
||