diff options
author | hche10x <hche10x@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-07-14 09:37:03 +0000 |
---|---|---|
committer | hche10x <hche10x@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-07-14 09:37:03 +0000 |
commit | f9334421d8f8543ed9e498095c272e8a0f563bc2 (patch) | |
tree | ee52f42fbe77a2cdaa9d968471f4e90c679c5b27 /Tools | |
parent | ad1f8df0c905c6114c4749321ac895cb74b5d251 (diff) | |
download | edk2-platforms-f9334421d8f8543ed9e498095c272e8a0f563bc2.tar.xz |
1. Remove empty top level elements if they have no data
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1013 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/SaveFile.java | 154 |
1 files changed, 153 insertions, 1 deletions
diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/SaveFile.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/SaveFile.java index ec587bb5be..5d5ab9fd2b 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/SaveFile.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/SaveFile.java @@ -17,6 +17,7 @@ package org.tianocore.frameworkwizard.common; import java.io.File;
import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
import org.tianocore.FrameworkDatabaseDocument;
import org.tianocore.ModuleSurfaceAreaDocument;
@@ -44,6 +45,157 @@ public class SaveFile { **/
public static void saveMsaFile(String path, ModuleSurfaceArea msa) throws Exception {
+ //
+ // Remove all empty top level elements
+ //
+ XmlObject o = msa.getLibraryClassDefinitions();
+ if (o != null) {
+ if (msa.getLibraryClassDefinitions().getLibraryClassList().size() <= 0) {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ }
+
+ o = msa.getSourceFiles();
+ if (o != null) {
+ if (msa.getSourceFiles().getFilenameList().size() <= 0) {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ }
+
+ o = msa.getPackageDependencies();
+ if (o != null) {
+ if (msa.getPackageDependencies().getPackageList().size() <= 0) {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ }
+
+ o = msa.getProtocols();
+ if (o != null) {
+ if (msa.getProtocols().getProtocolList().size() <= 0
+ && msa.getProtocols().getProtocolNotifyList().size() <= 0) {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ }
+
+ o = msa.getEvents();
+ if (o != null) {
+ if (msa.getEvents().getCreateEvents() != null || msa.getEvents().getSignalEvents() != null) {
+ if (msa.getEvents().getCreateEvents() != null && msa.getEvents().getCreateEvents().getEventTypesList().size() <= 0) {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ if (msa.getEvents().getSignalEvents() != null && msa.getEvents().getSignalEvents().getEventTypesList().size() <= 0) {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ } else {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ }
+
+ o = msa.getHobs();
+ if (o != null) {
+ if (msa.getHobs().getHobTypesList().size() <= 0) {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ }
+
+ o = msa.getPPIs();
+ if (o != null) {
+ if (msa.getPPIs().getPpiList().size() <= 0 && msa.getPPIs().getPpiNotifyList().size() <= 0) {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ }
+
+ o = msa.getVariables();
+ if (o != null) {
+ if (msa.getVariables().getVariableList().size() <= 0) {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ }
+
+ o = msa.getBootModes();
+ if (o != null) {
+ if (msa.getBootModes().getBootModeList().size() <= 0) {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ }
+
+ o = msa.getSystemTables();
+ if (o != null) {
+ if (msa.getSystemTables().getSystemTableCNamesList().size() <= 0) {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ }
+
+ o = msa.getDataHubs();
+ if (o != null) {
+ if (msa.getDataHubs().getDataHubRecordList().size() <= 0) {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ }
+
+ o = msa.getHiiPackages();
+ if (o != null) {
+ if (msa.getHiiPackages().getHiiPackageList().size() <= 0) {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ }
+
+ o = msa.getGuids();
+ if (o != null) {
+ if (msa.getGuids().getGuidCNamesList().size() <= 0) {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ }
+
+ o = msa.getExterns();
+ if (o != null) {
+ if (msa.getExterns().getExternList().size() <= 0 && msa.getExterns().getSpecificationList().size() <= 0
+ && msa.getExterns().getPcdIsDriver() == null) {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ }
+
+ o = msa.getPcdCoded();
+ if (o != null) {
+ if (msa.getPcdCoded().getPcdEntryList().size() <= 0) {
+ XmlCursor xmlCursor = o.newCursor();
+ xmlCursor.removeXml();
+ xmlCursor.dispose();
+ }
+ }
+
ModuleSurfaceAreaDocument msaDoc = ModuleSurfaceAreaDocument.Factory.newInstance();
File f = new File(path);
@@ -149,7 +301,7 @@ public class SaveFile { //
dbDoc.addNewFrameworkDatabase();
dbDoc.setFrameworkDatabase((FrameworkDatabase) cursor.getObject());
-
+
//
//Save the file
//
|