XML comments insertion / generation ?

General discussions about code engineering

Moderator: Moderators

XML comments insertion / generation ?

Postby deckerbd » Thu Apr 21, 2011 8:33 am

Am doing an XML schema project using Magic Draw. I am currently running the MD + SYSML + UPDM all at the 17.0SP1 version.

I would like to know how to insert "XML Comment" blocks bounded by the XML comment block tags "<!--" and "-->" into the XML Schema diagram objects so they end up generated into the .xsd files that result from running Code Generation. I assume there is a way to add these to some diagram object so they end up in the generated .xsd file.

One of my requirements is that my .xsd files have comment blocks at the top containing author and change history information.

I have tried putting the information into the File View component objects representing the .xsd files using the "Documentation" attribute but nothing ends up in the generated .xsd files.

If this is not possible in MagicDraw please advise as well so that I can determine how to insert these into the generated .xsd files via other means.

Thanks,
Brian Decker
deckerbd
Forum Newbie
Forum Newbie
 
Posts: 20
Posts Rating:0
Joined: Tue Jun 15, 2010 10:50 am

Re: XML comments insertion / generation ?

Postby TomasJkn » Thu Apr 28, 2011 3:02 am

Hello Brian,

Unfortunately, MagicDraw can not model/generate XML comments directly. It can, however, generate <annotation> elements for the generated XML schema elements (annotation elements are generated form the element documentation in the model).

If you are proficient with XSLT, you could do the following trick as a workaround:
place your comment texts in the element documentation in the model, generate schema with MagicDraw as usual (comment texts will go into <annotation>s).
Then write an XSL transformation (converting <annotation>s into <!-- --> comments where necessary) and pass your generated schemas through it.

Here are a couple of helpful pointers how to handle comments in XSLT:
http://wiki.orbeon.com/forms/doc/develo ... l-comments
http://stackoverflow.com/questions/3837 ... n-xml-file
Tomas Juknevicius
Senior Systems Analyst
No Magic Europe
TomasJkn
Customer Support
Customer Support
 
Posts: 63
Posts Rating:7
Joined: Mon May 10, 2010 9:24 am

Re: XML comments insertion / generation ?

Postby deckerbd » Mon May 23, 2011 9:48 am

Thank you for the implementation. Most efficient path I may have to open the generated XSD file in an XML editor and manually insert the required comments at the top. Not a huge problem but it would be nice if there was a way to attach actual "comments' - not Documentation to XSD code object or schemas to meet the need in a future version.
deckerbd
Forum Newbie
Forum Newbie
 
Posts: 20
Posts Rating:0
Joined: Tue Jun 15, 2010 10:50 am

Re: XML comments insertion / generation ?

Postby saulius_p » Tue May 24, 2011 2:35 am

Dear Brian,

Thank you for valuable feedback. We share your point of view on this issue. In future we are planing to add ability to perform XSL transformation on XML Schema generation. It is not scheduled yet, but will be evaluated with next XML schema generation improvements.
Best regards,
Saulius Pavalkis
User avatar
saulius_p
No Magic
No Magic
 
Posts: 335
Posts Rating:13
Joined: Fri Dec 04, 2009 5:37 am
Full name: Saulius Pavalkis

Re: XML comments insertion / generation ?

Postby sudhaec9@gmail.com » Thu Jun 18, 2020 4:10 am

can generate xsd file from UML model.What about xml file ?How we will generate xml file from Model by using MagicDraw?
sudhaec9@gmail.com
Forum Newbie
Forum Newbie
 
Posts: 1
Posts Rating:1
Joined: Wed Apr 08, 2020 5:02 am

Re: XML comments insertion / generation ?

Postby boonmecarlton2@gmail.com » Tue Sep 28, 2021 10:53 pm

I need comment my function prototype (written in C/C++) with summary, returns, param tags. How can I persuade Visual Studio to insert xml tags after three forward slashes like in C#? I found one solution. When I rename xx.h xx.cs in C++ project, I can use /// for generating xml comments (IntelliSense in xml comments works too). There must be a better way, mustn’t there? It would kill me to write it manually. I’ll grateful for every useful comment. mypascoconnect official
boonmecarlton2@gmail.com
Forum Newbie
Forum Newbie
 
Posts: 1
Posts Rating:0
Joined: Tue Sep 28, 2021 10:52 pm


Return to Code engineering

Who is online

Users browsing this forum: No registered users and 0 guests