Write a comment in XSD that will appear in auto-generated XML?

srinathshil picture srinathshil · May 8, 2016 · Viewed 12k times · Source

How can I write a comment in XML schema as below and that needs to be displayed in XML when we generate XML from XML Schema using Oxygen XML editor.

< THIS is a request for BUSINESS >

Above is displayed in comment tag

Answer

kjhughes picture kjhughes · May 8, 2016

Note first that your requested "comment" should instead be

<!-- < THIS is a request for BUSINESS > -->

as the form you request would not be allowed in XML (but perhaps that was what you intended anyway when you mentioned that the "above is displayed in comment tag").

The purpose of an XSD is to validate an XML document. While tools can, and have, been written to generate a valid XML document from an XSD, there is no reason to expect such tools to pass comments or annotations through to the XML documents they create.

Consider instead an XSLT script to augment the generated XML with the additional comments you wish to add.