Пример #1
0
 public String getPath() {
   StringBuilder builder = new StringBuilder();
   Node current = node;
   while (current != null && current instanceof Element) {
     if (current != node) {
       builder.insert(0, "/");
     }
     builder.insert(0, current.getNodeName());
     current = current.getParentNode();
   }
   return builder.toString();
 }
Пример #2
0
 public String getValueBasedIdentifier() {
   StringBuilder builder = new StringBuilder();
   XNode current = this;
   while (current != null) {
     if (current != this) {
       builder.insert(0, "_");
     }
     String value =
         current.getStringAttribute(
             "id",
             current.getStringAttribute("value", current.getStringAttribute("property", null)));
     if (value != null) {
       builder.insert(0, "]");
       builder.insert(0, value);
       builder.insert(0, "[");
     }
     builder.insert(0, current.getName());
     current = current.getParent();
   }
   return builder.toString();
 }