سؤال

XmlBeans provides access to XML schema traversal via XmlBeans.compileXsd(). That returns their SchemaTypeSystem, which allows convenient high level access to the entire schema. This is very convenient for code generation (e.g. for other languages or for other non-XML representations) among other things.

For example, you can do something like...

SchemaTypeSystem sts = XmlBeans.compileXsd(new XmlObject[] {
XmlObject.Factor.parse(xsdFile) }, XmlBeans.getBuiltInTypeSystem(), null);

You can then drill down into the SchemaTypeSystem to get at everything you need to know about he schema.

Is there something within JAXB or any of the other standard Java tooling that provides equivalent functionality? I don't simply want a DOM tree representing the schema.

Mostly, I don't want to have to drag XMLBeans into a project that is currently relying on JAXB.

هل كانت مفيدة؟

المحلول

Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB (JSR-222) expert group.

JAXB does not provide an alternative to how you have described XmlBeans.compileXsd(). The only expression of the metadata is through the annotations. You could use the JAXB APIs to generate an XML schema (see: http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JAXB/GenerateSchema), but you would require another tool to interpret it in the way you are looking for.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top