Question

I am trying to find a way to query a RNG schema while avoiding reinvention of the wheel, in order to answer basic questions such as: what elements are valid children of an XML instance element, what can/must be it's attributes and so on.

A post here raised my hopes of doing this with Jing/Trang, since I am already doing RNG validation with Jing, but after searching around I've found no source code examples which would confirm the claim and browsing API docs also did not help me much (which in turn also seems to be the only documentation bundled with Jing).

I'd really like to avoid parsing schema into my own object model to do these queries and it also seems kinda redundant since I know Jing must also be doing it somewhere. The question is how to obtain the information I require from it.

Is there another library I could use to query RNG schema from java code? Note that I'm not trying to validate instance files by using a schema, I am trying to query the schema itself.

Was it helpful?

Solution

The answer to this question would be to use RNGOM. It is an object model building API which is based on Jing. Since Jing does not expose it's internal model is seems to be the only way to avoid complete reinvention of the wheel for this use-case. You will still have to write your own code which will make the actual queries by browsing this model (as I am attempting to do now).

Learning how to utilize RNGOM is not trivial as can be seen here, but the project's code repository should make things easier (contains examples of usage).

I have unfortunately found no other library which would enable me to query a RNG schema (or at least ease the pain of doing it).

Edit 1

I ended up creating my own rng object model and a parser to generate it. It's aimed to deal with my specific use case and allows me to make queries like the ones I posted in the question. Since no other answers were offered I shall accept my own until (if at all) a better answer is posted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top