Skip to content

Class SchemaSet

Namespace: Apogee.Content.Xml
Assembly: Apogee.Content.dll

XSD, the parts content definitions need: checking XML against a schema and turning it into data (). A set is every .xsd file loaded into it (and the ones they include), so that a package can bring the schema of the definitions it adds, and the children it adds to an open element of another's.

Supported: element and attribute declarations (type, ref for elements, default, fixed, use, minOccurs, maxOccurs), complexType with sequence, choice and all (the order of children is not checked; a choice's members each repeat as they say, so a choice repeated stands for any order), group and attributeGroup, complexContent and simpleContent extensions, any and anyAttribute, simpleType restrictions (enumeration, minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, minLength, maxLength, length) and lists, the built-in types, annotation, and include/import of a file by its location (no namespaces: names are plain). Anything else is a that names it, so a schema never means less than it says.

public sealed class SchemaSet

Inheritance

object ← SchemaSet

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Properties

ElementNames

The names of the global elements, sorted: the kinds of definition and open-content children the schemas describe.

public IReadOnlyList<string> ElementNames { get; }

Property Value

IReadOnlyList<string>

Methods

Decode(XmlNode, string?, string?)

Checks node against the schemas and turns it into data. An element with a complex type is a record: its attributes (numbers, booleans and text by their types, a list type as a list), the defaults of the attributes it leaves out, and its child elements by name; a child that may repeat is a list; an element that holds nothing but one repeatable element (<units><unit/><unit/></units>) is that list; an element with a simple type is its value. Two conventions are read from an element's xs:appinfo: map (a container of <entry key="…"> items is a record by the keys; an item that has nothing but a key and a value gives the value) and defaults (the element left out is decoded as an empty one, so that the defaults of its attributes apply; a list left out is empty). An open element (xs:any) gives each child the global element <its name>.<child name> when the schemas have one, and keeps the others as they are.

public DecodeResult Decode(XmlNode node, string? origin = null, string? asElement = null)

Parameters

node XmlNode

The element.

origin string?

The file it was read from, for the problems.

asElement string?

The global element to check it as (its own name by default).

Returns

DecodeResult

DocumentationOf(string)

The xs:documentation of a global element, if it has one.

public string? DocumentationOf(string element)

Parameters

element string

Returns

string?

HasElement(string)

public bool HasElement(string name)

Parameters

name string

Returns

bool

LoadFile(VirtualFileSystem, string)

Loads the schema at path (a virtual path) and the files it includes, which are found beside it. A file that is loaded already is not loaded again.

public void LoadFile(VirtualFileSystem files, string path)

Parameters

files VirtualFileSystem

path string

Exceptions

SchemaException

The schema is invalid or uses something outside the supported subset.

XmlParseException

A file is not well-formed XML.

LoadFolder(VirtualFileSystem, string)

Loads every .xsd under a folder (sorted, folders last-in-first-out as lists them).

public void LoadFolder(VirtualFileSystem files, string folder)

Parameters

files VirtualFileSystem

folder string

LoadText(string, string, VirtualFileSystem?)

Loads a schema from text. files is where its includes are looked for (none: an include is an error).

public void LoadText(string xsd, string origin = "schema.xsd", VirtualFileSystem? files = null)

Parameters

xsd string

origin string

files VirtualFileSystem?