diff --git a/DataTableConverter/Assisstant/importers/XmlImporter.cs b/DataTableConverter/Assisstant/importers/XmlImporter.cs index 08a799f..dc054df 100644 --- a/DataTableConverter/Assisstant/importers/XmlImporter.cs +++ b/DataTableConverter/Assisstant/importers/XmlImporter.cs @@ -21,6 +21,7 @@ internal static void Import(string path, DatabaseHelper databaseHelper, Progress int counter = 0; SQLiteCommand insertCommand = null; Dictionary rowData = new Dictionary(); + Dictionary staticColumns = new Dictionary(); databaseHelper.CreateTable(new List(), tableName); XmlReaderSettings settings = new XmlReaderSettings @@ -31,6 +32,21 @@ internal static void Import(string path, DatabaseHelper databaseHelper, Progress }; XmlReader reader = XmlReader.Create(path, settings); reader.Read(); + + // read static rows + if (reader.HasAttributes) + { + while (reader.MoveToNextAttribute()) + { + string columnName = reader.LocalName; + staticColumns[columnName] = reader.Value; + rowData[columnName] = reader.Value; + overallColumns.Add(columnName); + databaseHelper.AddColumn(tableName, columnName); + } + + } + // reading rows while (reader.Read()) { @@ -39,6 +55,11 @@ internal static void Import(string path, DatabaseHelper databaseHelper, Progress { rowData[key] = string.Empty; } + // add static attributes + foreach (var pair in staticColumns) + { + rowData[pair.Key] = pair.Value; + } HashSet rowColumns = new HashSet(); LoadRowData(reader, rowData, rowColumns); @@ -125,8 +146,8 @@ private static string AlignArrayItemsAndPath(string parentPath, string parentNod foreach (string previousColumnName in previousNewCols) { string col = previousColumnName.Substring(parentPath.Length + rowReader.LocalName.Length + 2); - string adjustedParentPath = newParentPath + (newParentPath == string.Empty ? string.Empty : " "); - string newColumnName = $"{adjustedParentPath}{rowReader.LocalName} 1 {col}"; + string adjustedParentPath = newParentPath + (newParentPath == string.Empty ? string.Empty : "_"); + string newColumnName = $"{adjustedParentPath}{rowReader.LocalName}_1_{col}"; string previousValue = rowData[previousColumnName]; rowColumns.Remove(previousColumnName); @@ -145,20 +166,20 @@ private static string MergeColumnName(string columnName, string parentName, int { if(isParentList) { - return $"{columnName} {itemNumber}"; + return $"{columnName}_{itemNumber}"; } return columnName; } if (isParentList) { - return $"{parentName} {itemNumber} {columnName}"; + return $"{parentName}_{itemNumber}_{columnName}"; } if (columnName == string.Empty) { // value of an element return parentName; } - return $"{parentName} {columnName}"; + return $"{parentName}_{columnName}"; } } } diff --git a/DataTableConverter/Properties/AssemblyInfo.cs b/DataTableConverter/Properties/AssemblyInfo.cs index 8a61eea..129c559 100644 --- a/DataTableConverter/Properties/AssemblyInfo.cs +++ b/DataTableConverter/Properties/AssemblyInfo.cs @@ -32,4 +32,4 @@ // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.42.0")] \ No newline at end of file +[assembly: AssemblyFileVersion("1.0.43.0")] \ No newline at end of file