473,394 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

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

Nov 12 '05 #1
2 17778
co********@yahoo.com wrote:
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.


How do you create it?

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.XmlLab.Net | http://www.XLinq.Net | http://blog.tkachenko.com
Nov 12 '05 #2


co********@yahoo.com wrote:
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/frlrfSystemXmlXmlTextWriterClassWriteCommentTopic. asp>
for the DOM you can use CreateComment
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlDocumentClassCreateCommentTopic.a sp>

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>
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Tad Marko | last post by:
Howdy! I'm trying to get my head around Python and I've come to realize that there are a lot of idioms in Python that are a bit different than in other languages. I have a class similar to what...
13
by: Christoph Brunner | last post by:
Hi, on the sun homepage i had submit to the bugparade a request for feature enhancement for the JAXB API. After a period of time sun called me to post my request to a newsgroup an get comments...
9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
1
by: comic_rage | last post by:
Hi, I am writing C# code to produce xml schema. //Create attribute XmlSchemaAttribute att2 = new XmlSchemaAttribute(); att2.Name = "CustomerID"; att2.SchemaTypeName = new...
0
by: comic_rage | last post by:
Hi, I need to use C# to print the xml schema root <?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="http://www.ciber.com/myfile" xmlns="http://www.ciber.com/myfile"...
1
by: Rohit Raghuwanshi | last post by:
Hello all, we are running a delphi application with DB2 V8.01 which is causing deadlocks when rows are being inserted into a table. Attaching the Event Monitor Log (DEADLOCKS WITH DETAILS) here....
12
by: Noel | last post by:
Hello, I'm currently developing a web service that retrieves data from an employee table. I would like to send and retrieve a custom employee class to/from the webservice. I have currently coded...
13
by: Ray Cassick \(Home\) | last post by:
I have been using XML Comments in VB.NET during my time with VS.NET 2003 thanks to VBXC and NDoc. I just started to upgrade one of my projects into VB.NET 2005 and am seeing some odd errors...
4
by: Hemant Shah | last post by:
Folks, I am having problem with an application that uses static SQL, the application basically browses through the table given start and end key most of the time it is processed from begining to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.