reading XSD from file using eclipse-mdt-xsd

46 Views Asked by At

I'm trying to use the MSD-XSD library for parsing XSD files, but I can't figure out how to create an XSDSchema object from an XSD file, and if there's a way to also read the xs:include files, etc.

1

There are 1 best solutions below

0
On

I found a way to do it. Not sure if this is the easiest way.

    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    docFactory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    InputSource is = new InputSource(new FileReader(file));
    Document doc = builder.parse(is);
    XSDSchema xsd = XSDSchemaImpl.createSchema(doc.getFirstChild());