Pregunta

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?

¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top