Generate XML Schema with documentation

独自空忆成欢 提交于 2019-12-05 01:06:51

问题


Is there a way to generate XML Schema(xsd) with documentation(<xsd:annotation> / <xsd:documentation>) from javadoc comments in classes? I know the reverse is possible (i.e generation classes with javadoc comments from xsd with comments).

Please advice.


回答1:


Using the JAXBContext.generateSchema(SchemaOutputResolver) API it is not possible for Javadoc comments to be included in <xsd:documentation> sections. The reason for this is that there isn't any API available to introspect the Java class/field/property to get the information in the comments.




回答2:


When javadoc doesn't work: How about an annotation (something like @XmlDocumentation(lang="en" content="..."))?




回答3:


Yes, it is possible right now with the jaxb2-maven-plugin

http://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.2/index.html

But the recommendation is to use the XmlType annotation, for me the javadocs were working only when i dont use the attribute name of this annotation. I think is a bug with the default javadoc renderer.



来源:https://stackoverflow.com/questions/5244949/generate-xml-schema-with-documentation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!