문제

i know that you can generate Java classes from an XSD file with JAXB or similar methods and then use them with your resulting XML files. That's not what i'm looking for though.

I was wondering if it is possible to generate a generic Java representation of the XSD itself and if there are programs that parse any random XSD and fill the Java classes with it.

For example, let's take this short excerpt from an XSD:

<xs:complexType name="pc-type">
    <xs:sequence>
        <xs:element name="name" type="xs:string"/>
        <xs:element name="manufacturer" type="xs:string"/>
    </xs:sequence>
    <xs:attribute name="id" type="xs:integer"/>
</xs:complexType>

A Java representation could be something like:

public class ComplexType{
    String name;
    List<Attribute> attributes;
    List<Element> elements;
    ...
}

Does something like this exist?

도움이 되었습니까?

해결책

There is a XSD for XSD. You can generate the JAXB classes from this xsd.xsd.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top