@@ -197,25 +197,26 @@ func (c *contentTypes) findType(name string) (string, error) {
197197}
198198
199199type corePropertiesXMLMarshal struct {
200- XMLName xml.Name `xml:"coreProperties"`
201- XML string `xml:"xmlns,attr"`
202- XMLDCTERMS string `xml:"xmlns:dcterms,attr"`
203- XMLDC string `xml:"xmlns:dc,attr"`
204- Category string `xml:"category,omitempty"`
205- ContentStatus string `xml:"contentStatus,omitempty"`
206- Created string `xml:"dcterms:created,omitempty"`
207- Creator string `xml:"dc:creator,omitempty"`
208- Description string `xml:"dc:description,omitempty"`
209- Identifier string `xml:"dc:identifier,omitempty"`
210- Keywords string `xml:"keywords,omitempty"`
211- Language string `xml:"dc:language,omitempty"`
212- LastModifiedBy string `xml:"lastModifiedBy,omitempty"`
213- LastPrinted string `xml:"lastPrinted,omitempty"`
214- Modified string `xml:"dcterms:modified,omitempty"`
215- Revision string `xml:"revision,omitempty"`
216- Subject string `xml:"dc:subject,omitempty"`
217- Title string `xml:"dc:title,omitempty"`
218- Version string `xml:"version,omitempty"`
200+ XMLName xml.Name `xml:"coreProperties"`
201+ XML string `xml:"xmlns,attr"`
202+ XMLDCTERMS string `xml:"xmlns:dcterms,attr"`
203+ XMLDC string `xml:"xmlns:dc,attr"`
204+ XMLXSI string `xml:"xmlns:xsi,attr"`
205+ Category string `xml:"category,omitempty"`
206+ ContentStatus string `xml:"contentStatus,omitempty"`
207+ Created w3CDateTime `xml:"dcterms:created,omitempty"`
208+ Creator string `xml:"dc:creator,omitempty"`
209+ Description string `xml:"dc:description,omitempty"`
210+ Identifier string `xml:"dc:identifier,omitempty"`
211+ Keywords string `xml:"keywords,omitempty"`
212+ Language string `xml:"dc:language,omitempty"`
213+ LastModifiedBy string `xml:"lastModifiedBy,omitempty"`
214+ LastPrinted w3CDateTime `xml:"lastPrinted,omitempty"`
215+ Modified w3CDateTime `xml:"dcterms:modified,omitempty"`
216+ Revision string `xml:"revision,omitempty"`
217+ Subject string `xml:"dc:subject,omitempty"`
218+ Title string `xml:"dc:title,omitempty"`
219+ Version string `xml:"version,omitempty"`
219220}
220221
221222type corePropertiesXMLUnmarshal struct {
@@ -240,6 +241,16 @@ type corePropertiesXMLUnmarshal struct {
240241 Version string `xml:"version,omitempty"`
241242}
242243
244+ type w3CDateTime string
245+
246+ func (s w3CDateTime ) MarshalXML (e * xml.Encoder , start xml.StartElement ) error {
247+ type xmlType struct {
248+ XSITYPE string `xml:"xsi:type,attr"`
249+ Value string `xml:",chardata"`
250+ }
251+ return e .EncodeElement (xmlType {"dcterms:W3CDTF" , string (s )}, start )
252+ }
253+
243254// CoreProperties enable users to get and set well-known and common sets of property metadata within packages.
244255type CoreProperties struct {
245256 PartName string // Won't be writed to the package, only used to indicate the location of the CoreProperties part. If empty the default location is "/props/core.xml".
@@ -269,10 +280,11 @@ func (c *CoreProperties) encode(w io.Writer) error {
269280 "http://schemas.openxmlformats.org/package/2006/metadata/core-properties" ,
270281 "http://purl.org/dc/terms/" ,
271282 "http://purl.org/dc/elements/1.1/" ,
272- c .Category , c .ContentStatus , c .Created ,
283+ "http://www.w3.org/2001/XMLSchema-instance" ,
284+ c .Category , c .ContentStatus , w3CDateTime (c .Created ),
273285 c .Creator , c .Description , c .Identifier ,
274286 c .Keywords , c .Language , c .LastModifiedBy ,
275- c .LastPrinted , c .Modified , c .Revision ,
287+ w3CDateTime ( c .LastPrinted ), w3CDateTime ( c .Modified ) , c .Revision ,
276288 c .Subject , c .Title , c .Version ,
277289 })
278290}
0 commit comments