ddn.data.xml.xsd
XML Schema (XSD) 1.0 validation.
This module provides a native XSD representation and validator.
Supported schema features:
- Global
xs:elementdeclarations (multiple) withnameandtype - Global named
xs:complexTypeandxs:simpleTypewith type references xs:element ref='...'andxs:attribute ref='...'referencesxs:complexTypewithxs:sequence,xs:choice,xs:allcontent modelsxs:attributewithuse='required'or optional, with type referencesxs:group name='...'andxs:group ref='...'model group definitionsxs:attributeGroup name='...'andxs:attributeGroup ref='...'xs:extension base='...'inxs:complexContent(basic derivation)xs:restriction base='...'inxs:simpleContentandxs:simpleTypexs:includeandxs:importwith XML Catalog supportminOccurs/maxOccursoccurrence constraints (includingunbounded)xs:anywildcard (lax processing with sequence look-ahead)targetNamespacewithelementFormDefault/attributeFormDefaultawareness
Supported facets:
xs:minLength,xs:maxLength,xs:length(string-length constraints)xs:minInclusive,xs:maxInclusive(inclusive range bounds)xs:minExclusive,xs:maxExclusive(exclusive range bounds)xs:totalDigits(maximum number of decimal digits)xs:fractionDigits(maximum number of fractional digits)xs:pattern(regex pattern; multiple patterns are ORed)xs:whiteSpace(preserve, replace, collapse)xs:enumeration(value must match one of the listed values)
Supported built-in types:
- String types:
xs:string,xs:normalizedString,xs:token,xs:language,xs:NMTOKEN,xs:NMTOKENS,xs:ID,xs:IDREF,xs:anyURI,xs:anySimpleType - Numeric types:
xs:decimal,xs:float,xs:double - Integer types:
xs:integer,xs:int,xs:long,xs:short,xs:byte,xs:nonNegativeInteger,xs:positiveInteger,xs:nonPositiveInteger,xs:negativeInteger,xs:unsignedInt,xs:unsignedLong,xs:unsignedShort,xs:unsignedByte xs:boolean- Date/time types:
xs:date,xs:dateTime,xs:time
Remaining limitations:
xs:key/xs:keyrefidentity constraints are not supportedxs:uniqueidentity constraints are not supportedxs:assert/xs:assertion(XSD 1.1) are not supportedxs:redefineis not supportedxs:notationis not supportedxs:union/xs:listsimple type composition is not supported- Namespace-qualified element/attribute resolution is lexical-only
xs:complexTypemixed='true'is acknowledged but not enforcedxs:anynamespaceattribute is acknowledged but not filteredblock/finalattributes on types/elements are not enforcedxs:date/xs:dateTime/xs:timevalidation is structural (format-only)
Types 14
enumXsdBuiltinType
XSD built-in type supported by this module.
STRING`xs:string`
BOOLEAN`xs:boolean`
DECIMAL`xs:decimal`
FLOAT`xs:float`
DOUBLE`xs:double`
INT`xs:int`
INTEGER`xs:integer`
LONG`xs:long`
SHORT`xs:short`
BYTE`xs:byte`
NON_NEGATIVE_INTEGER`xs:nonNegativeInteger`
POSITIVE_INTEGER`xs:positiveInteger`
NON_POSITIVE_INTEGER`xs:nonPositiveInteger`
NEGATIVE_INTEGER`xs:negativeInteger`
UNSIGNED_INT`xs:unsignedInt`
UNSIGNED_LONG`xs:unsignedLong`
UNSIGNED_SHORT`xs:unsignedShort`
UNSIGNED_BYTE`xs:unsignedByte`
DATE`xs:date`
DATETIME`xs:dateTime`
TIME`xs:time`
ANY_URI`xs:anyURI`
ANY_SIMPLE_TYPE`xs:anySimpleType`
TOKEN`xs:token`
NORMALIZED_STRING`xs:normalizedString`
NMTOKEN`xs:NMTOKEN`
NMTOKENS`xs:NMTOKENS`
ID`xs:ID`
IDREF`xs:IDREF`
LANGUAGE`xs:language`
enumXsdWhiteSpace
XSD whiteSpace facet values.
PRESERVE
REPLACE
COLLAPSE
structXsdFacets
XSD facets supported by this module.
Fields
bool hasMinLengthsize_t minLengthbool hasMaxLengthsize_t maxLengthbool hasLengthsize_t length_bool hasMinInclusivedouble minInclusivebool hasMaxInclusivedouble maxInclusivebool hasMinExclusivedouble minExclusivebool hasMaxExclusivedouble maxExclusivebool hasTotalDigitssize_t totalDigitsbool hasFractionDigitssize_t fractionDigitsXsdWhiteSpace whiteSpacestring patternstring[] enumerationEnumeration values (from xs:enumeration facets).structXsdSimpleType
A simple type declaration.
enumXsdParticleKind
XSD particle kind.
ELEMENT
SEQUENCE
CHOICE
ALL
ANY
structXsdParticle
An XSD particle (element, sequence, choice, all, or any).
Fields
XsdParticleKind kindsize_t minOccurssize_t maxOccursstring nameElement name (for `ELEMENT` kind).string refNameElement ref name (when `ref=` is used instead of `name=`).XsdSimpleType typeSimple type of the element (for `ELEMENT` kind).XsdParticle[] childrenChild particles (for `SEQUENCE`, `CHOICE`, `ALL`).XsdAttributeDecl[] attributesAttributes for inline complex content.structXsdAttributeDecl
An attribute declaration.
Fields
string namebool requiredstring refNameAttribute ref name (when `ref=` is used).XsdSimpleType typeAttribute simple type (default: `xs:string`).structXsdSchema
Minimal schema model.
Fields
XsdElementDecl[] elementsGlobal element declarations indexed by name.XsdComplexType[string] complexTypesGlobal named complex types.XsdSimpleType[string] simpleTypesGlobal named simple types.XsdGroup[string] groupsGlobal named model groups.XsdAttributeGroup[string] attributeGroupsGlobal named attribute groups.string targetNamespaceTarget namespace.bool elementFormDefaultQualifiedelementFormDefault: 'qualified' or 'unqualified'.bool attributeFormDefaultQualifiedattributeFormDefault: 'qualified' or 'unqualified'.structXsdElementDecl
A global element declaration.
Fields
string nameElement name.XsdBuiltinType builtinTypeElement type (if simple).string typeNameNamed type reference (e.g. 'myType').XsdParticle particleInline content model (if complex).XsdFacets facetsInline facets (when simple content).XsdAttributeDecl[] attributesAttributes declared on this element.bool hasComplexContentWhether the type was resolved from a named complexType.bool hasInlineContentWhether this element has inline content (not a type reference).structXsdComplexType
A named complex type.
Fields
XsdParticle particleContent model particle.XsdAttributeDecl[] attributesAttributes.string extensionBaseExtension base type name.bool usesExtensionWhether this uses extension.bool mixedWhether mixed content is allowed.structXsdGroup
A named model group.
Fields
XsdParticle particleGroup content particle.structXsdAttributeGroup
A named attribute group.
Fields
XsdAttributeDecl[] attributesAttributes in this group.structXsdValidationResult
Result of validating a document against an XSD.
Fields
bool valid`true` if valid.string messageOptional message if invalid.structXsdParseOptions
Options controlling XSD parsing.
Fields
string[] catalogFilesXML Catalog files used to resolve `schemaLocation` values (system-id mapping).bool allowNetworkIf `true`, allow loading non-file URI schemas via `networkLoader`.const(ubyte)[] delegate(string uri) @safe networkLoaderOptional loader for non-file URI schemas (used when `allowNetwork=true`).bool cacheResourcesIf `true`, cache loaded schema bytes by resolved identifier.size_t maxDepthMaximum include/import recursion depth.size_t maxBytesMaximum schema bytes (0 = default).Functions 3
fn
XsdSchema parseXsdFromFile(string xsdFile, XsdParseOptions options = XsdParseOptions.init) @safeParses an XSD schema from a file, resolving `xs:include` and `xs:import`.fn
XsdValidationResult validateXsdDocument(XmlDocument doc, XsdSchema schema) @safeValidates `doc` against `schema`.