I have following passage in my java doc:
* <pre>
* {@code
* <?xml version="1.0" encoding="UTF-8"?>
* <beans xmlns="http://www.springframework.org/schema/beans"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
* xmlns:context="http://www.springframework.org/schema/context"
* xmlns:task="http://www.springframework.org/schema/task"
* xmlns:tx="http://www.springframework.org/schema/tx"
* xsi:schemaLocation="http://www.springframework.org/schema/beans
* http://www.springframework.org/schema/beans/spring-beans.xsd
* http://www.springframework.org/schema/context
* http://www.springframework.org/schema/context/spring-context.xsd
* http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
* http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
*
* <bean class="path.to.job.Class"
* id="jobBeanName" parent="baseJob">
* <!-- PROPERTIES OMITTED -->
* </bean>
*
* <task:scheduled-tasks scheduler="scheduler">
* <task:scheduled ref="jobBeanName" method="execute"
* cron="${cron_expression}" />
* </task:scheduled-tasks>
*
* </beans>
* }
* </pre>
This part should illustrate a quick guide on how a new definition should be done. Yet, for some reason, the "translation" is not complete.
This is what it results to:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<bean class="path.to.job.Class"
id="jobBeanName" parent="baseJob">
<!-- PROPERTIES OMITTED -->
</bean>
<task:scheduled-tasks scheduler="scheduler">
<task:scheduled ref="jobBeanName" method="execute"
cron="${cron_expression}" />
}
It is missing these parts:
</task:scheduled-tasks>
</beans>
And includes } which is part of {@code }.
The only way to make them visible, is by adding a space after < on both elements. Though this space is then also visible in the docs which makes it very ugly.
I checked following links:
- https://www.rgagnon.com/javadetails/java-0623.html
- http://smartkey.co.uk/development/adding-xml-to-javadoc-comments/
- https://reflectoring.io/howto-format-code-snippets-in-javadoc/
- Putting sample XML code in Javadoc
Actually I just found a way which was replacing < with < for the parts that were not displayed. Though that doesn't explain why it sometimes does work and sometimes it doesn't. Also, I am still having the fragment (}) of the {@code } part that is displayed as well.
So the question is, how should one format XML in JAVADOC without the need for "hacks" like < and having fragments that are no supposed to be shown?