Error: Reference to undeclared namespace: ‘ns1’ when trying to create a custom Document Information Panel

Posted Tuesday, September 29, 2009 4:40 PM by CoreyRoth

I’ve been chasing this particular error for a little while and thought I would take the time to share my experience and how to resolve it.  The scenario I had is I have a custom content type with several custom site columns.  I generated the CAML for my content type and site columns using SPSource.  When I clicked on the Create a new custom template button, I received the following error (or one similar).

propertySchema0.xsd#/schema/element[1][@name = 'properties']/complexType[1]/sequence[1]/element[1][@name = 'documentManagement']/complexType[1]/all[1]/element[1]

Reference to undeclared namespace prefix: 'ns1'.

As with all InfoPath errors, this is completely useless.  After many attempts at trying to figure out this issue, I noticed that I could create a new Lookup Column and a new Content Type using the SharePoint UI and not receive this error.  I then busted out the Imtech Fields Explorer and as far as I could tell all of the properties were just about the same.  However, I noticed one difference in the SchemaXML property.  My Field element did not have a SourceId but the column created through the UI did.  It’s value was set to the Id of the web hosting the site column.  I knew I couldn’t set it to that and so I remembered in the past I had always set the SourceId of the field element as seen below.

SourceID=”http://schemas.microsoft.com/sharepoint/v3”

This got me closer, the content types and site columns deployed correctly and the SchemaXML had a SourceID in it.  However, when I tried to create a Document Information Panel this time, I got this new lovely error.

InfoPath has encountered an error.  The operation failed.

Catastrophic failure

Once again, thanks InfoPath team for such useful error information.  After further investigation, I discovered I needed to set the StaticName attribute as well.  I simply set this to match the Name attribute I had and everything works now.  It’s strange how the content type can work completely everywhere else, but in InfoPath it’s very picky.  Here is what a complete working Field element might look like for you.

<Field Type="Text" DisplayName="MyField" Required="FALSE" MaxLength="255" Group="My Field Group" ID="{2E6858a5-6ae2-409f-8492-fa15c39821c8}" Name="MyField" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="MyField" />

I mentioned above the issue I had was with a Lookup column but I quickly discovered that this was happening with all of my columns and had nothing to do with the lookup.  SPSource has saved me a ton of time, but this is just another minor thing to look out with the tool.  I logged an issue on CodePlex to see if we can get these two attributes added to the Site Column export.  If you aren’t customizing Document Information Panels, then there is nothing to worry about with the exported CAML, but if you are be sure and add these two attributes.

Comments

# Error: Reference to undeclared namespace: ???ns1??? when trying to create a custom Document Information Panel

Pingback from  Error: Reference to undeclared namespace: ???ns1??? when trying to create a custom Document Information Panel

# re: Error: Reference to undeclared namespace: ‘ns1’ when trying to create a custom Document Information Panel

Monday, March 8, 2010 5:55 AM by John C

I am experiencing this exact issue. Could you please explain where we could find the Schema XML file. I have tried looking with SPD but to no avail.

# re: Error: Reference to undeclared namespace: ‘ns1’ when trying to create a custom Document Information Panel

Monday, March 8, 2010 9:14 AM by CoreyRoth

In this case, the schema.xml is used in my custom document library's feature.  I also highly recommend being fairly current on service packs / updates if you are dealing with document information panels.

Leave a Comment

(required)
(required)
(optional)
(required)