Example usage for org.jdom2 Element getTextTrim

List of usage examples for org.jdom2 Element getTextTrim

Introduction

In this page you can find the example usage for org.jdom2 Element getTextTrim.

Prototype

public String getTextTrim() 

Source Link

Document

Returns the textual content of this element with all surrounding whitespace removed.

Usage

From source file:com.github.zdsiyan.maven.plugin.smartconfig.SmartconfigMojo.java

License:Apache License

private Smartconfig buildFastconfig() throws Exception {
    PluginParameterExpressionEvaluator pel = new PluginParameterExpressionEvaluator(session, execution);
    Smartconfig fastconfig = new Smartconfig();

    SAXBuilder builder = new SAXBuilder();
    Document doc = builder.build(config);
    Element root = doc.getRootElement();

    // use scriptEngine, maybe we can extend it, not only javascript 
    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine engine = manager.getEngineByName("javascript");

    // load profile
    List<Profile> profiles = session.getCurrentProject().getActiveProfiles();
    profiles.forEach(profile -> profile.getProperties().keySet().forEach(key -> {
        Object value = profile.getProperties().get(key);
        engine.put(key.toString(), value);
        //getLog().warn("profile:"+key);
    }));//from   w  w  w.j  a  v  a  2 s.  co  m
    // load user properties
    session.getUserProperties().keySet().forEach(key -> {
        Object value = session.getUserProperties().get(key);
        engine.put(key.toString(), value);
        //getLog().warn("user:"+key);
    });
    /* load sys properties
    session.getSystemProperties().keySet().forEach(key->{
       Object value = session.getSystemProperties().get(key);
       engine.put(key.toString(), value);
       getLog().warn("sys:"+key);
    });
    */

    session.getCurrentProject().getProperties().keySet().forEach(key -> {
        Object value = session.getCurrentProject().getProperties().get(key);
        engine.put(key.toString(), value);
        //getLog().warn("prop:"+key);
    });

    // config-file
    for (Element cf : root.getChildren()) {
        String path = String.valueOf(pel.evaluate(cf.getAttributeValue("path")));
        File file = new File(path);
        if (!file.isAbsolute()) {
            file = new File(outputDirectory, path);
        }

        boolean disable = false;
        //eval the script
        if (StringUtils.isNotEmpty(cf.getAttributeValue("disable"))) {
            Object result = engine.eval(cf.getAttributeValue("disable"));
            if (Boolean.TRUE.equals(result)) {
                disable = true;
            }
        }
        if (disable == true) {
            continue;
        }

        //rename to
        if (StringUtils.isNotEmpty(cf.getAttributeValue("replace"))) {
            String replace = String.valueOf(pel.evaluate(cf.getAttributeValue("replace")));
            //getLog().warn("filepath:"+file.getPath());
            File refile = new File(file.getParent() + File.separator + replace);
            //getLog().warn("refilepath:"+refile.getPath());
            FileUtils.rename(file, refile);
            continue;
        }

        ConfigFile.Mode mode;
        if (StringUtils.isNotEmpty(cf.getAttributeValue("mode"))) {
            mode = ConfigFile.Mode.valueOf(cf.getAttributeValue("mode"));
        } else {
            mode = toConfigMode(path.substring(path.lastIndexOf(".") + 1));
        }

        if (mode == null) {
            throw new SmartconfigException("Not found file[" + path + "] replace mode");
        }

        ConfigFile configFile = new ConfigFile(file, mode);

        for (Element rt : cf.getChildren()) {
            String expression = rt.getAttributeValue("expression");
            String value = String.valueOf(pel.evaluate(rt.getTextTrim()));
            PointHandle.Mode phMode;
            if (StringUtils.isNotEmpty(rt.getAttributeValue("mode"))) {
                phMode = PointHandle.Mode.valueOf(rt.getAttributeValue("mode"));
            } else {
                phMode = PointHandle.Mode.replace;
            }
            if (mode == null) {
                throw new SmartconfigException("Not found pointhandle mode");
            }
            configFile.addPointHandle(new PointHandle(expression, value, phMode));

        }
        fastconfig.addConfigFile(configFile);
    }
    return fastconfig;
}

From source file:com.init.octo.schema.XsdAll.java

License:Open Source License

/**
 * This method builds a ALL element//from   w  ww. ja v a  2 s.  c om
 *
 * @param    root - the ALL element that defines this element
 * @param    cache - a list of pre-defined XML types
 */

public boolean build(Element root, XSDCache cache, String parentName) {

    log.debug("" + indent + ": " + "Build representation of a ALL");

    id = root.getAttributeValue(XSDSchema.ID_ATT);
    maxOccurs = root.getAttributeValue(XSDSchema.MAXOCCURS_ATT);
    minOccurs = root.getAttributeValue(XSDSchema.MINOCCURS_ATT);

    group = new LinkedList<XMLType>();

    Element element;
    String elementName;

    for (Iterator<?> i = (root.getChildren()).iterator(); i.hasNext();) {

        element = (Element) i.next();
        elementName = element.getName();

        log.debug("" + indent + ": " + "Child element <" + elementName + "> found");

        /** process the child elements that define this element...   **/

        if (elementName.equals(XSDSchema.ANNOTATION)) {

            annotation = element.getTextTrim();
        } else if (elementName.equals(XSDSchema.ELEMENT)) {

            log.debug("" + indent + ": " + "Adding element to the list of child elements");

            XSDElement e = new XSDElement(indent + 1);

            if (e.build(element, cache, parentName) != true) {
                log.error("Error building an element - " + element);
                return (false);
            }

            group.add(e);
        } else {
            log.warn("" + indent + ": " + "Unexpected element <" + elementName + "> found and ignored");
        }

    } // end for all child elements of this <ALL> tag

    log.debug("" + indent + ": " + "ALL built");

    return (true);

}

From source file:com.init.octo.schema.XSDAttribute.java

License:Open Source License

/**
 * This method builds the element definition
 *
 * @param    root - the schema element that defines this element
 * @param    cache - a list of pre-defined XML types
 *///from w ww  . j  av  a2 s .  c  o  m

//log.debug("Build representation of an Attribute");
public boolean build(Element root, XSDCache cache, String parentName) {
    this.parentName = parentName;
    name = root.getAttributeValue(XSDSchema.NAME_ATT);
    ref = root.getAttributeValue(XSDSchema.REF_ATT);
    type = root.getAttributeValue(XSDSchema.TYPE_ATT);
    defaultAtt = root.getAttributeValue(XSDSchema.DEFAULT_ATT);
    use = root.getAttributeValue(XSDSchema.USE_ATT);

    if (use == null) {
        use = "optional";
    }
    if (defaultAtt == null) {
        defaultAtt = "";
    }

    if (notEmpty(name)) {
        cache.putAttribute(name, this);
    }

    if (notEmpty(ref)) {
        XSDAttribute refAtt = (XSDAttribute) cache.getAttribute(ref);
        if (refAtt == null) {
            log.warn("Referenced attribute not found [" + ref + "]");
            return (true);
        }
        name = refAtt.getName();
        use = refAtt.getUse();
        defaultAtt = refAtt.getDefault();
        type = refAtt.getType();
        return (true);
    }

    for (Element child : root.getChildren()) {
        String childElementType = child.getName();

        if (childElementType.equals(XSDSchema.ANNOTATION)) {
            annotation = child.getTextTrim();
        } else if (childElementType.equals(XSDSchema.SIMPLETYPE)) {
            if (elementType != null) {
                throw new XmlSchemaException("Cannot define the type of an attribute more than once");
            }
            elementType = new XSDElementTypeSimple();
            elementType.build(child, cache, parentName);
        }
    } // end for all child elements of this <element> tag

    log.debug("Attribute built");
    return true;
}

From source file:com.init.octo.schema.XSDChoice.java

License:Open Source License

/**
 * This method builds a choice element/*from w w  w . j  ava  2s . c  om*/
 * @param root
 *            - the choice element that defines this element
 * @param cache
 *            - a list of pre-defined XML types
 */
public boolean build(Element root, XSDCache cache, String parentName) {

    log.debug("" + indent + ": " + "Build representation of a choice");

    id = root.getAttributeValue(XSDSchema.ID_ATT);
    maxOccurs = root.getAttributeValue(XSDSchema.MAXOCCURS_ATT);
    minOccurs = root.getAttributeValue(XSDSchema.MINOCCURS_ATT);

    group = new LinkedList<XMLType>();

    String elementName;

    for (Element element : root.getChildren()) {
        elementName = element.getName();
        log.debug("" + indent + ": " + "Child element <" + elementName + "> found");

        if (elementName.equals(XSDSchema.ANNOTATION)) {
            annotation = element.getTextTrim();
        } else if (elementName.equals(XSDSchema.ELEMENT)) {
            log.debug("" + indent + ": " + "Adding element to the list of child elements");
            XSDElement e = new XSDElement(indent + 1);
            if (e.build(element, cache, parentName) != true) {
                log.error("Error building the element");
                return (false);
            }

            group.add(e);
        } else if (elementName.equals(XSDSchema.GROUP)) {

            log.debug("" + indent + ": " + "Adding group to the list of child elements");
            XSDGroupType g = new XSDElementGroup(indent);
            if (g.build(element, cache, parentName) != true) {
                log.error("Error building a group");
                return (false);
            }

            group.add(g);

        } else if (elementName.equals(XSDSchema.CHOICE)) {

            log.debug("" + indent + ": " + "Adding choice to the list of child elements");

            XSDChoice c = new XSDChoice(indent);
            if (c.build(element, cache, parentName) != true) {
                log.error("Error building a choice");
                return (false);
            }

            group.add(c);
        } else if (elementName.equals(XSDSchema.SEQUENCE)) {

            log.debug("" + indent + ": " + "Adding sequence to the list of child elements");
            XSDSequence s = new XSDSequence(indent); // child elements all at the same level

            if (s.build(element, cache, parentName) != true) {
                log.debug("Error building a sequence");
                return (false);
            }

            group.add(s);
        } else {
            log.warn("" + indent + ": " + "Unexpected element <" + elementName + "> found and ignored");
        }

    } // end for all child elements of this <choice> tag

    log.debug("" + indent + ": " + "Choice built");

    return (true);

}

From source file:com.init.octo.schema.XSDElement.java

License:Open Source License

/**
 * This method builds the element definition
 *
 * @param    root - the schema element that defines this element
 * @param    cache - a list of pre-defined XML types
 *///www.j  a v a  2s.  c  om

public boolean build(Element root, XSDCache cache, String parentName) {

    log.debug("" + indent + ": " + "Build representation of an Element");

    // root.getAttributeValue(XSDSchema.ID_ATT);
    //root.getAttributeValue(XSDSchema.BLOCK_ATT);
    //root.getAttributeValue(XSDSchema.FINAL_ATT);

    name = root.getAttributeValue(XSDSchema.NAME_ATT);
    ref = root.getAttributeValue(XSDSchema.REF_ATT);
    type = root.getAttributeValue(XSDSchema.TYPE_ATT);
    maxOccurs = root.getAttributeValue(XSDSchema.MAXOCCURS_ATT);
    minOccurs = root.getAttributeValue(XSDSchema.MINOCCURS_ATT);

    this.parentName = parentName;

    log.debug("" + indent + ": Element <" + name + ">");

    /** Add the element definition to the element cache... **/

    if (name != null && name.equals("") == false) {
        log.debug("Adding element [" + name + "] to the cache");
        cache.putElement(name, this);
    }

    /** If this element is a reference to another full definition then get that definition... **/

    if (ref != null && ref.equals("") == false) {

        name = ref;

        XSDElement refElement = (XSDElement) cache.getElement(ref);

        if (refElement == null) {
            log.debug("The reference element [" + ref + "] not in the cache...");
            return (true);
        }

        log.debug("The reference element [" + ref + "] retrieved from the cache...");

        /* Referenced element found so make this element look like it... */

        elementType = refElement.getElementType();

        if (maxOccurs == null) {
            maxOccurs = refElement.getMaxOccurs();
        }

        if (minOccurs == null) {
            minOccurs = refElement.getMinOccurs();
        }

        if (name == null) {
            name = refElement.getName();
        }

        defaultOccurs();

        return (true);

    }

    defaultOccurs();

    /** if the type attribute has been specified then lookup its definition in the cache **/

    if (type != null) {

        log.debug("" + indent + ": This element is of type <" + type + ">");

        elementType = (XSDElementType) cache.getElementTypeComplex(type);

        if (elementType == null) {
            log.debug("No definition of type <" + type + "> found in type cache");
            /** carry on, the type was probably an XSD standard type... **/
        } else {
            cachedType = true;
            /** no sub definition allowed if the type has been specified **/
            return (true);
        }
    }

    Element element;
    String elementName;

    for (Iterator<Element> i = (root.getChildren()).iterator(); i.hasNext();) {

        element = (Element) i.next();
        elementName = element.getName();

        log.debug("" + indent + ": " + "Child element <" + elementName + "> found");

        /** process the child elements that define this element...   **/

        if (elementName.equals(XSDSchema.ANNOTATION)) {

            annotation = element.getTextTrim();

        } else if (elementName.equals(XSDSchema.SIMPLETYPE)) {

            if (elementType != null) {
                log.error("Cannot define the type of an element more than once");
                return (false);
            }

            elementType = new XSDElementTypeSimple(indent);

            if (elementType.build(element, cache, getFullName()) == false) {
                log.error("Error building a simpleType object");
                return (false);
            }
        } else if (elementName.equals(XSDSchema.COMPLEXTYPE)) {

            if (elementType != null) {
                log.error("Cannot define the type of an element more than once");
                return (false);
            }

            elementType = new XSDElementTypeComplex(indent);

            if (elementType.build(element, cache, getFullName()) == false) {
                log.error("Error building a complexType object");
                return (false);
            }
        } else {
            log.warn("" + indent + ": " + "Unexpected element <" + elementName + "> found and ignored");
        }

    } // end for all child elements of this <element> tag

    log.debug("" + indent + ": " + "Element built");

    return (true);

}

From source file:com.init.octo.schema.XSDElementTypeComplex.java

License:Open Source License

/**
 * This method builds a complex type//from  w w w  .j  ava 2  s  .  c o  m
 *
 * @param    root - the complexType element that defines this element
 * @param    cache - a list of pre-defined XML types
 */

public boolean build(Element root, XSDCache cache, String parentName) {

    log.debug("" + indent + ": " + "Build representation of a ComplexType");

    /** get the complex types attributes **/

    id = root.getAttributeValue(XSDSchema.ID_ATT);
    name = root.getAttributeValue(XSDSchema.NAME_ATT);
    abstractAtt = root.getAttributeValue(XSDSchema.ABSTRACT_ATT);
    mixed = root.getAttributeValue(XSDSchema.MIXED_ATT);
    block = root.getAttributeValue(XSDSchema.BLOCK_ATT);
    finalAtt = root.getAttributeValue(XSDSchema.FINAL_ATT);

    log.debug("" + indent + ": ComplexType <" + name + ">");

    for (Element rootChild : root.getChildren()) {
        String elementName = rootChild.getName();

        if (elementName.equals(XSDSchema.ANNOTATION)) {
            annotation = rootChild.getTextTrim();

        } else if (elementName.equals(XSDSchema.SIMPLECONTENT)) {

        } else if (elementName.equals(XSDSchema.COMPLEXCONTENT)) {

            for (Element child : rootChild.getChildren()) {

                Attribute baseTypeAtt = child.getAttribute(XSDSchema.BASE_ATT);
                if (baseTypeAtt == null) {
                    throw new XmlSchemaException("No base attribute for element [" + elementName + "]");
                }

                XSDElementTypeComplex cachedObject = cache.getElementTypeComplex(baseTypeAtt.getValue());
                if (cachedObject != null) {
                    baseType = cachedObject;
                }

                processComplexTypeChildren(child, cache);
            }

        } else if (elementName.equals(XSDSchema.GROUP)) {
            if (elementGroup != null) {
                throw new XmlSchemaException("Cannot define a grouping element more than once");
            }
            elementGroup = new XSDElementGroup(indent);
            elementGroup.build(rootChild, cache, parentName);

        } else if (elementName.equals(XSDSchema.ALL)) {
            if (elementGroup != null) {
                throw new XmlSchemaException("Cannot define a grouping element more than once");
            }
            elementGroup = new XsdAll(indent);
            elementGroup.build(rootChild, cache, parentName);
        } else if (elementName.equals(XSDSchema.CHOICE)) {
            if (elementGroup != null) {
                throw new XmlSchemaException("Cannot define a grouping element more than once");
            }

            elementGroup = new XSDChoice(indent);
            elementGroup.build(rootChild, cache, parentName);
        } else if (elementName.equals(XSDSchema.SEQUENCE)) {

            if (elementGroup != null) {
                log.error("Cannot define a grouping element more than once");
                return (false);
            }

            elementGroup = new XSDSequence(indent);

            if (elementGroup.build(rootChild, cache, parentName) != true) {
                log.error("Error building a sequence object");
                return (false);
            }
        } else if (elementName.equals(XSDSchema.ATTRIBUTE)) {

            XSDAttribute attribute = new XSDAttribute();
            if (attribute.build(rootChild, cache, parentName) != true) {
                log.error("Error building an attribute object");
                return (false);
            }

            attributeList.add(attribute);
        } else if (elementName.equals(XSDSchema.ATTRIBUTEGROUP)) {

            XSDAttributeGroup group = new XSDAttributeGroup();

            if (group.build(rootChild, cache, parentName) != true) {
                log.error("Error building an attribute group object");
                return (false);
            }

            attributeList.addAll(group.getAllAttributes());

        } else {
            log.warn("" + indent + ": " + "Unexpected element <" + elementName + "> found and ignored");
        }

    } // end for all child elements of this <element> tag

    log.debug("" + indent + ": " + "ComplexType built");

    return (true);

}

From source file:com.init.octo.schema.XSDElementTypeSimple.java

License:Open Source License

/**
 * This method builds a simple type/*from   w  w w .j ava 2 s. co m*/
 *
 * @param root
 *            - the simpleType element that defines this element
 * @param cache
 *            - a list of pre-defined XML types
 */

public boolean build(Element root, XSDCache cache, String parentName) {

    log.debug("" + indent + ": " + "Build representation of a SimpleType");

    id = root.getAttributeValue(XSDSchema.ID_ATT);
    finalAtt = root.getAttributeValue(XSDSchema.FINAL_ATT);
    name = root.getAttributeValue(XSDSchema.NAME_ATT);

    for (Element child : root.getChildren()) {
        String childType = child.getName();

        if (childType.equals(XSDSchema.ANNOTATION)) {
            annotation = child.getTextTrim();
            break;
        } else if (childType.equals(XSDSchema.RESTRICTION)) {
            // @todo
        } else if (childType.equals(XSDSchema.LIST)) {
            // @todo
        }
    }

    return true;
}

From source file:com.init.octo.schema.XSDGroupType.java

License:Open Source License

public boolean build(Element root, XSDCache cache, String parentName) {

    log.debug("" + indent + ": " + "Build representation of a group");

    id = root.getAttributeValue(XSDSchema.ID_ATT);
    maxOccurs = root.getAttributeValue(XSDSchema.MAXOCCURS_ATT);
    minOccurs = root.getAttributeValue(XSDSchema.MINOCCURS_ATT);
    name = root.getAttributeValue(XSDSchema.NAME_ATT);
    ref = root.getAttributeValue(XSDSchema.REF_ATT);

    /* If this group is named then add it to the cache... */
    /*/*from www  .  j  a v  a 2s .  c o  m*/
          if (name != null && name.equals("") == false) {
             cache.putGroup(name, this);
          }
    */
    /* If this group is a reference then lookup the reference... */
    /*
          if (ref != null && ref.equals("") == false) {
            
             List<XSDGroup> cachedGroup = cache.getGroup(ref);
            
             if (cachedGroup != null) {
    group
    return (true);
             }
          }
    */
    group = new LinkedList<XMLType>();

    Element element;
    String elementName;

    for (Iterator<?> i = (root.getChildren()).iterator(); i.hasNext();) {

        element = (Element) i.next();
        elementName = element.getName();

        log.debug("" + indent + ": " + "Child element <" + elementName + "> found");

        /** process the child elements that define this element... **/

        if (elementName.equals(XSDSchema.ANNOTATION)) {

            annotation = element.getTextTrim();

        } else if (elementName.equals(XSDSchema.ALL)) {

            log.debug("" + indent + ": " + "Adding ALL to the list of child elements");

            XsdAll a = new XsdAll(indent); // child elements will be at the same level

            if (a.build(element, cache, parentName) != true) {
                log.error("Error building a ALL element");
                return (false);
            }

            group.add(a);
        } else if (elementName.equals(XSDSchema.CHOICE)) {

            log.debug("" + indent + ": " + "Adding choice to the list of child elements");

            XSDChoice c = new XSDChoice(indent); // child elements will be
            // at the same level

            if (c.build(element, cache, parentName) != true) {
                log.error("Error building a choice");
                return (false);
            }

            group.add(c);
        } else if (elementName.equals(XSDSchema.SEQUENCE)) {
            log.debug("" + indent + ": " + "Adding sequence to the list of child elements");
            XSDSequence s = new XSDSequence(indent);
            if (s.build(element, cache, parentName) != true) {
                log.error("Error building a sequence");
                return (false);
            }
            group.add(s);
        } else {
            log.warn("" + indent + ": " + "Unexpected element <" + elementName + "> found and ignored");
        }

    } // end for all child elements of this <group> tag

    return (true);

}

From source file:com.init.octo.schema.XSDSequence.java

License:Open Source License

/**
 * This method builds a sequence element
 *
 * @param    root - the sequence element that defines this element
 * @param    cache - a list of pre-defined XML types
 *//*w w  w .ja v  a2 s  .  co m*/
public boolean build(Element root, XSDCache cache, String parentName) {

    log.debug("" + indent + ": " + "Build representation of a sequence");

    id = root.getAttributeValue(XSDSchema.ID_ATT);
    maxOccurs = root.getAttributeValue(XSDSchema.MAXOCCURS_ATT);
    minOccurs = root.getAttributeValue(XSDSchema.MINOCCURS_ATT);

    group = new LinkedList<XMLType>();

    Element element;
    String elementName;

    for (Iterator<?> i = (root.getChildren()).iterator(); i.hasNext();) {

        element = (Element) i.next();
        elementName = element.getName();

        log.debug("" + indent + ": " + "Child element <" + elementName + "> found");

        /** process the child elements that define this element...   **/

        if (elementName.equals(XSDSchema.ANNOTATION)) {
            annotation = element.getTextTrim();

        } else if (elementName.equals(XSDSchema.ELEMENT)) {
            log.debug("" + indent + ": " + "Adding element to the list of child elements");
            XSDElement e = new XSDElement(indent + 1);
            if (e.build(element, cache, parentName) != true) {
                log.debug("Error building the element");
                return (false);
            }
            group.add(e);
        } else if (elementName.equals(XSDSchema.GROUP)) {
            log.debug("" + indent + ": " + "Adding group to the list of child elements");
            XSDGroupType g = new XSDElementGroup(indent); // child elements will be at the same level

            if (g.build(element, cache, parentName) != true) {
                log.error("Error building a group");
                return (false);
            }

            group.add(g);
        } else if (elementName.equals(XSDSchema.CHOICE)) {

            log.debug("" + indent + ": " + "Adding choice to the list of child elements");

            XSDChoice c = new XSDChoice(indent); // child elements will be at the same level

            if (c.build(element, cache, parentName) != true) {
                log.error("Error building a choice");
                return (false);
            }

            group.add(c);
        } else if (elementName.equals(XSDSchema.SEQUENCE)) {

            log.debug("" + indent + ": " + "Adding sequence to the list of child elements");

            XSDSequence s = new XSDSequence(indent); // child elements will be at the same level

            if (s.build(element, cache, parentName) != true) {
                log.error("Error building a sequence");
                return (false);
            }

            group.add(s);
        } else {
            log.warn("" + indent + ": " + "Unexpected element <" + elementName + "> found and ignored");
        }

    } // end for all child elements of this <sequence> tag

    log.debug("" + indent + ": " + "Sequence built");

    return (true);

}

From source file:com.init.octo.util.FindXML.java

License:Open Source License

/**
 * This method locates an XML tag or attribute based on an input string.
 * The input locator string must be in the format root.element.element or root.element.[attribute]
 *
 * @param   locator - the definition of the element you want to locate
 * @param   root - the root element of the XML structure
 *
 * @returns   String - the string we have found, or null of it wasn't found
 *///from  www .ja v  a  2 s  .co m

static public String findXML(String locator, Element root) {

    Element element = null;
    String retStr = null;
    StringTokenizer tokens = new StringTokenizer(locator, ".");
    String str = tokens.nextToken();

    if (tokens.countTokens() == 0) {
        locator = "root." + locator;
        tokens = new StringTokenizer(locator, ".");
        str = tokens.nextToken();
    }

    // follow the locator text element name definition down...

    element = root;

    while (tokens.hasMoreTokens()) {
        str = tokens.nextToken();

        if (str.startsWith("[")) { // an attribute has been specified
            String attName = str.substring(1, str.indexOf("]"));
            retStr = element.getAttributeValue(attName);
            element = null;
            break;
        } else {
            String[] spec = str.split(":");

            if (spec.length == 1) {
                element = element.getChild(str);
            } else {
                /** A specific member of a repeating group has been specified... **/
                Iterator<?> it = element.getChildren(spec[0]).iterator();
                int idx = 1;
                int num = 0;

                try {
                    num = Integer.parseInt(spec[1]);
                } catch (Exception x) {
                    log.warn("Bad element index [" + spec[1] + "]");
                    num = 1;
                }

                while (it.hasNext()) {
                    element = (Element) it.next();
                    if (idx == num) {
                        break;
                    }
                }

                /** If we go past the end of the list we will return the last one... **/
                /** this way the call can detect no change in the output...          **/
            }
        }
        if (element == null) {
            return (null);
        }
    }

    if (element != null) { // wasn't specified as an attribute...
        retStr = element.getTextTrim();
    }

    return (retStr);

}