Consolidates the in-progress #146 work; valid-instances-rejected reaches 4 on the 2006-11-06 XSTS archive (buckets now 1/262/4/147). Regex: match Unicode scalars rather than grapheme clusters; the empty pattern matches only the empty string; pin the category repertoire to Unicode 3.2, the version the corpus is consistent at, so code points added in 3.2 (Tagalog, Cyrillic Komi) are word characters while later additions (the Tamil digit zero) stay unassigned and match \D. New XSDCategory and a 3.2 assignment table derived from DerivedAge, replacing the old Unicode31 files. Content model: assess each child against the particle the content automaton matched, not a by-name lookup (#180). Two same-named particles keep their own fixed values, and an element matching a skip wildcard is no longer validated against its global declaration. Selection is made reproducible when an ambiguous schema slips past the UPA check. XSTS runner: compile and merge every schemaDocument in a schemaTest, not just the first; this also surfaced one previously-masked invalid-instance acceptance (recorded in the baselines). Also folds in attribute-group anyAttribute inheritance, extension wildcard union, namespace-qualified type tables for multi-document xsi:schemaLocation, per-container elementFormDefault, strict and lax attribute wildcard validation, built-in type resolution, and xs:redefine simpleType overrides.
34 lines
1.4 KiB
Swift
34 lines
1.4 KiB
Swift
extension PureXML.Schema {
|
|
/// Builds the XSD-style ``Facets`` a RELAX NG datatype constrains its base type
|
|
/// with, from `<param name= >value` pairs (XML syntax) or `name "value"` pairs
|
|
/// (compact syntax). Shared by both RELAX NG parsers.
|
|
enum RelaxNGFacets {
|
|
static func apply(_ name: String, _ value: String, into facets: inout Facets) {
|
|
applyValue(name, value, into: &facets)
|
|
applyNumeric(name, Int(value), into: &facets)
|
|
}
|
|
|
|
private static func applyValue(_ name: String, _ value: String, into facets: inout Facets) {
|
|
switch name {
|
|
case "pattern": facets.patternGroups.append([value])
|
|
case "minInclusive": facets.minInclusive = value
|
|
case "maxInclusive": facets.maxInclusive = value
|
|
case "minExclusive": facets.minExclusive = value
|
|
case "maxExclusive": facets.maxExclusive = value
|
|
default: break
|
|
}
|
|
}
|
|
|
|
private static func applyNumeric(_ name: String, _ number: Int?, into facets: inout Facets) {
|
|
switch name {
|
|
case "length": facets.length = number
|
|
case "minLength": facets.minLength = number
|
|
case "maxLength": facets.maxLength = number
|
|
case "totalDigits": facets.totalDigits = number
|
|
case "fractionDigits": facets.fractionDigits = number
|
|
default: break
|
|
}
|
|
}
|
|
}
|
|
}
|