internal override void LoadFrom (Stream stream)
{
+ if (stream.Length == 0)
+ return;
+
XmlDocument doc = new XmlDocument ();
doc.Load (stream);
if ((node = doc.SelectSingleNode ("prop:coreProperties/prop:category", manager)) != null)
category = node.InnerXml;
if ((node = doc.SelectSingleNode ("prop:coreProperties/prop:contentStatus", manager)) != null)
- ContentStatus = node.InnerXml;
+ contentStatus = node.InnerXml;
if ((node = doc.SelectSingleNode ("prop:coreProperties/prop:contentType", manager)) != null)
- ContentType = node.InnerXml;
+ contentType = node.InnerXml;
if ((node = doc.SelectSingleNode ("prop:coreProperties/dcterms:created", manager)) != null)
- Created = DateTime.Parse (node.InnerXml);
+ created = DateTime.Parse (node.InnerXml);
if ((node = doc.SelectSingleNode ("prop:coreProperties/dc:creator", manager)) != null)
- Creator = node.InnerXml;
+ creator = node.InnerXml;
if ((node = doc.SelectSingleNode ("prop:coreProperties/dc:description", manager)) != null)
- Description = node.InnerXml;
+ description = node.InnerXml;
if ((node = doc.SelectSingleNode ("prop:coreProperties/dc:identifier", manager)) != null)
- Identifier = node.InnerXml;
+ identifier = node.InnerXml;
if ((node = doc.SelectSingleNode ("prop:coreProperties/prop:keywords", manager)) != null)
- Keywords = node.InnerXml;
+ keywords = node.InnerXml;
if ((node = doc.SelectSingleNode ("prop:coreProperties/dc:language", manager)) != null)
- Language = node.InnerXml;
+ language = node.InnerXml;
if ((node = doc.SelectSingleNode ("prop:coreProperties/prop:lastModifiedBy", manager)) != null)
- LastModifiedBy = node.InnerXml;
+ lastModifiedBy = node.InnerXml;
if ((node = doc.SelectSingleNode ("prop:coreProperties/prop:lastPrinted", manager)) != null)
- LastPrinted = DateTime.Parse (node.InnerXml);
+ lastPrinted = DateTime.Parse (node.InnerXml);
if ((node = doc.SelectSingleNode ("prop:coreProperties/dcterms:modified", manager)) != null)
- Modified = DateTime.Parse (node.InnerXml);
+ modified = DateTime.Parse (node.InnerXml);
if ((node = doc.SelectSingleNode ("prop:coreProperties/prop:revision", manager)) != null)
- Revision = node.InnerXml;
+ revision = node.InnerXml;
if ((node = doc.SelectSingleNode ("prop:coreProperties/dc:subject", manager)) != null)
- Subject = node.InnerXml;
+ subject = node.InnerXml;
if ((node = doc.SelectSingleNode ("prop:coreProperties/dc:title", manager)) != null)
- Title = node.InnerXml;
+ title = node.InnerXml;
if ((node = doc.SelectSingleNode ("prop:coreProperties/prop:version", manager)) != null)
- Version = node.InnerXml;
+ version = node.InnerXml;
}
internal override void WriteTo(XmlTextWriter writer)
coreProperties.Attributes.Append (doc.CreateAttribute ("xmlns:xsi")).Value = NSXsi;
// Create the children
- coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "category", NSPackageProperties)).InnerXml = Category ?? "";
- coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "contentStatus", NSPackageProperties)).InnerXml = ContentStatus ?? "";
- coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "contentType", NSPackageProperties)).InnerXml = ContentType ?? "";
+ if (Category != null)
+ coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "category", NSPackageProperties)).InnerXml = Category;
+ if (ContentStatus != null)
+ coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "contentStatus", NSPackageProperties)).InnerXml = ContentStatus;
+ if (ContentType != null)
+ coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "contentType", NSPackageProperties)).InnerXml = ContentType;
if (Created.HasValue)
coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "dcterms", "created", NSDcTerms)).InnerXml = Created.Value.ToString ();
- coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "dc", "creator", NSDc)).InnerXml = Creator ?? "";
- coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "dc", "description", NSDc)).InnerXml = Description ?? "";
- coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "dc", "identifier", NSDc)).InnerXml = Identifier ?? "";
- coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "keywords", NSPackageProperties)).InnerXml = Keywords ?? "";
- coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "dc", "language", NSDc)).InnerXml = Language ?? "";
- coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "lastModifiedBy", NSPackageProperties)).InnerXml = LastModifiedBy ?? "";
+ if (Creator != null)
+ coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "dc", "creator", NSDc)).InnerXml = Creator;
+ if (Description != null)
+ coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "dc", "description", NSDc)).InnerXml = Description;
+ if (Identifier != null)
+ coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "dc", "identifier", NSDc)).InnerXml = Identifier;
+ if (Keywords != null)
+ coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "keywords", NSPackageProperties)).InnerXml = Keywords;
+ if (Language != null)
+ coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "dc", "language", NSDc)).InnerXml = Language;
+ if (LastModifiedBy != null)
+ coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "lastModifiedBy", NSPackageProperties)).InnerXml = LastModifiedBy;
if (LastPrinted.HasValue)
coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "lastPrinted", NSPackageProperties)).InnerXml = LastPrinted.Value.ToString ();
- coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "revision", NSPackageProperties)).InnerXml = Revision ?? "";
- coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "dc", "subject", NSDc)).InnerXml = Subject ?? "";
- coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "dc", "title", NSDc)).InnerXml = Title ?? "";
- coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "version", NSPackageProperties)).InnerXml = Version ?? "";
+ if (Revision != null)
+ coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "revision", NSPackageProperties)).InnerXml = Revision;
+ if (Subject != null)
+ coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "dc", "subject", NSDc)).InnerXml = Subject;
+ if (Title != null)
+ coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "dc", "title", NSDc)).InnerXml = Title;
+ if (Version != null)
+ coreProperties.AppendChild (doc.CreateNode (XmlNodeType.Element, "version", NSPackageProperties)).InnerXml = Version;
if (Modified.HasValue)
{