开发者

How to programmatically determine all valid XML nodes from a schema

Is there an existing Java library that will let me determine all valid nodes for a p开发者_JS百科oint in an XML document (specified by XPath, or otherwise), given an XML schema?


This isn't a very helpful answer - hopefully something better will come along.

I don't think what you want is out there in an easily usable form. Obviously, the functionality is embedded in various editors, but not necessarily in a form that's easily and/or legally reusable.

If you were to try to roll your own, you'd probably want to start with a pre-built XSD object model if possible. There are three that I'm aware of. I've used none - just thought I was going to but ended up not.

XSOM is the one best wrapped for reuse. FWIW, it's by the enviably prolific Kohsuke Kawaguchi, creator of Hudson/Jenkins and a bunch of other stuff.

There's also one embedded in Xerces, and one in the Eclipse XML support. In both cases, my ill-informed opinion is that documentation is sketchy and reuse, while theoretically possible, is not something the authors have paid much attention to supporting.


check javax.xml.validation and the XPath libraries at javax.xml.xpath

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜