public class XsdAnnotationProcessor extends Object implements NodeProcessor
Node processor that injects XSD documentation annotations consisting of JavaDoc harvested Java source code into ComplexTypes, Elements and Attributes. The documentation is injected as follows:
Thus, the following 'vanilla'-generated XSD:
<xs:complexType name="somewhatNamedPerson">
<xs:sequence>
<xs:element name="firstName" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="lastName" type="xs:string"/>
</xs:sequence>
<xs:attribute name="age" type="xs:int" use="required"/>
</xs:complexType>
... would be converted to the following annotated XSD, given a DefaultJavaDocRenderer:
<xs:complexType name="somewhatNamedPerson">
<xs:annotation>
<xs:documentation><![CDATA[Definition of a person with lastName and age, and optionally a firstName as well...
(author): <a href="mailto:lj@jguru.se">Lennart Jörelid</a>, jGuru Europe AB
(custom): A custom JavaDoc annotation.]]></xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element minOccurs="0" name="firstName" nillable="true" type="xs:string">
<xs:annotation>
<xs:documentation><![CDATA[The first name of the SomewhatNamedPerson.]]></xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="lastName" type="xs:string">
<xs:annotation>
<xs:documentation><![CDATA[The last name of the SomewhatNamedPerson.]]></xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="age" type="xs:int" use="required">
<xs:annotation>
<xs:documentation><![CDATA[The age of the SomewhatNamedPerson. Must be positive.]]></xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
... given that the Java class SomewhatNamedPerson
has JavaDoc on its class and fields
corresponding to the injected XSD annotation/documentation elements.
JavaDocRenderer
Modifier and Type | Field and Description |
---|---|
static String |
ANNOTATION_ELEMENT_NAME
The name of the annotation element.
|
static String |
DOCUMENTATION_ELEMENT_NAME
The name of the documentation element.
|
static String |
XSD_SCHEMA_NAMESPACE_PREFIX
The namespace schema prefix for the URI
http://www.w3.org/2001/XMLSchema
(i.e. |
Constructor and Description |
---|
XsdAnnotationProcessor(SearchableDocumentation docs,
JavaDocRenderer renderer)
Creates an XsdAnnotationProcessor 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)
Defines if this visitor should process the provided node.
|
void |
process(Node aNode)
Processes the provided DOM Node.
|
public static final String XSD_SCHEMA_NAMESPACE_PREFIX
http://www.w3.org/2001/XMLSchema
(i.e. XMLConstants.W3C_XML_SCHEMA_NS_URI
).public static final String ANNOTATION_ELEMENT_NAME
public static final String DOCUMENTATION_ELEMENT_NAME
public XsdAnnotationProcessor(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)
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–2015 MojoHaus. All rights reserved.