开发者

Runtime binding of XML Schema to Java code

开发者 https://www.devze.com 2022-12-25 01:08 出处:网络
The situation is thus: I have an application which provides editing capabilities to XML an file. This file follows a certain Schema. The Schema belongs to a subset of Schemas which actually follow a

The situation is thus:

I have an application which provides editing capabilities to XML an file. This file follows a certain Schema. The Schema belongs to a subset of Schemas which actually follow a line of evolution from one to another - so they are not so different from one another.

The main difference between the schemas is an enumeration of string labels.

I now have need to save "meta data" in XML format (This is a second type of XML file). This "meta data" contains a list of labels from the set enumerated in the schema.

The application can accept a new schema at runtime and adjust itself.

Therefore I have an XML file that must be validated by two schemas on开发者_开发百科e static containing the basic structure of the "meta data" stored in the XML and one which contains the 'proper' label enumeration. The latter schema is determined at runtime.

I have glanced over JAXB, XMLBeans and JiBX.

I can't figure out what technology to choose that would allow for a runtime bind of code and schema in the way that would most benefit my use-case.

Any suggestions?

Thanks!


Here is an article on validation.

As for "handy objects" - well, you actually can compile an XML schema into Java classes - even with JAXB even in runtime. The problem is that you can't really profit from the classes created in the runtime since your code does not know them.

I'd be thinking in the direction of some XML Schema APIs (like XSOM).

0

精彩评论

暂无评论...
验证码 换一张
取 消