Search code examples
xmlxsdjavadocxml-documentation

How can I reference an <xs:element> into my <xs:documentation>?


I have an XSD which is used to create the corresponding classes in Java interfaces. Every element of my xsd has its own <xs:documentation>, and I was wondering if I could reference another <xs:element> into a documentation tag.

To be clearer, if I was writing this in Java Doc:

/**
This method does something nice.
If you want to do something nicer, use {@link AnotherClass#NicerMethod()}
*/
public void niceMethod()

... then when the Java Doc is created, the user could click on the link AnotherClass#NicerMethod() and go directly to the documentation of that method.

I would like to do something similar in the <xs:documentation>. For example, given this XSD:

<xs:complexType name="personinfo">
  <xs:sequence>
    <xs:element name="firstname" type="xs:string">
      <xs:annotation>
        <xs:documentation>This element is linked to @lastname</xs:documentation>
      </xs:annotation>            
    </xs:element>
    <xs:element name="lastname" type="xs:string"/>
  </xs:sequence>
</xs:complexType>

... I would like to know (if exists) the correct syntax to use on @lastname so that when the XSD documentation is generated / when Java classes are generated from this XSD, the attribute firstname would be documented with a real link to the other attribute lastname.

The only example of <xs:documentation> I could find on the web is this XSD where some elements are referenced in plain string (with namespace upfront) in the doc, but when I generate the XSD doc using such a sample I get no link, just plain text. Reading around, I can't seem to find any other example or mention to this.

Is it possible? If so, how should I do it?


Solution

  • There is no provision in XSD for specifying references to components (elements or attributes) within xsd:documentation (user metadata) or xsd:appinfo (application metadata) – you're on your own.