private void rewriteElementXmlPackage(PackageVO pkg)
        {
            if (pkg.childPackageList.Count > 0)
            {
                foreach (PackageVO p in pkg.childPackageList)
                {
                    rewriteElementXmlPackage(p);
                }
            }

            if (pkg.elements.Count > 0)
            {
                foreach (ElementVO elem in pkg.elements)
                {
                    ElementXmlWriter.outputElementXmlFile(elem);
                }
            }
        }
        private static void outputPackage(PackageVO pkg, int depth, StreamWriter sw)
        {
            sw.Write(indent(depth) + "<package ");
            sw.Write("changed='" + pkg.changed + "' ");
            sw.Write(" PackageID='" + pkg.packageId + "'");
            sw.Write(" guid='" + escapeXML(pkg.guid) + "'");
            sw.Write(" parentPackageId='" + pkg.parentPackageId + "'");
            sw.Write(" TPos='" + pkg.treePos + "'");
            sw.Write(" name='" + escapeXML(pkg.name) + "'");
            sw.Write(" Alias='" + escapeXML(pkg.alias) + "'");
            if (pkg.stereoType != null)
            {
                sw.Write(" stereoType='" + pkg.stereoType + "'");
            }
            sw.Write(" isControlled='" + pkg.isControlled + "'");
            sw.WriteLine(">");

            if (pkg.elements != null && pkg.elements.Count > 0)
            {
                foreach (ElementVO elem in pkg.elements)
                {
                    ElementXmlWriter.writeElementXml(elem, depth + 1, sw);
                }
            }

            if (pkg.diagrams != null && pkg.diagrams.Count > 0)
            {
                foreach (DiagramVO dia in pkg.diagrams)
                {
                    DiagramXmlWriter.outputDiagramXml(dia, depth + 1, sw);
                }
            }

            if (pkg.childPackageList.Count > 0)
            {
                foreach (PackageVO p in pkg.childPackageList)
                {
                    outputPackage(p, depth + 1, sw);
                }
            }

            sw.WriteLine(indent(depth) + "</package>");
        }