/**
   * Get the index of a tag. Grabs the parent tag, and iterates it's children to find out what the
   * index of the tag passed in should be
   */
  private int getIndexOfTag(MXMLTagData tag) {
    MXMLTagData parent = tag.getParentTag();

    int index = 0;
    for (MXMLTagData d = parent.getFirstChild(true); d != null; d = d.getNextSibling(true)) {
      if (d == tag) break;
      else if (d.getName().equals(tag.getName())) ++index;
    }
    return index;
  }
 /**
  * Do a lookup of a prefix, starting with the specified tag. This method will record if the prefix
  * is defined outside of the <fx:XML> tag. If it is defined outside of the tag, then the prefix
  * will need to be added to the root XML tag as an 'xmlns' so that it will still be accessible.
  *
  * @param prefix the prefix to look for
  * @param tag the tag to start looking in
  */
 void lookupPrefix(String prefix, MXMLTagData tag) {
   while (tag != null) {
     PrefixMap pm = tag.getPrefixMap();
     if (pm != null && pm.containsPrefix(prefix))
       // we found the prefix, and haven't gone past the root tag, so don't need to do anything
       // special
       return;
     else if (tag == rootTag)
       // don't look past the root tag
       tag = null;
     else tag = tag.getParentTag();
   }
   // We will only get here if we have traversed past the root XML tag, and haven't found the
   // prefix yet
   // in that case, record the prefix if its defined somewhere else in the MXML document, so we can
   // make sure it ends up in the resulting XML literal.
   if (externalPrefixes.containsPrefix(prefix)) referencedPrefixes.add(prefix);
 }