0

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.

ModdyFire
  • 706
  • 3
  • 9
  • 19
  • Please show us what you have tried. Include code snippets and a description of what went wrong. – kimbert May 12 '20 at 12:24
  • I haven't tried anything. I didn't see any method that seems to create an XSDSchema. XSDSchemaImpl() is private. – ModdyFire May 14 '20 at 22:16
  • This is a very mature Eclipse project. There must be some documentation? Have you not got any docs or sample projects? – kimbert May 15 '20 at 16:14
  • I got javadoc. I couldn't find and sample that reads an XSD file – ModdyFire May 17 '20 at 08:17
  • Fair enough - I struggled to find the samples as well. There are some dead links in the docs. Maybe this will help: https://wiki.eclipse.org/MDT-XSD-FAQ#How_can_I_load_a_XSDSchema_from_a_simple_Java_String_or_from_a_DOM_Tree.3F – kimbert May 17 '20 at 22:15
  • Exactly. The code you linked to doesn't compile BTW - XSDPackage.eINSTANCE.createXSDSchema() doesn't exist. – ModdyFire May 18 '20 at 22:21

1 Answers1

0

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());
ModdyFire
  • 706
  • 3
  • 9
  • 19