[MOBY-guts] biomoby commit
Paul Gordon
gordonp at dev.open-bio.org
Mon Aug 17 21:08:08 UTC 2009
gordonp
Mon Aug 17 17:08:08 EDT 2009
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util
In directory dev.open-bio.org:/tmp/cvs-serv25469/src/main/ca/ucalgary/services/util
Modified Files:
RuleCreator.java
Log Message:
Provide extra suggestions for XPaths based on sibling nodes
moby-live/Java/src/main/ca/ucalgary/services/util RuleCreator.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/RuleCreator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/RuleCreator.java 2009/06/09 19:36:09 1.1
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/RuleCreator.java 2009/08/17 21:08:08 1.2
@@ -55,7 +55,7 @@
" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n");
rule.append(" <xpath>"+discoveryXPath+"</xpath>\n");
if(dataType != null && !dataType.equals(MobyTags.MOBYOBJECT)){
- rule.append(" <datatype>"+dataType+"</datatype>");
+ rule.append(" <datatype value=\""+dataType+"\"/>");
}
if(!nsXPaths.isEmpty()){
rule.append(" <namespace>\n");
@@ -128,6 +128,29 @@
suggestions.add("{-- @"+attrName+" not available --} -- Click the "+
attrName+" link, not the "+attrVal+" link in results XML to use it");
// todo: place attr in selection last
+ // suggest sibling nodes too
+ NodeList siblings = selectionNode.getParentNode().getChildNodes();
+ for(int i = 0; siblings.getLength() < 50 && i < siblings.getLength(); i++){
+ Node sibling = siblings.item(i);
+ if(sibling == selectionNode || !(sibling instanceof Element)){
+ continue;
+ }
+ if(((Element) sibling).getTextContent().length() > 0){
+ String suggestion = "../"+sibling.getNodeName()+"/text() -- The sibling node's text contents";
+ if(!suggestions.contains(suggestion)){
+ suggestions.add(suggestion);
+ }
+ }
+ NamedNodeMap sibAttrs = ((Element) sibling).getAttributes();
+ for(int j = 0; j < sibAttrs.getLength(); j++){
+ String otherAttrName = sibAttrs.item(i).getLocalName();
+ String suggestion = "../"+sibling.getNodeName()+"/@"+otherAttrName+
+ " -- The value of sibling node's attribute "+otherAttrName;
+ if(!suggestions.contains(suggestion)){
+ suggestions.add(suggestion);
+ }
+ }
+ }
}
// element selection was based on a given attribute being present (excludes case above by logic, not regex)
else if(byAttrNameMatcher.find()){
More information about the MOBY-guts
mailing list