public Element mergeDescriptorElements(List baseList, List rootList) throws MetadataException
{
Document doc = XMLUtil.parse(new StringReader("<Metadata/>"));
Element descriptorElement = doc.getDocumentElement();
Lookup2D resourceMap = new HashTab2D();
Lookup refNameMap = new LinkedHashTab();
Lookup mixinMap = new LinkedHashTab();
String sBaseNamespace = null;
String sBaseVersion = null;
String sBaseChecksum = null;
String sBaseName = null;
String sBaseRevision = null;
String sBaseDescription = null;
String sBaseCoreVersion = null;
String sBaseModule = null;
String sBaseOverride = null;
String sRootNamespace = null;
String sRootVersion = null;
String sRootDescription = null;
String sRootName = null;
String sRootRevision = null;
String sRootCoreVersion = null;
String sRootModule = null;
String sRootOverride = null;
Element baseElement = getDescriptorElement(false);
Element rootElement = getDescriptorElement(true);
if (baseElement != null)
{
sBaseNamespace = XMLUtil.getReqStringAttr(baseElement, "namespace");
sBaseVersion = XMLUtil.getReqStringAttr(baseElement, "version");
sBaseName = XMLUtil.getReqStringAttr(baseElement, "name");
sBaseRevision = XMLUtil.getReqStringAttr(baseElement, "revision");
sBaseCoreVersion = XMLUtil.getStringAttr(baseElement, "coreVersion");
sBaseModule = normalizeScope(XMLUtil.getStringAttr(baseElement, "module"));
sBaseOverride = XMLUtil.getStringAttr(baseElement, "override");
sBaseDescription = XMLUtil.getStringAttr(baseElement, "description");
sBaseChecksum = getChecksum(false);
addMixinElements(mixinMap, baseElement);
addResourceElements(resourceMap, refNameMap, baseElement);
}
if (rootElement != null)
{
sRootNamespace = XMLUtil.getReqStringAttr(rootElement, "namespace");
sRootVersion = XMLUtil.getReqStringAttr(rootElement, "version");
sRootName = XMLUtil.getReqStringAttr(rootElement, "name");
sRootRevision = XMLUtil.getReqStringAttr(rootElement, "revision");
sRootCoreVersion = XMLUtil.getStringAttr(rootElement, "coreVersion");
sRootModule = normalizeScope(XMLUtil.getStringAttr(rootElement, "module"));
sRootOverride = XMLUtil.getStringAttr(rootElement, "override");
sRootDescription = XMLUtil.getStringAttr(rootElement, "description");
addMixinElements(mixinMap, rootElement);
addResourceElements(resourceMap, refNameMap, rootElement);
if (baseElement == null)
{
sBaseNamespace = XMLUtil.getStringAttr(rootElement, "baseNamespace");
sBaseVersion = XMLUtil.getStringAttr(rootElement, "baseVersion");
sBaseChecksum = XMLUtil.getStringAttr(rootElement, "baseChecksum");
}
}
else
{
sRootNamespace = sBaseNamespace;
sRootVersion = sBaseVersion;
sRootName = sBaseName;
sRootRevision = sBaseRevision;
sRootModule = sBaseModule;
sRootOverride = sBaseOverride;
sRootDescription = sBaseDescription;
sBaseNamespace = null;
sBaseVersion = null;
sBaseChecksum = null;
sBaseModule = null;
sBaseOverride = null;
sBaseDescription = null;
}
if (sRootCoreVersion == null)
{
sRootCoreVersion = sBaseCoreVersion;
}
if (sRootNamespace != null)
{
descriptorElement.setAttribute("name", sRootName);
descriptorElement.setAttribute("revision", sRootRevision);
descriptorElement.setAttribute("namespace", sRootNamespace);
descriptorElement.setAttribute("version", sRootVersion);
if (sRootCoreVersion != null)
{
descriptorElement.setAttribute("coreVersion", sRootCoreVersion);
}
if (sRootModule != null)
{
descriptorElement.setAttribute("module", sRootModule);
}
if (sRootOverride != null)
{
descriptorElement.setAttribute("override", sRootOverride);
}
if (sRootDescription != null)
{
descriptorElement.setAttribute("description", sRootDescription);
}
}
if (sBaseNamespace != null)
{
descriptorElement.setAttribute("baseNamespace", sBaseNamespace);
descriptorElement.setAttribute("baseVersion", sBaseVersion);
descriptorElement.setAttribute("baseChecksum", sBaseChecksum);
}
// Insert the mixin elements
Element mixinsElement = doc.createElement("Mixins");
descriptorElement.appendChild(mixinsElement);
for (Iterator itr = mixinMap.valueIterator(); itr.hasNext(); )
{
Element mixinElement = XMLUtil.addChildElement(mixinsElement, null, "Mixin");
NamedNodeMap map = ((Element)itr.next()).getAttributes();
for (int i = 0, n = map.getLength(); i < n; ++i)