Specifying Document Content Type for XML Parsing
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
When a user first uploads an XML document to a document library, the built-in XML parser examines the content type and document template properties to determine the content type to assign to the document. The parser must determine which of the content types associated with the document library to assign the document before the parser can promote or demote document properties.
For a detailed examination of the process the parser performs to match a document’s content type with a content type associated with the document library, see Determining Document Content Type for XML Parsing.
Specifying Content Type by Content Type ID
The parser looks for a processing instruction that specifies the document's content type by content type ID. The location of this processing instruction is included in the definition for the content type ID column template. The processing instruction is named MicrosoftWindowsSharePointServices and contains an attribute named ContentTypeID that represents the ID of the document's content type.
<FieldRef
ID="{4B1BF6C6-4F39-45ac-ACD5-16FE7A214E5E}"
Name="Content Type ID"
PITarget="MicrosoftWindowsSharePointServices"
PIAttribute="ContentTypeID"/>
By default, all library list templates include a column that represents the content type ID.
Add this processing instruction to your XML document. Set the ContentTypeID attribute to the ID of the document's content type.
For example:
<?MicrosoftWindowsSharePointServices ContentTypeID=”0x010101003D7907A1908011d082BD08005AA74F5E00A557E10DA69DBF4C8BE1E21071B08163”/>
In the following situations, the parser will fail to determine the content type:
The MicrosoftWindowsSharePointServices processing instruction isn’t present in the document.
The processing instruction does not specify a content type.
The specified content type is not associated with the document library.
No parent or child of the specified content type is associated with the document library.
If the parser cannot identify the content type by content type ID, it performs a second check, detailed in the next section.
Note
The parser looks for the content type ID in whatever document location you specify in the field definition for the Content Type ID column on the document library. You can map the Content Type ID column to any processing instruction or XPath expression you choose. However, we recommend you adhere to the default mapping included in the content type ID column template definition to minimize the chance of having content types that specify a different location for this document property than the document library with which they are associated. This situation will lead to the XML parser looking in the wrong document location for the content type ID.
Specifying Content Type by Document Template
If the parser fails to determine a suitable content type for the document based on content type ID, it looks for a processing instruction that contains the URL of the document template on which the document is based. The processing instruction is named mso-infoPathSolution that contains an attribute named hrefthat represents the URL of the document template.
<FieldRef
ID="{4B1BF6C6-4F39-45ac-ACD5-16FE7A214E5E}"
Name="DocumentTemplate"
PITarget="mso-infoPathSolution"
PIAttribute="href"/>
This column is included in the Form content type and is added to a library whenever that content type is added to the library.
So, rather than include a content type ID, you can add this processing instruction to your XML document. Set the href attribute to the URI of the document template on which the document is based.
For example:
<?mso-infoPathSolution href=”http://www.adventureworks.com/templates/myTemplate.XML”?>
If the parser finds this processing instruction, it examines the content types associated with the document library to determine if a content type has the same document template. If so, the parser assigns that content type to the document. If more than one content type associated with the document library has the same matching document template, the parser simply assigns the first matching content type.
Note
The parser looks for the document template URL in whatever document location you specify in the field definition for the Document Template column on the document library. You can map the Document Template column to any processing instruction or XPath expression you choose. However, we recommend you adhere to the default mapping included in the document template column template definition. This minimizes the chance of having content types that specify a different location for this document property than the document library with which they are associated. Such a situation would lead to the XML parser looking in the wrong document location for the document template.
See Also
Concepts
XML Document Property Promotion and Demotion