Setting the Content Type of a Part
When adding a new part to a package, the package implementer shall ensure that a content type for that part is specified in the Content Types stream; the package implementer shall perform the following steps to do so [M2.8]:
Get the extension from the part name by taking the substring to the right of the rightmost occurrence of the dot character (.) from the rightmost segment.
If a part name has no extension, a corresponding
<Override>
element shall be added to the Content Types stream.Compare the resulting extension with the values specified for the
@Extension
attributes of the<Default>
elements in the Content Types stream. The comparison shall be case-insensitive ASCII.If there is a
<Default>
element with a matching@Extension
attribute, then the content type of the new part shall be compared with the value of the@ContentType
attribute. The comparison might be case-sensitive and include every character regardless of the role it plays in the content-type grammar of RFC 2616, or it might follow the grammar of RFC 2616.If the content types match, no further action is required.
If the content types do not match, a new
<Override>
element shall be added to the Content Types stream.
If there is no
<Default>
element with a matching Extension attribute, a new<Default>
element or<Override>
element shall be added to the Content Types stream.