开发者

In Java, how to populate available tags based on cursor location in XML using DTD?

开发者 https://www.devze.com 2023-02-25 14:47 出处:网络
I am using XOM (or JDOM) to construct an XML editor. I am trying to allow user to avoid typing in XML code, but select available tags from a side-pane to insert tags/attributes into the XML code. The

I am using XOM (or JDOM) to construct an XML editor. I am trying to allow user to avoid typing in XML code, but select available tags from a side-pane to insert tags/attributes into the XML code. The side pane will likely be generated from a set of DTD (or Schema) files.

Is there a module that can populate available tags开发者_开发技巧/attributes based on DTD and currently selected node location?

Thanks,

Jason


You can use Apache XMLSchema (e.g.) to wander around in a schema.

You can convert a DTD to an XML schema using trang.

To see more about how to use xml schema, I recommend reading the unit tests.

Consider for example this one. Note the call to schemaCol.getElementByQName(elementQName) to find a particular element.

To visit all the elements, you'd start with org.apache.ws.commons.schema.XmlSchema.getElements() and iterate the map.

There are much meatier examples inside of Apache CXF.

0

精彩评论

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