diff --git a/src/main/java/widoco/LODEParser.java b/src/main/java/widoco/LODEParser.java index f27d770..d783468 100644 --- a/src/main/java/widoco/LODEParser.java +++ b/src/main/java/widoco/LODEParser.java @@ -182,14 +182,14 @@ private void parse(String content, Properties langFile) { "

" + langFile.getProperty(Constants.LANG_NAMED_INDIV) + "

"); break; - /*missing: rules!*/ - case "rules": + case "swrlrules": ruleList = (getTermList(html.item(i))); - rules = (nodeToString(html.item(i))); -// rules = rules.replace( -// "

" + langFile.getProperty(Constants.LANG_NAMED_INDIV) + "

", -// "

" -// + langFile.getProperty(Constants.LANG_NAMED_INDIV) + "

"); + if (ruleList != null) { + rules = ruleList.replace( + "

" + langFile.getProperty(Constants.LANG_NAMED_INDIV) + "

", + "

" + + langFile.getProperty(Constants.LANG_NAMED_INDIV) + "

"); + } break; } } @@ -230,12 +230,28 @@ private void parse(String content, Properties langFile) { } private String getTermList(Node n) { + String AttrID = n.getAttributes().item(0).getTextContent(); NodeList divs = n.getChildNodes(); + StringBuilder swrl_list = new StringBuilder(); + boolean is_swrl = Objects.equals(AttrID, "swrlrules"); for (int j = 0; j < divs.getLength(); j++) { - if (divs.item(j).getNodeName().equals("ul")) { - return (nodeToString(divs.item(j))); + Node node = divs.item(j); + if (!is_swrl) { + if (node.getNodeName().equals("ul")) { + return (nodeToString(node)); + } + } else { + if (node.getNodeName().equals("div")) { + Node classAttribute = node.getAttributes().getNamedItem("class"); + if (classAttribute != null && classAttribute.getNodeValue().equals("entity")) { + swrl_list.append(nodeToString(node)); + } + } } } + if (is_swrl && swrl_list.length()>0) { + return swrl_list.toString(); + } return null; }