[quoted text, click to view] comic_rage@yahoo.com wrote:
> I am trying to add an annotation with a documentation, which contains
> several nodes. So far, I having a problem on how to code this with C#.
Here is a simple example:
XmlSchema schema = new XmlSchema();
XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();
XmlSchemaDocumentation documentation = new XmlSchemaDocumentation();
XmlDocument xmlDocument = new XmlDocument();
XmlElement xhtmlParagraph1 = xmlDocument.CreateElement("p",
"
http://www.w3.org/1999/xhtml");
xhtmlParagraph1.AppendChild(xmlDocument.CreateTextNode(
"This is a schema example."));
XmlElement xhtmlParagraph2 = xmlDocument.CreateElement("p",
"
http://www.w3.org/1999/xhtml");
xhtmlParagraph2.AppendChild(xmlDocument.CreateTextNode(
"Kibology for all."));
documentation.Markup = new XmlNode[2] {xhtmlParagraph1,
xhtmlParagraph2};
annotation.Items.Add(documentation);
schema.Items.Add(annotation);
schema.Compile(new ValidationEventHandler(ValidationHandler));
XmlNamespaceManager namespaceManager = new XmlNamespaceManager(new
NameTable());
namespaceManager.AddNamespace("xs", XmlSchema.Namespace);
namespaceManager.AddNamespace("xhtml", "
http://www.w3.org/1999/xhtml");
schema.Write(Console.Out, namespaceManager);
Schema generated is
<xs:schema xmlns:xhtml="
http://www.w3.org/1999/xhtml" xmlns:xs="
http://www.w3.org/2001/XMLSchema"> <xs:annotation>
<xs:documentation>
<p xmlns="
http://www.w3.org/1999/xhtml">This is a schema example.</p>
<p xmlns="
http://www.w3.org/1999/xhtml">Kibology for all.</p>
</xs:documentation>
</xs:annotation>
</xs:schema>
--
Martin Honnen --- MVP XML