Changeset 6650


Ignore:
Timestamp:
07/06/10 09:34:33 (9 years ago)
Author:
callan
Message:

Handle namespace prefixes on nodes during parsing of the DOM.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/ome-xml/src/ome/xml/model/AbstractOMEModelObject.java

    r6543 r6650  
    9292 
    9393  /** 
    94    * Retrieves all the children of an element that have a given tag name. 
     94   * Retrieves all the children of an element that have a given tag name. If a 
     95   * tag has a namespace prefix it will be stripped prior to attempting a 
     96   * name match. 
    9597   * @param parent DOM element to retrieve tags based upon. 
    9698   * @param name Name of the tags to retrieve. 
     
    104106      Node child = children.item(i); 
    105107      if (child.getNodeType() == Node.ELEMENT_NODE 
    106           && name.equals(child.getNodeName())) { 
     108          && name.equals(stripNamespacePrefix(child.getNodeName()))) { 
    107109        toReturn.add((Element) child); 
    108110      } 
     
    110112    return toReturn; 
    111113  } 
     114 
     115  /** 
     116   * Strips the namespace prefix off of a given tag name. 
     117   * @param v Tag name to strip the prefix from if it has one. 
     118   * @return <code>v</code> with the namespace prefix stripped or <code>v</code> 
     119   * if it has none. 
     120   */ 
     121  public static String stripNamespacePrefix(String v) { 
     122    int beginIndex = v.lastIndexOf(':'); 
     123    if (beginIndex != -1) { 
     124      v = v.substring(beginIndex + 1); 
     125    } 
     126    return v; 
     127  } 
    112128} 
Note: See TracChangeset for help on using the changeset viewer.