将本体类与xml文档节点进行比较

编程入门 行业动态 更新时间:2024-10-23 17:36:26
本文介绍了将本体类与xml文档节点进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的目标是通过从文档中搜索与本体类同名的节点来将本体与提供的XML文档进行比较.为此,我使用以下代码:

My objective is to compare an ontology to a provided XML document by searching nodes from the document having the same name as the ontology classes. To do so, I use the following code :

public void freqConcept(String xmldoc,OWLClass node){ try { String filepath = xmldoc; DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.parse(filepath); doc.getDocumentElement().normalize(); list = doc.getElementsByTagName(node.getIRI().getFragment()); } catch (ParserConfigurationException pce) { pce.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } catch (SAXException sae) { sae.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }

如您所见,我给函数提供了一个OWLClass作为参数,然后我尝试使用此行从具有相同名称的XML文档返回节点:list = doc.getElementsByTagName(node.getIRI().getFragment()); 它适用于People Ontology,因为上一行将类的名称返回为String.但是我注意到,当我尝试返回此node.getIRI().getFragment()时,来自DBPedia的类得到的是 null ,而不是具有类名,仅针对某些类而不是全部.结果,只有具有正确名称的类才被计数并存储在列表中,其他类构成例外...

As you can see I give to the function an OWLClass as a parameter, then I try to return nodes from the XML document having the same name by using this line: list = doc.getElementsByTagName(node.getIRI().getFragment()); It works for People Ontology since the previous line returns the name of classes as String. But I notice that classes from DBPedia when I try to return this node.getIRI().getFragment() I get null instead of having names of classes, just for some classes not all of them. As result only classes with correct names are counted and stored in the list the others constitute the exception ...

下面的图片显示了结果..仅正确地返回了一个类 SpatialThing ,其他类为null,无法理解为什么...

The picture below shows the result.. just one classe SpatialThing is correctly returned for the others is null, can't understand why...

我想知道是否有一种方法可以将OWLClass视为节点,或者是否可以将OWLClass与xml文档节点进行比较?

I'm wondering if there is a way to treat an OWLClass as a node or other possibility to compare the OWLClass with the xml document nodes ??

谢谢

推荐答案

某些IRI没有片段.这是设计使然,并在javadoc中进行了描述.

Some IRIs do not have fragments. This is by design and is described in the javadoc.

您将不得不找出一些无法解决的情况,然后找到您想要匹配的XML的示例.然后,您也许可以找到解决方案.

You'll have to find a few cases where this does not work, then find an example of the XML you wish to match. Then you might be able to find a solution.

更多推荐

将本体类与xml文档节点进行比较

本文发布于:2023-10-23 14:01:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1521031.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:本体   节点   文档   xml

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!