用于处理分类法的 Java API
寻找可以帮助我处理分类法的 API。应该可以在对象模型中使用分类法(从 xml 文件加载)、列出类别、遍历类别树(如果是树分类法)、获取类别的名称和值等。只读模式就足够了。谷歌并没有提供太多帮助:(
用法可以如下:
分类taxonomy = Taxonomy.loadFromStream(XMLInputStream);
列出类别 =taxonomy.listAllCategories();
类别 rootCategory =taxonomy.getRootCategory();
重要的是我不想直接处理 XML。没用的。如果有一些 YAML 适配器,分类可以采用 YAML 格式,并且我的代码不受影响...
Looking for API that helps me with processing of taxonomies. It should be possible to work with taxonomy in object model (loading from xml file), list categories, traverse tree of categories (if it's tree taxonomy), getting name and value for category, etc. Read only mode is sufficient. Google hasn't helped a lot :(
Usage can be as follows:
Taxonomy taxonomy = Taxonomy.loadFromStream(XMLInputStream);
List categories = taxonomy.listAllCategories();
Category rootCategory = taxonomy.getRootCategory();
What's important about it is that I don't want to handle XML directly. It's useless. If there will be some YAML adapter, taxonomy can be in YAML format and my code stays unaffected...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为您永远不会找到基于 XML 的分类库:它太具体了。
但是,您可以在诸如 XStream 之类的库之上自行实现分类模型 a href="http://jaxb.java.net/" rel="nofollow noreferrer">JAXB 以便序列化为 XML,而无需编写详细的 XML 操作代码。
I don't think that you will ever find an XML based library for taxonomy: it is too specific.
However you can implement taxonomy model yourself on top of a library like XStream of JAXB in order to serialize to XML without writing verbose XML manipulation code.
如果您找不到专门用于分类的内容,请尝试对本体进行同样的操作。然后您可以创建仅具有分类关系的本体。
OWL API (http://owlapi.sourceforge.net/) 似乎可以解决这个问题。您可以创建 OWL 本体,并使用 OWL/XML 解析器和编写器轻松地将其转换为 XML 并返回。这是使用此库创建层次结构的示例: https://github.com/owlcs/owlapi/blob/master/contract/src/test/java/uk/ac/manchester/owl/owlapi/ Tutorial/examples/SimpleHierarchyExample.java
希望有帮助。
If you cannot find something specifically for taxonomies, try doing the same for ontologies. Then you can create an ontology with only taxonomic relations.
The OWL API (http://owlapi.sourceforge.net/) seems to solve the problem. You can create and OWL ontology and easily convert it to XML and back using their OWL/XML parser and writer. And here is an example of creating a hierarchy with this library: https://github.com/owlcs/owlapi/blob/master/contract/src/test/java/uk/ac/manchester/owl/owlapi/tutorial/examples/SimpleHierarchyExample.java
Hope that helps.
从我最近的开发来看,我不得不说 Flex 开发环境(有很多关于入门的在线资源)。我知道它并不是真正的 Java,因为它与 Flash 类似,但它基于与 Java 类似的 ActionScript。此外,Flex还具有与外部JavaScript资源通信的能力,并且对于XML资源的处理非常直观。
在 Java 中,我使用了 Java SDK 附带的标准 DOM 解析器(我相信它基于 Xerces 解析器),但至少可以说它们使用起来很麻烦。
From my recent development, I've got to say I'm impressed with the Flex development environment (there are a lot of online resources about getting started with it). I know it's not really Java because it's similar to Flash, but it's based on ActionScript which is similar to Java. In addition, Flex and has the ability to communicate with external JavaScript resources, and is really intuitive for processing of XML resources.
In Java, I have used the standard DOM parsers that come with Java SDK (which I believe are based on the Xerces parser), but they were a hassle to use to say the least.
我想 JDom 可以帮助你。
查看 维基百科上的 Jdom 、JDom javadoc
I think JDom may help you.
Look at Jdom at Wikipedia , JDom javadoc