开发者

Read DTD or Schema and list all valid child elements or attributes for a given element

I want to develop an application something like XML editor.. providing intellisense like feature when user types an element, t开发者_JAVA百科he application will read the DTD or schema and list the valid child elements and attributes (something like Oxygen XML Editor).

Is there an API that i can get this done?


I'm not familiar with an API that performs this task.

If you choose to implement this yourself, however, here's a couple of thoughts:

  • An XML schema is itself an XML file, that is structured according to the meta-schema. You can easily use one of the existing APIs to unmarshal a schema into an object structure that you can easily work with in-memory.
  • A DTD is not an XML structure, but any DTD can be represented as a simple schema. Therefore you should try and find a way to convert a DTD into a schema (and apply your schema solution).

HTH


You might find XSD4J useful:

XSD4J is a library to parse XML Schema files into a structure of Java objects, convert those back into an XML DOM tree (and hence plain text) again, and allow for performing several queries on the XSD objects. The library currently supports most real-world features such as simple and complex types, type restrictions and attributes.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜