/// <summary> /// Write out the topic metadata /// </summary> /// <param name="writer">The writer to which the metadata is written</param> /// <param name="builder">The build process</param> /// <remarks>This will recursively write out metadata for sub-topics /// as well.</remarks> internal void WriteMetadata(XmlWriter writer, BuildProcess builder) { // MS Help Viewer doesn't support empty place holders so we automatically generate a dummy place // holder file for them. if (!noFile || (builder.CurrentProject.HelpFileFormat & HelpFileFormats.MSHelpViewer) != 0) { writer.WriteStartElement("topic"); writer.WriteAttributeString("id", this.Id); writer.WriteAttributeString("revisionNumber", this.RevisionNumber.ToString(CultureInfo.InvariantCulture)); // Write out the help file version project property value writer.WriteStartElement("item"); writer.WriteAttributeString("id", "PBM_FileVersion"); writer.WriteValue(builder.TransformText(builder.CurrentProject.HelpFileVersion)); writer.WriteEndElement(); // If no title is specified, use the display title writer.WriteStartElement("title"); if (!String.IsNullOrEmpty(title)) { writer.WriteString(title); } else { writer.WriteString(this.DisplayTitle); } writer.WriteEndElement(); // TOC title is optional if (!String.IsNullOrEmpty(tocTitle)) { writer.WriteElementString("tableOfContentsTitle", tocTitle); } // Each topic includes the project-level help attributes foreach (MSHelpAttr attr in builder.CurrentProject.HelpAttributes) { writer.WriteStartElement("attribute"); writer.WriteAttributeString("name", attr.AttributeName); // Replace tags with their project property value writer.WriteValue(builder.TransformText(attr.AttributeValue)); writer.WriteEndElement(); } // Add topic-specific attributes foreach (MSHelpAttr attr in helpAttributes) { writer.WriteStartElement("attribute"); writer.WriteAttributeString("name", attr.AttributeName); // Replace tags with their project property value writer.WriteValue(builder.TransformText(attr.AttributeValue)); writer.WriteEndElement(); } // Add topic-specific index keywords foreach (MSHelpKeyword kw in keywords) { writer.WriteStartElement("keyword"); writer.WriteAttributeString("index", kw.Index); // Replace tags with their project property value writer.WriteValue(builder.TransformText(kw.Term)); writer.WriteEndElement(); } // If this is the default topic and the NamedUrlIndex keywords for DefaultPage and/or HomePage // are not present, add them. if (this.IsDefaultTopic) { if (!keywords.Contains(new MSHelpKeyword("NamedUrlIndex", "DefaultPage"))) { writer.WriteStartElement("keyword"); writer.WriteAttributeString("index", "NamedUrlIndex"); writer.WriteValue("DefaultPage"); writer.WriteEndElement(); } if (!keywords.Contains(new MSHelpKeyword("NamedUrlIndex", "HomePage"))) { writer.WriteStartElement("keyword"); writer.WriteAttributeString("index", "NamedUrlIndex"); writer.WriteValue("HomePage"); writer.WriteEndElement(); } } writer.WriteEndElement(); // </topic> } // Write metadata for sub-topics too foreach (Topic t in subtopics) { t.WriteMetadata(writer, builder); } }