whummer / jaxb-facets

Support for extended XSD features in JAXB: facets (restrictions on simple types), annotations, asserts, ...
Other
26 stars 18 forks source link

Annotation generation #30

Closed DramaticallyDecayed closed 8 years ago

DramaticallyDecayed commented 8 years ago

If it is possible to somehow generate Java classes with @AppInfo annotation out of the xsd or wsdl file that containts these annotations? I tried to generate Java classes using the test.wsdl file from your repository but got classes only with @Document annotation over a class structure. Sorry if it is not a proper issue. Thanks in advance.

whummer commented 8 years ago

Can you please provide a short XML snippet of the WSDL file you are using in your tests? Where exactly does the <xs:appinfo> element occur in your WSDL file, and where (in which class) would you expect the @AppInfo annotation to be generated?

Assuming this is the structure of your WSDL file:

<wsdl:definitions ...>
    <wsdl:types>
        <xs:schema ...>
            <xs:complexType name="TestRequest">
                <xs:annotation id="id123">
                    <xs:appinfo source="src 1">appinfo 1</xs:appinfo>
                    ...
                </xs:annotation>
                ...
            </xs:complexType>
        ...
        </xs:schema>
    </wsdl:types>
    ...
</wsdl:definitions>

... then the <xs:appinfo> can occur only within the <xs:schema> element (e.g., within a <xs:complexType> element), not outside of it. Maybe this answers your question. Otherwise, please provide a minimal test case. Thanks

DramaticallyDecayed commented 8 years ago

Thank you for reply. I'm using test.wsdl from your project. So it has the snippet you presented. I'm running the following command: ./bin/wsimport.sh -keep -B-jaxb-facets -d ~/temp ~/IdeaProjects/jaxb-facets-master/testutils/src/test/resources/test.wsdl And I'm expecting that file ~/temp/pellcorp/com/service/personservice/TestRequest.java will have @AppoInfo annotation (just as in the file from your project ~/IdeaProjects/jaxb-facets-master/jaxb-impl/src/test/java/at/ac/tuwien/infosys/jaxb/test/TestRequest.java):

...
@Documentation("doc 3")
@AppInfo(source = "src 1", value = "appinfo 1")
@SuppressWarnings("all")
@Assert(test = "not(bar1) or not(bar2)")
public class TestRequest {
    @XmlAttribute
    public ChartType type;
...

But instead genereated file (~/temp/pellcorp/com/service/personservice/TestRequest.java) has only @Document annotation:

...
@Annotation(documentation = @Documentation("doc 3"))
public class TestRequest {

    @XmlElement(required = true)
    @Facets(pattern = "[0-9]+", whiteSpace = Facets.WhiteSpace.preserve)
...
whummer commented 8 years ago

Thanks for reporting. I have pushed a new version 898c4e05c5a164ced949c28e3c67e2d616c50479 which contains basic support for @AppInfo in generated Java classes.

When you have an element like this one:

<xs:complexType name="TestRequest">
                <xs:annotation>
                    <xs:appinfo source="src 1"><foo xmlns="myns123">appinfo 1</foo></xs:appinfo>
                    <xs:documentation source="src 1" xml:lang="en">doc 1</xs:documentation>
                </xs:annotation>
                ...

... then the generated source will look like this:

@Annotation(documentation = @Documentation("doc 1"), appinfo = @AppInfo("<foo xmlns=\"myns123\">appinfo 1</foo>"))
public class TestRequest {
...

However, there are some limitations imposed on us, due to issues in JAXB/XJC:

Version number has not been changed. To use this updated version, please clean your Maven cache in $HOME/.m2/repository and the updated version will be automatically re-downloaded.

Closing this issue for now. Please feel free to re-open if there are any other issues/questions.

DramaticallyDecayed commented 8 years ago

Thanks a lot!