private static void WriteObsoleteInfo(this MamlWriter writer, Topic topic)
 {
     writer.StartAlert(AlertClass.Note);
     writer.StartParagraph();
     writer.WriteString("This XML entity is now obsolete. The non-obsolete alternative is ");
     writer.WriteTopicLink(topic);
     writer.EndParagraph();
     writer.EndAlert();
 }
 private static void AddItem(ICollection<ListItem> items, ArtItem artItem, Topic topic, string summaryMarkup)
 {
     var listItem = new ListItem
                    {
                        ArtItem = artItem,
                        Topic = topic,
                        SummaryMarkup = summaryMarkup
                    };
     items.Add(listItem);
 }
        public static void WriteHtmlTopicLink(this MamlWriter writer, Topic topic)
        {
            // Don't use the HTML prefix (/html/) because that would break website builds.
            //
            // The topic that uses the HTML based topic links are generated; the topics
            // it points to are generated as well. That means source and target must be
            // in the same folder anywyas.

            var url = String.Format(CultureInfo.InvariantCulture, "{0}.htm", topic.Id);

            writer.WriteStartElement("a", Namespaces.Maml);
            writer.WriteAttributeString("href", url);
            writer.WriteString(topic.LinkTitle);
            writer.WriteEndElement();
        }
Beispiel #4
0
        private Topic AddTopic(TopicType topicType, string objNamespace, XmlSchemaObject obj, string name)
        {
            objNamespace = (objNamespace == string.Empty)
                            ? null
                            : objNamespace;

            if (_topicStack.Count == 0)
            {
                var root = new List<Topic>();
                _topicStack.Push(root);
            }

            var topic = new Topic
                        {
                            Title = GetTopicTitle(topicType, name),
                            LinkTitle = GetTopicLinkTitle(topicType, name),
                            LinkUri = GetTopicLinkUri(topicType, objNamespace, obj),
                            LinkIdUri = GetTopicLinkIdUri(topicType, obj),
                            TopicType = topicType,
                            Namespace = objNamespace,
                            SchemaObject = obj
                        };

            if (obj != null)
                _topicDictionary.Add(obj, topic);

            _topicStack.Peek().Add(topic);

            return topic;
        }
        private void GenerateSimpleTypeTopic(Topic topic)
        {
            var simpleType = (XmlSchemaSimpleType)topic.SchemaObject;
            var usages = _context.SchemaSetManager.GetTypeUsages(simpleType);
            var simpleTypeStructureRoot = _context.SchemaSetManager.GetSimpleTypeStructure(simpleType.Content);

            using (var stream = File.Create(topic.FileName))
            using (var writer = new MamlWriter(stream))
            {
                writer.StartTopic(topic.Id);
                writer.WriteIntroductionForObject(_context, simpleType);
                writer.WriteContentTypeSection(_context, simpleTypeStructureRoot);
                writer.WriteUsagesSection(_context, usages);
                writer.WriteRemarksSectionForObject(_context, simpleType);
                writer.WriteExamplesSectionForObject(_context, simpleType);
                writer.WriteSyntaxSection(_context, simpleType);
                writer.WriteRelatedTopics(_context, simpleType);
                writer.EndTopic();
            }
        }
        private void GenerateSchemaTopic(Topic topic)
        {
            var schema = (XmlSchema)topic.SchemaObject;

            var contentFinder = new SchemaContentFinder(schema);
            contentFinder.Traverse(schema);

            using (var stream = File.Create(topic.FileName))
            using (var writer = new MamlWriter(stream))
            {
                writer.StartTopic(topic.Id);
                writer.WriteIntroductionForSchema(_context, schema);
                writer.WriteRemarksSectionForObject(_context, schema);
                writer.WriteExamplesSectionForObject(_context, schema);
                writer.WriteElementsSection(_context, contentFinder.Elements);
                writer.WriteAttributesSection(_context, contentFinder.Attributes);
                writer.WriteGroupsSection(_context, contentFinder.Groups);
                writer.WriteAttributeGroupsSection(_context, contentFinder.AttributeGroups);
                writer.WriteSimpleTypesSection(_context, contentFinder.SimpleTypes);
                writer.WriteComplexTypesSection(_context, contentFinder.ComplexTypes);
                writer.EndTopic();
            }
        }
        private void GenerateSchemaSetTopic(Topic topic)
        {
            if (_context.Configuration.NamespaceContainer)
            {
                using (var stream = File.Create(topic.FileName))
                using (var writer = new MamlWriter(stream))
                {
                    writer.StartTopic(topic.Id);
                    writer.WriteIntroductionForSchemaSet(_context);
                    writer.WriteRemarksSectionForSchemaSet(_context);
                    writer.WriteExamplesSectionForSchemaSet(_context);
                    writer.WriteNamespacesSection(_context, _context.SchemaSetManager.GetNamespaces());
                    writer.EndTopic();
                }
            }
            else
            {
                var contentFinder = new NamespaceContentFinder(_context.SchemaSetManager, topic.Namespace);
                contentFinder.Traverse(_context.SchemaSetManager.SchemaSet);

                using (var stream = File.Create(topic.FileName))
                using (var writer = new MamlWriter(stream))
                {
                    writer.StartTopic(topic.Id);
                    writer.WriteIntroductionForSchemaSet(_context);
                    writer.WriteRemarksSectionForSchemaSet(_context);
                    writer.WriteExamplesSectionForSchemaSet(_context);
                    writer.WriteRootSchemasSection(_context, _context.SchemaSetManager.GetNamespaceRootSchemas(topic.Namespace));
                    writer.WriteRootElementsSection(_context, _context.SchemaSetManager.GetNamespaceRootElements(topic.Namespace));
                    writer.WriteSchemasSection(_context, contentFinder.Schemas);
                    writer.WriteElementsSection(_context, contentFinder.Elements);
                    writer.WriteAttributesSection(_context, contentFinder.Attributes);
                    writer.WriteGroupsSection(_context, contentFinder.Groups);
                    writer.WriteAttributeGroupsSection(_context, contentFinder.AttributeGroups);
                    writer.WriteSimpleTypesSection(_context, contentFinder.SimpleTypes);
                    writer.WriteComplexTypesSection(_context, contentFinder.ComplexTypes);
                    writer.EndTopic();
                }
            }
        }
        private void GenerateOverviewTopic(Topic topic)
        {
            var contentFinder = new NamespaceContentFinder(_context.SchemaSetManager, topic.Namespace);
            contentFinder.Traverse(_context.SchemaSetManager.SchemaSet);

            using (var stream = File.Create(topic.FileName))
            using (var writer = new MamlWriter(stream))
            {
                writer.StartTopic(topic.Id);
                writer.WriteIntroductionForOverview(_context, topic.Namespace);

                switch (topic.TopicType)
                {
                    case TopicType.RootSchemasSection:
                        writer.WriteRootSchemasSection(_context, _context.SchemaSetManager.GetNamespaceRootSchemas(topic.Namespace));
                        break;
                    case TopicType.RootElementsSection:
                        writer.WriteRootElementsSection(_context, _context.SchemaSetManager.GetNamespaceRootElements(topic.Namespace));
                        break;
                    case TopicType.SchemasSection:
                        writer.WriteSchemasSection(_context, contentFinder.Schemas);
                        break;
                    case TopicType.ElementsSection:
                        writer.WriteElementsSection(_context, contentFinder.Elements);
                        break;
                    case TopicType.AttributesSection:
                        writer.WriteAttributesSection(_context, contentFinder.Attributes);
                        break;
                    case TopicType.AttributeGroupsSection:
                        writer.WriteAttributeGroupsSection(_context, contentFinder.AttributeGroups);
                        break;
                    case TopicType.GroupsSection:
                        writer.WriteGroupsSection(_context, contentFinder.Groups);
                        break;
                    case TopicType.SimpleTypesSection:
                        writer.WriteSimpleTypesSection(_context, contentFinder.SimpleTypes);
                        break;
                    case TopicType.ComplexTypesSection:
                        writer.WriteComplexTypesSection(_context, contentFinder.ComplexTypes);
                        break;
                    default:
                        throw ExceptionBuilder.UnhandledCaseLabel(topic.TopicType);
                }

                writer.EndTopic();
            }
        }
        private void GenerateGroupTopic(Topic topic)
        {
            var group = (XmlSchemaGroup)topic.SchemaObject;
            var parents = _context.SchemaSetManager.GetObjectParents(group);
            var children = _context.SchemaSetManager.GetChildren(group);

            using (var stream = File.Create(topic.FileName))
            using (var writer = new MamlWriter(stream))
            {
                writer.StartTopic(topic.Id);
                writer.WriteIntroductionForObject(_context, group);
                writer.WriteUsagesSection(_context, parents);
                writer.WriteChildrenSection(_context, children);
                writer.WriteRemarksSectionForObject(_context, group);
                writer.WriteExamplesSectionForObject(_context, group);
                writer.WriteSyntaxSection(_context, group);
                writer.WriteRelatedTopics(_context, group);
                writer.EndTopic();
            }
        }
        private void GenerateElementTopic(Topic topic)
        {
            var element = (XmlSchemaElement)topic.SchemaObject;
            var parents = _context.SchemaSetManager.GetObjectParents(element);
            var simpleTypeStructureRoot = _context.SchemaSetManager.GetSimpleTypeStructure(element.ElementSchemaType);
            var children = _context.SchemaSetManager.GetChildren(element);
            var attributeEntries = _context.SchemaSetManager.GetAttributeEntries(element);
            var constraints = element.Constraints;

            using (var stream = File.Create(topic.FileName))
            using (var writer = new MamlWriter(stream))
            {
                writer.StartTopic(topic.Id);
                writer.WriteIntroductionForObject(_context, element);
                writer.WriteTypeSection(_context, element);
                writer.WriteContentTypeSection(_context, simpleTypeStructureRoot);
                writer.WriteParentsSection(_context, parents);
                writer.WriteChildrenSection(_context, children);
                writer.WriteAttributesSection(_context, attributeEntries);
                writer.WriteConstraintsSection(_context, constraints);
                writer.WriteRemarksSectionForObject(_context, element);
                writer.WriteExamplesSectionForObject(_context, element);
                writer.WriteSyntaxSection(_context, element);
                writer.WriteRelatedTopics(_context, element);
                writer.EndTopic();
            }
        }
        private void GenerateAttributeTopic(Topic topic)
        {
            var attribute = (XmlSchemaAttribute)topic.SchemaObject;
            var parents = _context.SchemaSetManager.GetObjectParents(attribute);
            var simpleTypeStructureRoot = _context.SchemaSetManager.GetSimpleTypeStructure(attribute.AttributeSchemaType);

            using (var stream = File.Create(topic.FileName))
            using (var writer = new MamlWriter(stream))
            {
                writer.StartTopic(topic.Id);
                writer.WriteIntroductionForObject(_context, attribute);
                writer.WriteContentTypeSection(_context, simpleTypeStructureRoot);
                writer.WriteParentsSection(_context, parents);
                writer.WriteRemarksSectionForObject(_context, attribute);
                writer.WriteExamplesSectionForObject(_context, attribute);
                writer.WriteSyntaxSection(_context, attribute);
                writer.WriteRelatedTopics(_context, attribute);
                writer.EndTopic();
            }
        }
        private void GenerateAttributeGroup(Topic topic)
        {
            var attributeGroup = (XmlSchemaAttributeGroup)topic.SchemaObject;
            var usages = _context.SchemaSetManager.GetObjectParents(attributeGroup);
            var attributeEntries = _context.SchemaSetManager.GetAttributeEntries(attributeGroup);

            using (var stream = File.Create(topic.FileName))
            using (var writer = new MamlWriter(stream))
            {
                writer.StartTopic(topic.Id);
                writer.WriteIntroductionForObject(_context, attributeGroup);
                writer.WriteUsagesSection(_context, usages);
                writer.WriteAttributesSection(_context, attributeEntries);
                writer.WriteRemarksSectionForObject(_context, attributeGroup);
                writer.WriteExamplesSectionForObject(_context, attributeGroup);
                writer.WriteSyntaxSection(_context, attributeGroup);
                writer.WriteRelatedTopics(_context, attributeGroup);
                writer.EndTopic();
            }
        }
 private static string GetAbsoluteFileName(string topicsFolder, Topic topic)
 {
     return Path.Combine(topicsFolder, Path.ChangeExtension(topic.Id, ".aml"));
 }
 public static void WriteHtmlArtItemWithTopicLink(this MamlWriter writer, ArtItem artItem, Topic topic)
 {
     writer.StartHtmlArtItem(artItem);
     writer.WriteHtmlTopicLink(topic);
     writer.EndHtmlArtItem();
 }
 private static void WriteTopicLinkWithReferenceMarker(this MamlWriter writer, Topic rootItemTopic)
 {
     writer.WriteLink(rootItemTopic.Id, rootItemTopic.LinkTitle, XmlTopicType);
 }
 public static void WriteTopicLink(this MamlWriter writer, Topic topic)
 {
     writer.WriteLink(topic.Id, topic.LinkTitle);
 }