PhoenixmlDb.Core

SchemaPatternGuard

Bounds the regular expressions behind XSD pattern facets. System.Xml builds them with no match timeout of its own, so a pattern that backtracks catastrophically runs for as long as the value makes it, in a cast to a schema type, in validation, and while the schema compiles (which checks the schema's own enumeration, default and fixed values against its patterns).

#SchemaPatternGuard

Namespace: PhoenixmlDb.Core.Schema

Bounds the regular expressions behind XSD

pattern

facets. System.Xml builds them with no match timeout of its own, so a pattern that backtracks catastrophically runs for as long as the value makes it, in a cast to a schema type, in validation, and while the schema compiles (which checks the schema's own enumeration, default and fixed values against its patterns).

A compiled schema set keeps each type's patterns as Regex objects in a list that has no public accessor. SchemaPatternGuard.Bound replaces each with the same expression and a match timeout, which is the only way to reach the matches a validating reader makes: it sees a value and its type together, and nothing outside it does before the match runs.

That reads System.Xml's private state, so it fails closed: where the expected shape is missing and the schema set declares a pattern, SchemaPatternGuard.Bound throws rather than report a bound it did not apply.

#Methods

#Bound(Xml.Schema.XmlSchemaSet,TimeSpan)

Gives every pattern facet of a compiled schema set the match timeout

. Returns how many patterns the set's types carry.

Exceptions:

  • NotSupportedException — The set declares a pattern facet and none could be reached on this runtime.

#CheckSchemaLiterals(Xml.Schema.XmlSchemaSet,TimeSpan,Collections.Generic.HashSet<String>,Collections.Generic.HashSet<String>)

Runs every pattern facet of the set against every value the schemas themselves supply (other facets' values, defaults and fixed values), each match under

, before the set is compiled. Compiling makes those matches with no timeout. Pairs already checked are remembered in

and

.

Exceptions:

#ToNetPattern(String)

The .NET expression System.Xml builds for one pattern facet: anchored, grouped, with the XSD class escapes rewritten to the classes .NET keeps for them.

#Walk(Xml.Schema.XmlSchemaSet)

Every schema object reachable from the set: the schema documents with what they include, import and redefine, and — once compiled — the types, elements and attributes the compilation resolved, anonymous ones included.