Setting custom Open XML metadata
Background
Custom properties in Open XML are stored in docProps/custom.xml
and look like this (for a string):
<property fmtid="{xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxxxxx}" pi开发者_如何学JAVAd="2" name="Key">
<vt:lpwstr>Value</vt:lpwstr>
</property>
The Open XML (v1) specification doesn't give many details about fmtid
and pid
. It merely states in section 7.3.2.2:
[PID] Uniquely relates a custom property with an OLE property
Questions
I have a few questions about the specification's vague explanation:
- What are OLE properties?
- Is it possible add a new OpenXML property in custom.xml without storing an OLE property?
- Does
pid
need to be unique perfmtid
, or unique for allfmtid
s in custom.xml - Why don't my own properties in custom.xml appear in Word?
I'm going to partially answer my own question based on what I discovered by experimenting.
OLE properties are NTFS extended attributes that are stored in alternative file streams. They can be viewed or modified with DSOfile.dll. See this StackOverflow question.
Custom properties can be added by modifying custom.xml. They will only appear in Word's properties dialog if the fmtid belongs to Word or a loaded COM add-in.
精彩评论