private static NamespaceDeclarationCollection NamespaceDeclarations( IEnumerable <XNamespace> appeared, IReadOnlyNamespaceDeclarationCollection declared) { int n = 0; var result = new List <NamespaceDeclaration>(); appeared = Enumerable.Concat( new List <XNamespace> { Psf.Namespace, Psk.Namespace, Xsd.Namespace, Xsi.Namespace }, appeared); foreach (var uri in appeared) { var prefix = declared.LookupPrefix(uri); if (prefix == null) { prefix = string.Format("ns{0:0000}", n); n += 1; } result.Add(new NamespaceDeclaration(prefix, uri)); } return(new NamespaceDeclarationCollection(result)); }
private static NamespaceDeclarationCollection NamespaceDeclarations( IEnumerable<XNamespace> appeared, IReadOnlyNamespaceDeclarationCollection declared) { int n = 0; var result = new List<NamespaceDeclaration>(); appeared = Enumerable.Concat( new List<XNamespace> { Psf.Namespace, Psk.Namespace, Xsd.Namespace, Xsi.Namespace }, appeared); foreach (var uri in appeared) { var prefix = declared.LookupPrefix(uri); if (prefix == null) { prefix = string.Format("ns{0:0000}", n); n += 1; } result.Add(new NamespaceDeclaration(prefix, uri)); } return new NamespaceDeclarationCollection(result); }
internal NamespaceResolver(IReadOnlyNamespaceDeclarationCollection namespaces) { NamespaceDeclarations = new NamespaceDeclarationCollection(namespaces); }