Changeset 29522


Ignore:
Timestamp:
2014-12-03T12:40:42+13:00 (9 years ago)
Author:
kjdon
Message:

need to check that namespaceURI is not null before using it, new method, getMetadataValue - get a metadata value from a metadata list

File:
1 edited

Legend:

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

    r29306 r29522  
    10411041        {
    10421042            Node child = children.item(i);
    1043             if (child.getNodeType() == Node.ELEMENT_NODE && child.getNamespaceURI().equals(namespace_uri) && child.getLocalName().equals(node_local_name))
     1043            if (child.getNodeType() == Node.ELEMENT_NODE && child.getNamespaceURI() != null && child.getNamespaceURI().equals(namespace_uri) && child.getLocalName().equals(node_local_name))
    10441044            {
    10451045                if (((Element) child).getAttribute(attribute_name).equals(attribute_value))
     
    10581058        {
    10591059            Node child = children.item(i);
    1060             if (child.getNodeType() == Node.ELEMENT_NODE && child.getNamespaceURI().equals(namespace_uri) && child.getLocalName().equals(node_local_name))
     1060            if (child.getNodeType() == Node.ELEMENT_NODE && child.getNamespaceURI() != null && child.getNamespaceURI().equals(namespace_uri) && child.getLocalName().equals(node_local_name))
    10611061            {
    10621062                if (((Element) child).getAttribute(attribute_name).equals(attribute_value))
     
    11411141        {
    11421142            Node child = children.item(i);
    1143             if (child.getNodeType() == Node.ELEMENT_NODE && child.getNamespaceURI().equals(namespace) && child.getLocalName() != null && child.getLocalName().equals(node_local_name))
     1143            if (child.getNodeType() == Node.ELEMENT_NODE && child.getNamespaceURI() != null && child.getNamespaceURI().equals(namespace) && child.getLocalName() != null && child.getLocalName().equals(node_local_name))
    11441144            {
    11451145                if (((Element) child).getAttribute(attribute_name).equals(attribute_value))
     
    12201220    }
    12211221
     1222  public static String getMetadataValue(Element metadata_list, String name) {
     1223    Element meta = getNamedElement(metadata_list, METADATA_ELEM, NAME_ATT, name);
     1224    if (meta == null) {
     1225      return "";
     1226    }
     1227    String att_value = meta.getAttribute(VALUE_ATT);
     1228    if (att_value.equals("")) {
     1229      // try the text
     1230      att_value = getNodeText(meta);
     1231    }
     1232    return att_value;
     1233  }
    12221234    /**
    12231235     * Returns the appropriate language element from a display elem, display is
Note: See TracChangeset for help on using the changeset viewer.