Ignore:
Timestamp:
2016-08-04T11:41:02+12:00 (8 years ago)
Author:
kjdon
Message:

if att value is null for getNamedElement, will now return the first one with the specified attribute, regardless of value

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSXML.java

    r30629 r30666  
    140140    public static final String LANG_ATT = "lang";
    141141  public static final String KEY_ATT = "key";
     142  public static final String DICTIONARY_ATT = "dictionary";
    142143    public static final String HREF_ATT = "href";
    143144    public static final String TYPE_ATT = "type";
     
    10471048    }
    10481049
    1049     /** returns the element parent/node_name[@attribute_name='attribute_value'] */
     1050    /** returns the element parent/node_name[@attribute_name='attribute_value']
     1051     if attribute_value is null, just returns the first one with that attribute */
    10501052    public static Element getNamedElement(Element parent, String node_name, String attribute_name, String attribute_value)
    10511053    {
     
    10571059            if (child.getNodeName().equals(node_name))
    10581060            {
    1059                 if (((Element) child).getAttribute(attribute_name).equals(attribute_value))
    1060                     return (Element) child;
    1061             }
    1062         }
     1061              String att_val = ((Element) child).getAttribute(attribute_name);
     1062              if (!att_val.equals("") ) {
     1063                if (attribute_value == null || att_val.equals(attribute_value)) {
     1064                  return (Element) child;
     1065                }
     1066              }
     1067            }
     1068        } // for each child
    10631069        // not found
    10641070        return null;
Note: See TracChangeset for help on using the changeset viewer.