public static void ConvertTest(XResource test) { XNamespace xNamespace = "http://www.imsglobal.org/xsd/imsqtiasi_v3p0"; foreach (var element in test.Content.Descendants()) { var tagName = element.Name.LocalName; var kebabTagName = tagName.ToKebabCase(); element.Name = xNamespace + $"qti-{kebabTagName}"; } // fix attributes foreach (var element in test.Content.Descendants()) { var attributesToRemove = new List <XAttribute>(); var attributesToAdd = new List <XAttribute>(); foreach (var attribute in element.Attributes() .Where(attr => !attr.IsNamespaceDeclaration && string.IsNullOrEmpty(attr.Name.NamespaceName))) { var attributeName = attribute.Name.LocalName; var kebabAttributeName = attributeName.ToKebabCase(); if (attributeName != kebabAttributeName) { var newAttr = new XAttribute($"{kebabAttributeName}", attribute.Value); attributesToRemove.Add(attribute); attributesToAdd.Add(newAttr); } } attributesToRemove.ForEach(a => a.Remove()); attributesToAdd.ForEach(a => element.Add(a)); } test.Save(); }
public static void ConvertTest(XResource test) { test.Save(); }