Skip to content

Repository files navigation

MetronInfo.Xml

CI NuGet

A .NET library for reading and writing MetronInfo.xml files — the comic/manga metadata format described by MetronInfo.xsd.

Installation

dotnet add package MetronInfo.Xml

Requirements

  • .NET 10 SDK

Project layout

MetronInfo.slnx
MetronInfo.xsd                       # schema, embedded into the library for validation
src/MetronInfo.Xml/                  # the library
  MetronInfoXml.cs                   # Read / Write / Validate entry points
  Models/                            # POCOs mapped 1:1 to the XSD's types
tests/MetronInfo.Xml.Tests/          # xUnit tests, including a real MetronInfo.xml fixture

Build & test

dotnet build
dotnet test

Usage

Reading

using MetronInfo.Xml;

MetronInfo.Xml.Models.MetronInfo info = MetronInfoXml.Read("MetronInfo.xml");

Console.WriteLine(info.Series.Name);
Console.WriteLine(info.Number);

Read also has overloads for a Stream or TextReader.

Writing

var info = new MetronInfo.Xml.Models.MetronInfo
{
    Series = new SeriesType { Name = "Sandman", Volume = 1, StartYear = 1989 },
    Number = "1",
    AgeRating = AgeRatingType.Mature,
};

MetronInfoXml.Write(info, "MetronInfo.xml");

Write also has overloads for a Stream or TextWriter. Optional elements and attributes you leave unset are simply omitted from the output.

Write emits the same xmlns:metroninfo, xmlns:xsd, xmlns:xsi, and xsi:schemaLocation attributes that Metron's own tooling writes, so output stays interoperable with other readers even though the schema itself declares no target namespace.

Validating

IReadOnlyList<string> errors = MetronInfoXml.Validate("MetronInfo.xml");

if (errors.Count > 0)
{
    foreach (var error in errors)
    {
        Console.WriteLine(error);
    }
}

Validate checks the document against the embedded copy of MetronInfo.xsd. It also separately enforces the "at most one primary=\"true\"" rules on IDS/ID and URLs/URL — the schema expresses these as XSD 1.1 xs:assert rules, which .NET's built-in XSD 1.0 validator cannot evaluate on its own.

Notes

  • Models live under the MetronInfo.Xml.Models namespace and mirror the schema's element and attribute names.
  • xs:gYear (Series.StartYear) is modeled as int.
  • xs:date fields (CoverDate, StoreDate) and the xs:dateTime field (LastModified) are modeled as DateTime?.

License

GPL-3.0

About

A .NET library for reading and writing MetronInfo.xml files

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages