-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent creating properties from infinite recursive attribute group refs
Prevent duplicate elements from multiple group refs in choices Add schema downloader script Add XBRL schema
- Loading branch information
Michael Ganss
committed
Jan 18, 2022
1 parent
add51cc
commit 5485b25
Showing
45 changed files
with
5,757 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,3 +299,4 @@ __pycache__/ | |
*.xsd.cs | ||
/coverage.xml | ||
/coverage.netcoreapp2.2.xml | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#! "net6.0" | ||
|
||
using System.Net.Http; | ||
using System.Xml; | ||
using System.Xml.Linq; | ||
|
||
var opts = Args.Where(a => a.StartsWith("-")); | ||
|
||
if (Args.Except(opts).Count() < 1) | ||
{ | ||
Console.WriteLine("Usage: dotnet script download.csx [-ddestination] URL..."); | ||
return; | ||
} | ||
|
||
XNamespace xs = "http://www.w3.org/2001/XMLSchema"; | ||
var xsds = new HashSet<string>(StringComparer.OrdinalIgnoreCase); | ||
var client = new HttpClient(); | ||
var destination = opts.FirstOrDefault(a => a.StartsWith("-d"))?[2..] ?? "."; | ||
|
||
void Download(string url, string destination) | ||
{ | ||
destination = Path.GetFullPath(destination); | ||
|
||
var key = $"{url}:{destination}"; | ||
|
||
if (xsds.Contains(key)) return; | ||
|
||
Console.WriteLine($"Downloading {url} to {destination}"); | ||
|
||
xsds.Add(key); | ||
|
||
var xsd = client.GetStringAsync(url).Result; | ||
var document = XDocument.Parse(xsd); | ||
var uri = new Uri(url); | ||
var fileName = Path.GetFileName(uri.LocalPath); | ||
var dir = new Uri(uri, "."); | ||
var locations = document.Descendants(xs + "include") | ||
.Concat(document.Descendants(xs + "import")) | ||
.Concat(document.Descendants(xs + "redefine")) | ||
.Select(e => e.Attribute("schemaLocation")?.Value) | ||
.Where(a => a != null && !new Uri(a, UriKind.RelativeOrAbsolute).IsAbsoluteUri); | ||
|
||
Directory.CreateDirectory(destination); | ||
File.WriteAllText(Path.Join(destination, fileName), xsd); | ||
|
||
foreach (var location in locations) | ||
{ | ||
var locationUri = new Uri(dir, location).OriginalString; | ||
var locationDest = Path.GetDirectoryName(Path.Join(destination, location)); | ||
Download(locationUri, locationDest); | ||
} | ||
} | ||
|
||
foreach (var url in Args.Except(opts)) | ||
{ | ||
Download(url, destination); | ||
} | ||
|
||
Console.WriteLine("Done."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"script": { | ||
"enableScriptNuGetReferences": true, | ||
"defaultTargetFramework": "net5.0" | ||
} | ||
} |
Oops, something went wrong.