3

so this is my first question. :)

I try to generate java classes from a xsd file.

So my Problem is the following. Somehow jaxb won't generate a java class for the simple type "Test".

I have two attributes within a complex type that i am interested in "Art" and "Nummer"

            <xs:attribute name="Art" use="required">
              <xs:annotation>
                <xs:documentation>Darf ausschließlich die Werte "BEL" (BEL-Leistung), "NBL"(andere, nicht in der BEL enthaltene Leistung), "EDM" (Edelmetalle oder -legierungen), "MAT" (alle anderen Materialien) oder "RBT" (Rabatt) enthalten. Jede Art kann mehrmals auftreten.</xs:documentation>
              </xs:annotation>
              <xs:simpleType>
                <xs:restriction base="Positionsart"/>
              </xs:simpleType>
            </xs:attribute>
            <xs:attribute name="Nummer" use="optional">
              <xs:annotation>
                <xs:documentation>Ausschließlich anzugeben, wenn Art="BEL". Es sind ausschließlich die offiziellen BEL-Nummern zu verwenden. BEL-Nummern müssen vierstellig übermittelt werden. Das Feld wird nicht übermittelt, wenn Art ungleich BEL ist.</xs:documentation>
              </xs:annotation>
              <xs:simpleType>
                <xs:restriction base="Test"/>
              </xs:simpleType>
            </xs:attribute>

The types are both defined at the end of the xsd:

  <xs:simpleType name="Positionsart">
  <xs:simpleType name="Test">

There is more in those two types but stackoverflow told me that it would be to much code. :)

But you can have a look at the files here:

https://www.dropbox.com/sh/u0j58gd1jo98qrn/L2Yw_-psOw

This is how the beginning of the class looks like

   @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "")
    public static class Position {

        @XmlAttribute(name = "Art", required = true)
        protected Positionsart art;
        @XmlAttribute(name = "Nummer", required = true)
        protected String nummer;

As you can see, Art is a Positionsart type like it is specified in the xsd but Number is not a Test type it is just a String.

I don't understand what the issue is. The only difference between the two attributes is that the one is required and the other is optinal, but I tried to change that already.

Also I thought that there might be a problem with the naming. The SimpleType "Test" was before named BEL2 so I tried changing the name.

Furthermore I found that in the beginning there is a dead link to a namespace, first of all the namespace is not used in this document and second of all I tried to generate the classes without this namespace.

To generate the classes I opened the command line tool, navigated to the right location and typed xjc Laborabrechnungsdaten.xsd. My Java variables are in place.

I hope someone has a suggestion.

Thanks in advance. :)

1 Answer 1

1

What's the Same?

Positionsart and Test are both simple types in your XML Schema (see: https://www.dropbox.com/sh/u0j58gd1jo98qrn/F37X8kxa67/Laborabrechnungsdaten.xsd) that extend xs:string and define an xs:enumeration of valid values.

What's Different?

The reason that a Java enum is generated for Positionsart and not Test is that the Test type contains values that are not valid Java enum values.

  <xs:enumeration value="0010"/>
  <xs:enumeration value="0018"/>

For each of these invalid values you will need to use an external binding file to specify a valid enum value. For an example see this answer I gave to a similar question on Stack Overflow

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.