Ejemplo n.º 1
0
        /// <summary>
        /// Index an extension attribute. Attaches the attribute to all its extended parent elements.
        /// </summary>
        /// <param name="attribute">The attribute to index.</param>
        private void IndexExtensionAttributes(XmlSchemaAttribute attribute)
        {
            XmlSchemaAttributeInfo attributeInfo = (XmlSchemaAttributeInfo)this.attributes[attribute.QualifiedName];
            if (null == attributeInfo)
            {
                attributeInfo = new XmlSchemaAttributeInfo();
                this.attributes.Add(attribute.QualifiedName, attributeInfo);
            }

            if (attribute.Annotation != null)
            {
                foreach (XmlSchemaObject obj in attribute.Annotation.Items)
                {
                    XmlSchemaAppInfo appInfo = obj as XmlSchemaAppInfo;

                    if (appInfo != null)
                    {
                        foreach (XmlNode node in appInfo.Markup)
                        {
                            XmlElement markupElement = node as XmlElement;

                            if (markupElement != null && markupElement.LocalName == "parent" && markupElement.NamespaceURI == XmlSchemaExtensionNamespace)
                            {
                                string parentNamespace = markupElement.GetAttribute("namespace");
                                string parentRef = markupElement.GetAttribute("ref");

                                if (parentNamespace.Length == 0)
                                {
                                    throw new ApplicationException("The parent element is missing the namespace attribute.");
                                }

                                if (parentRef.Length == 0)
                                {
                                    throw new ApplicationException("The parent element is missing the ref attribute.");
                                }

                                XmlQualifiedName parentQualifiedName = new XmlQualifiedName(parentRef, parentNamespace);

                                // add the explicit parent to the list of parents for this attribute
                                attributeInfo.AddParent(parentQualifiedName);

                                // add this attribute to the list of extended attributes for its parent
                                XmlSchemaElementInfo parentElementInfo = (XmlSchemaElementInfo)this.elements[parentQualifiedName];
                                if (parentElementInfo == null)
                                {
                                    throw new ApplicationException(String.Format("The parent element {0} is not defined.", parentQualifiedName));
                                }
                                parentElementInfo.AddExtendedAttribute(attribute);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Write the documentation file for an attribute.
        /// </summary>
        /// <param name="schema">The parent schema of the attribute.</param>
        /// <param name="attribute">The attribute.</param>
        /// <param name="attributeInfo">Extra information about the attribute.</param>
        private void WriteAttributeDoc(XmlSchema schema, XmlSchemaAttribute attribute, XmlSchemaAttributeInfo attributeInfo)
        {
            StringBuilder content;
            using (XmlWriter writer = CreateXmlWriter(out content))
            {
                writer.WriteStartElement("dl");
                this.WriteDescription(attribute, writer);
                this.WriteWIReferences(attribute, writer);
                this.WriteParents(attributeInfo.Parents, writer);
                this.WriteRemarks(attribute, writer);
                this.WriteHowTos(schema, attribute, writer);
                this.WriteSeeAlso(schema, attribute, writer);
                writer.WriteEndElement();
            }

            string mdFile = this.GetSchemaMarkdownFile(schema, attribute.Name);
            string layout = (this.mainSchemas.Contains(schema) ? MainLayout : ExtensionLayout);
            WriteContentFile(mdFile, this.GetTitleWithExtension(attribute.Name, "Attribute", schema), layout, content);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Write the documentation file for an attribute.
        /// </summary>
        /// <param name="schema">The parent schema of the attribute.</param>
        /// <param name="attribute">The attribute.</param>
        /// <param name="attributeInfo">Extra information about the attribute.</param>
        private void WriteAttributeDoc(XmlSchema schema, XmlSchemaAttribute attribute, XmlSchemaAttributeInfo attributeInfo)
        {
            string htmlFile = this.GetSchemaHtmlFile(schema, attribute.Name);

            XmlTextWriter writer = null;
            try
            {
                string headerClass = (this.mainSchemas.Contains(schema) ? "elementHeader" : "extensionHeader");
                writer = StartHtmlWriter(htmlFile, this.GetTitleWithExtension(attribute.Name, "Attribute", schema), headerClass);

                writer.WriteStartElement("dl");
                this.WriteDescription(attribute, writer);
                this.WriteWIReferences(attribute, writer);
                this.WriteParents(attributeInfo.Parents, writer);
                this.WriteRemarks(attribute, writer);
                this.WriteHowTos(schema, attribute, writer);
                this.WriteSeeAlso(schema, attribute, writer);
                writer.WriteEndElement();

                this.WriteVersion(writer);

                EndHtmlWriter(writer);
            }
            finally
            {
                if (null != writer)
                {
                    writer.Close();
                }
            }
        }