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:6
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: 259
Posts Rating:8
Joined: Fri Dec 04, 2009 5:37 am
Full name: Saulius Pavalkis


Return to Code engineering

Who is online

Users browsing this forum: No registered users and 0 guests

cron