Changeset 4503


Ignore:
Timestamp:
2003-06-06T15:42:53+12:00 (21 years ago)
Author:
kjdon
Message:

getFullName and getFullIdentifier now take a namespace string as a parameter to be used if the element has no parent - and therefore can obtain its namespace

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/msm/MSMUtils.java

    r4487 r4503  
    408408     * @return A fully qualified identifier as a <strong>String</strong>
    409409     */
    410     static final public String getFullIdentifier(Node element) {
     410    static final public String getFullIdentifier(Node element, String namespace) {
    411411    if(element == null) {
    412412        return "Error";
     
    421421        }
    422422        return identifier + NS_SEP + getIdentifier(element);
    423     }
    424     return getIdentifier(element); // No namespace anymore
     423    }
     424    if (namespace.equals("")) {
     425        return getIdentifier(element); // No namespace anymore
     426    }
     427    return namespace + NS_SEP + getIdentifier(element);
    425428    } // static public String getFullIdentier(Node element)
    426429
    427430    /*************************************************************************/
    428     /** Method to construct an elements fully qualified name. Note that this is different from a nodes identifier. Think of name as a short, unique reference to an metadata element, whereas identifier can be much longer, language specific and non-unique.
     431    /** Method to construct an elements fully qualified name. Note that this is different from a nodes identifier. Think of name as a short, unique reference to a metadata element, whereas identifier can be much longer, language specific and non-unique.
    429432     * @param element An <strong>Element</strong> whose name we are interested in.
    430433     * @return A <strong>String</strong> representing this given elements fully namespace qualified name.
    431434     */
    432435    static final public String getFullName(Element element) {
     436    return getFullName(element, "");
     437
     438    }
     439    /*************************************************************************/
     440    /** Method to construct an elements fully qualified name. Note that this is different from a nodes identifier. Think of name as a short, unique reference to a metadata element, whereas identifier can be much longer, language specific and non-unique.
     441     * @param element An <strong>Element</strong> whose name we are interested in.
     442     * @return A <strong>String</strong> representing this given elements fully namespace qualified name.
     443     */
     444    static final public String getFullName(Element element, String def_namespace) {
    433445    if(element == null) {
    434446        return null;
     
    436448    // Get namespace for given element.
    437449    Element root = (Element)element.getParentNode();
    438     String identifier = root.getAttribute("namespace") + NS_SEP + element.getAttribute("name");
     450    String namespace = "";
     451    if (root==null) {
     452        namespace = def_namespace;
     453    }  else {
     454        namespace = root.getAttribute("namespace") ;
     455    }
     456    String identifier = namespace + NS_SEP + element.getAttribute("name");
    439457    // Get name and return it.
    440458    if(identifier.startsWith(".")) {
     
    557575    static final public String[] getStructuralDetails(MetadataSet mds, Element element) {
    558576    String details[] = new String[4];
    559     Element root = (Element)element.getParentNode();
     577    //Element root = (Element)element.getParentNode();
    560578    //details[0] = root.getAttribute("name");
    561579    //details[1] = root.getAttribute("namespace");
     
    671689    }
    672690
     691    /** can only be used to set the english value */
    673692    static final public void setIdentifier(Node element, String value) {
    674693    // Get the 'identifier' Element
     
    677696        if(node.getNodeName().equals("Attribute")) {
    678697        Element target = (Element)node;
    679         if(target.getAttribute("name").equals("identifier")) {
     698        if(target.getAttribute("name").equals("identifier") && target.getAttribute("language").equals("en")) {
    680699            Node text = target.getFirstChild();
    681700            text.setNodeValue(value);
     701            break;
    682702        }
    683703        }
Note: See TracChangeset for help on using the changeset viewer.