質問

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