0

I am having a WSDL which I must use and not modify.

In the WSDL there is a type 'TextType' defined without any elements. This 'TextType' is actually meant as simple String (which is only described in a separate documentation file)

  <xs:complexType name="TextType">
  </xs:complexType>

TextType is then used in XSD file as usual:

    <xs:complexType name="AnschriftType">
      <xs:element name="Strasse" type="xs:string"/>
    </xs:complexType>

I know, this WSDL is not really usable nor a good design. The provider of this WSDL already changed it in a newer version. But anyway I have to stick on that faulty version :-/

From this JXB generates theses Pojos:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "TextType")
public class TextType {
}

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AnschriftType" propOrder={...})
public class AnschriftType {

    @XmlElement(name = "Strasse")
    protected TextType strasse;

    public TextType getStrasse() {
        return strasse;
    }

    public void setStrasse(TextType value) {
        this.strasse = value;
    }
}

Is it somehow possible to let JAXB generate the Pojos with 'String' instead of 'TextType'?

I already tried something but didn't work so far...

1)

    <jaxb:bindings node="xs:complexType[@name='TextType']">
        <jaxb:class name="String" implClass="java.lang.String"/>
    </jaxb:bindings>
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AnschriftType" propOrder={...})
public class AnschriftType {

    @XmlElement(name = "Strasse", type = java.lang.String.class)
    protected java.lang.String strasse;

    public package.of.xsd.String getStrasse() {
        return strasse;
    }

    public void setStrasse(package.of.xsd.String value) {
        this.strasse = ((java.lang.String) value);
    }
}
    <jaxb:bindings node="xs:complexType[@name='TextType']">
        <jaxb:property>
            <jaxb:baseType name="java.lang.String"/>
        </jaxb:property>
    </jaxb:bindings>
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AnschriftType" propOrder={...})
public class AnschriftType {

    @XmlElement(name = "Strasse")
    protected TextType strasse;

    public TextType getStrasse() {
        return strasse;
    }

    public void setStrasse(TextType value) {
        this.strasse = value;
    }
}
4
  • Could you create MRE with this ? Thanks Commented Oct 1, 2024 at 8:29
  • What do you mean with "MRE"? Commented Oct 1, 2024 at 11:49
  • Sorry : Minimal Reproductible Example 😄 Commented Oct 1, 2024 at 14:47
  • Hi @LaurentSchoelens. Sorry for the delay. Here ist the MRE :-) github.com/sentinel0815/xsd-texttype Commented Oct 8, 2024 at 12:05

0

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.