473,372 Members | 1,188 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,372 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 17770
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.