forked from qifengzhang007/gooxml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CoreProperties.go
151 lines (142 loc) · 5.62 KB
/
CoreProperties.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Copyright 2017 Baliance. All rights reserved.
//
// DO NOT EDIT: generated by gooxml ECMA-376 generator
//
// Use of this source code is governed by the terms of the Affero GNU General
// Public License version 3.0 as published by the Free Software Foundation and
// appearing in the file LICENSE included in the packaging of this file. A
// commercial license can be purchased by contacting sales@baliance.com.
package core_properties
import (
"encoding/xml"
"time"
"github.com/t-xl/gooxml"
)
type CoreProperties struct {
CT_CoreProperties
}
func NewCoreProperties() *CoreProperties {
ret := &CoreProperties{}
ret.CT_CoreProperties = *NewCT_CoreProperties()
return ret
}
func (m *CoreProperties) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns"}, Value: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties"})
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:cp"}, Value: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties"})
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:dc"}, Value: "http://purl.org/dc/elements/1.1/"})
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:dcterms"}, Value: "http://purl.org/dc/terms/"})
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "xmlns:xml"}, Value: "http://www.w3.org/XML/1998/namespace"})
start.Name.Local = "cp:coreProperties"
return m.CT_CoreProperties.MarshalXML(e, start)
}
func (m *CoreProperties) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
// initialize to default
m.CT_CoreProperties = *NewCT_CoreProperties()
lCoreProperties:
for {
tok, err := d.Token()
if err != nil {
return err
}
switch el := tok.(type) {
case xml.StartElement:
switch el.Name {
case xml.Name{Space: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", Local: "category"}:
m.Category = new(string)
if err := d.DecodeElement(m.Category, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", Local: "contentStatus"}:
m.ContentStatus = new(string)
if err := d.DecodeElement(m.ContentStatus, &el); err != nil {
return err
}
case xml.Name{Space: "http://purl.org/dc/terms/", Local: "created"}:
m.Created = new(gooxml.XSDAny)
if err := d.DecodeElement(m.Created, &el); err != nil {
return err
}
case xml.Name{Space: "http://purl.org/dc/elements/1.1/", Local: "creator"}:
m.Creator = new(gooxml.XSDAny)
if err := d.DecodeElement(m.Creator, &el); err != nil {
return err
}
case xml.Name{Space: "http://purl.org/dc/elements/1.1/", Local: "description"}:
m.Description = new(gooxml.XSDAny)
if err := d.DecodeElement(m.Description, &el); err != nil {
return err
}
case xml.Name{Space: "http://purl.org/dc/elements/1.1/", Local: "identifier"}:
m.Identifier = new(gooxml.XSDAny)
if err := d.DecodeElement(m.Identifier, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", Local: "keywords"}:
m.Keywords = NewCT_Keywords()
if err := d.DecodeElement(m.Keywords, &el); err != nil {
return err
}
case xml.Name{Space: "http://purl.org/dc/elements/1.1/", Local: "language"}:
m.Language = new(gooxml.XSDAny)
if err := d.DecodeElement(m.Language, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", Local: "lastModifiedBy"}:
m.LastModifiedBy = new(string)
if err := d.DecodeElement(m.LastModifiedBy, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", Local: "lastPrinted"}:
m.LastPrinted = new(time.Time)
if err := d.DecodeElement(m.LastPrinted, &el); err != nil {
return err
}
case xml.Name{Space: "http://purl.org/dc/terms/", Local: "modified"}:
m.Modified = new(gooxml.XSDAny)
if err := d.DecodeElement(m.Modified, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", Local: "revision"}:
m.Revision = new(string)
if err := d.DecodeElement(m.Revision, &el); err != nil {
return err
}
case xml.Name{Space: "http://purl.org/dc/elements/1.1/", Local: "subject"}:
m.Subject = new(gooxml.XSDAny)
if err := d.DecodeElement(m.Subject, &el); err != nil {
return err
}
case xml.Name{Space: "http://purl.org/dc/elements/1.1/", Local: "title"}:
m.Title = new(gooxml.XSDAny)
if err := d.DecodeElement(m.Title, &el); err != nil {
return err
}
case xml.Name{Space: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", Local: "version"}:
m.Version = new(string)
if err := d.DecodeElement(m.Version, &el); err != nil {
return err
}
default:
gooxml.Log("skipping unsupported element on CoreProperties %v", el.Name)
if err := d.Skip(); err != nil {
return err
}
}
case xml.EndElement:
break lCoreProperties
case xml.CharData:
}
}
return nil
}
// Validate validates the CoreProperties and its children
func (m *CoreProperties) Validate() error {
return m.ValidateWithPath("CoreProperties")
}
// ValidateWithPath validates the CoreProperties and its children, prefixing error messages with path
func (m *CoreProperties) ValidateWithPath(path string) error {
if err := m.CT_CoreProperties.ValidateWithPath(path); err != nil {
return err
}
return nil
}