public class XsdEnumerationAnnotationProcessor extends Object implements NodeProcessor
Node processor that injects XSD documentation annotations consisting of JavaDoc harvested Java source code into SimpleTypes, Elements and Attributes typically produced by SchemaGen when generate XSDs for Java Enumerations. The documentation is injected as follows:
Thus, the following 'vanilla'-generated XSD:
<xs:simpleType name="foodPreference">
<xs:restriction base="xs:string">
<xs:enumeration value="NONE"/>
<xs:enumeration value="VEGAN"/>
<xs:enumeration value="LACTO_VEGETARIAN"/>
</xs:restriction>
</xs:simpleType>
... will be converted in a manner similar to the one below:
<xs:simpleType name="foodPreference">
<xs:annotation>
<xs:documentation><![CDATA[Simple enumeration example defining some Food preferences.]]></xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="LACTO_VEGETARIAN">
<xs:annotation>
<xs:documentation><![CDATA[Vegetarian who will not eat meats, but drinks milk.]]></xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="NONE">
<xs:annotation>
<xs:documentation><![CDATA[No special food preferences; eats everything.]]></xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="VEGAN">
<xs:annotation>
<xs:documentation><![CDATA[Vegan who will neither eat meats nor drink milk.]]></xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
... given that the Java class FoodPreference
has JavaDoc on its class and fields
corresponding to the injected XSD annotation/documentation elements.
Constructor and Description |
---|
XsdEnumerationAnnotationProcessor(SearchableDocumentation docs,
JavaDocRenderer renderer)
Creates an XsdEnumerationAnnotationProcessor that uses the supplied/generated SearchableDocumentation to read all
JavaDoc structures and the supplied JavaDocRenderer to render JavaDocs into XSD documentation annotations.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(Node aNode)
Only accept simpleTypes which are restrictions to either
xs:string or xs:integer . |
void |
process(Node aNode)
Processes the provided DOM Node.
|
public XsdEnumerationAnnotationProcessor(SearchableDocumentation docs, JavaDocRenderer renderer)
docs
- A non-null SearchableDocumentation, produced from the source code of the JAXB compilation unit.renderer
- A non-null JavaDocRenderer, used to render the JavaDocData within the SearchableDocumentation.public boolean accept(Node aNode)
Only accept simpleTypes which are restrictions to either xs:string
or xs:integer
.
The former is generated by JAXB when the Java Enum uses String values, and the latter is used
for ordinal values.
accept
in interface NodeProcessor
aNode
- The DOM node to process.true
if the provided Node should be processed by this NodeProcessor.public void process(Node aNode)
process
in interface NodeProcessor
aNode
- The DOM Node to process.Copyright © 2005–2018 MojoHaus. All rights reserved.