Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / October 2005

Tip: Looking for answers? Try searching our database.

need help on how to add comment to xml schema with C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
comic_rage@yahoo.com - 30 Oct 2005 18:58 GMT
how do you add a comment line/section to an xml schema xsd file?

like this

    <!-- ===============================================================
-->
    <!-- ===================  My comment line   ========================
-->
    <!-- ===============================================================
-->

I like to add a section before each element. Currently, I am creating a
large xsd file with many elements.

Thanks
Oleg Tkachenko [MVP] - 31 Oct 2005 10:07 GMT
> how do you add a comment line/section to an xml schema xsd file?
>
[quoted text clipped - 9 lines]
> I like to add a section before each element. Currently, I am creating a
> large xsd file with many elements.

How do you create it?

Signature

Oleg Tkachenko [XML MVP, MCAD]
http://www.XmlLab.Net | http://www.XLinq.Net | http://blog.tkachenko.com

Martin Honnen - 31 Oct 2005 14:22 GMT
> how do you add a comment line/section to an xml schema xsd file?

If you treat an XSD document as a normal XML document that your create
or manipulate with APIs like XmlTextWriter or the DOM/XmlDocument then
you can create comments as usual, for XmlTextWriter you can use WriteComment
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fSystemXmlXmlTextWriterClassWriteCommentTopic.asp
>
for the DOM you can use CreateComment
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fSystemXmlXmlDocumentClassCreateCommentTopic.asp
>

If you are using the Schema Object Model (SOM) then as far as I am
currently aware there are no ways in .NET to have top level comments
created, however you should be able to include comments in the
documentation e.g. the following code snippet

    XmlSchema xmlSchema = new XmlSchema();
    XmlSchemaAnnotation annotation = new XmlSchemaAnnotation();
    XmlSchemaDocumentation documentation = new XmlSchemaDocumentation();
    XmlDocument helperDocument = new XmlDocument();
    XmlComment comment = helperDocument.CreateComment(
"Schema comment 1");
    documentation.Markup = new XmlNode[1] { comment };
    annotation.Items.Add(documentation);
    xmlSchema.Items.Add(annotation);

    xmlSchema.Compile(new ValidationEventHandler(ValidationHandler));

    xmlSchema.Write(Console.Out);

yields the schema

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
    <xs:documentation>
      <!--Schema comment 1-->
    </xs:documentation>
  </xs:annotation>
</xs:schema>

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.