Documentation
¶
Overview ¶
union_list_types.go - Implementation of XSD union and list simple types validation
This file provides validation support for: - Union types: values that can be valid against any one of multiple member types - List types: space-separated lists of values of a specific item type - Proper namespace resolution for type references (fixed parseQName in schema.go) - Integration with the overall XSD validation framework
Index ¶
- Constants
- Variables
- func AnalyzeTestFailures(results []W3CTestResult) map[string]*FailureCategory
- func ApplyDefaultValue(elem xmldom.Element, defaultValue string) string
- func CombineEnumerations(facets []FacetValidator) []string
- func CountWildcardMatches(elements []xmldom.Element, wildcard *AnyElement, targetNamespace string) int
- func ExtractNamespaces(doc xmldom.Document) map[string]NamespaceAttr
- func GenerateFailureReport(categories map[string]*FailureCategory) string
- func GetBuiltinTypeValidator(typeName string) func(string) error
- func HasDefaultValue(decl interface{}) (string, bool)
- func HasFixedValue(decl interface{}) (string, bool)
- func IsBuiltinType(name string) bool
- func MatchesWildcard(elem xmldom.Element, namespace string, targetNamespace string) bool
- func NormalizeWhiteSpace(value string, whiteSpace string) string
- func ValidateFacets(value string, facets []FacetValidator, baseType Type) error
- func ValidateListType(value string, list *List, schema *Schema) error
- func ValidateSchemaFile(filename string) []error
- func ValidateUnionType(value string, union *Union, schema *Schema) error
- type AllowAnyContent
- type AnyAttribute
- type AnyElement
- type AttributeDecl
- type AttributeGroup
- type AttributeUse
- type BuiltinType
- type ComplexContent
- type ComplexType
- type Content
- type Diagnostic
- type DiagnosticConverter
- type ElementDecl
- type ElementRef
- type EnumerationFacet
- type ErrorFormatter
- type Extension
- type Facet
- type FacetValidator
- type FailureCategory
- type Field
- type FractionDigitsFacet
- type GroupRef
- type IdentityConstraint
- type IdentityConstraintKind
- type IdentityConstraintValidator
- type Import
- type LengthFacet
- type List
- type MaxExclusiveFacet
- type MaxInclusiveFacet
- type MaxLengthFacet
- type MinExclusiveFacet
- type MinInclusiveFacet
- type MinLengthFacet
- type ModelGroup
- type ModelGroupKind
- type NamespaceAttr
- type Particle
- type PatternFacet
- type PatternLoader
- type Position
- type ProcessContentsMode
- type QName
- type Related
- type Restriction
- type Schema
- type SchemaCache
- func (sc *SchemaCache) Clear()
- func (sc *SchemaCache) Get(location string) (*Schema, error)
- func (sc *SchemaCache) GetOrLoad(location string, doc xmldom.Document) (*Schema, error)
- func (sc *SchemaCache) PreloadCommonTypes()
- func (sc *SchemaCache) Remove(location string)
- func (sc *SchemaCache) SetBasePath(path string)
- type SchemaLoader
- type SchemaLoaderConfig
- type SchemaLoaderFunc
- type SchemaRegistry
- func (sr *SchemaRegistry) GetForNamespace(namespace string) (*Schema, bool)
- func (sr *SchemaRegistry) Register(namespace string, schema *Schema)
- func (sr *SchemaRegistry) RegisterFile(namespace, location string) error
- func (sr *SchemaRegistry) SetDefault(schema *Schema)
- func (sr *SchemaRegistry) Validate(doc xmldom.Document) []Violation
- type SchemaValidator
- type Selector
- type Severity
- type SimpleContent
- type SimpleType
- type TotalDigitsFacet
- type Type
- type Union
- type Validator
- type Violation
- func ValidateAnyAttribute(attr xmldom.Node, wildcard *AnyAttribute, schema *Schema) []Violation
- func ValidateAnyElement(elem xmldom.Element, wildcard *AnyElement, schema *Schema) []Violation
- func ValidateAttributeFixedDefault(attr xmldom.Node, decl *AttributeDecl, elem xmldom.Element) []Violation
- func ValidateChildSequence(elem xmldom.Element, expected []string) []Violation
- func ValidateElementFixedDefault(elem xmldom.Element, decl *ElementDecl) []Violation
- func ValidateFixedValue(value, fixed string, isElement bool, name string) *Violation
- func ValidateWildcardOccurrences(matchCount int, wildcard *AnyElement) []Violation
- type W3CAnnotation
- type W3CCurrentStatus
- type W3CDocReference
- type W3CExpected
- type W3CInstanceDoc
- type W3CInstanceTest
- type W3CSchemaDoc
- type W3CSchemaTest
- type W3CTestGroup
- type W3CTestResult
- type W3CTestRunner
- func (r *W3CTestRunner) GenerateReport() string
- func (r *W3CTestRunner) LoadTestSet(metadataPath string) (*W3CTestSet, error)
- func (r *W3CTestRunner) RunAllTests(pattern string) error
- func (r *W3CTestRunner) RunMetadataFile(metadataPath string) error
- func (r *W3CTestRunner) RunTestSet(testSet *W3CTestSet, metadataDir string)
- type W3CTestSet
- type WhiteSpaceFacet
- type WildcardNamespaceConstraint
Constants ¶
const XSDNamespace = "http://www.w3.org/2001/XMLSchema"
XSDNamespace is the XML Schema namespace
Variables ¶
var GlobalCache = NewSchemaCache("")
GlobalCache is the singleton schema cache
Functions ¶
func AnalyzeTestFailures ¶
func AnalyzeTestFailures(results []W3CTestResult) map[string]*FailureCategory
AnalyzeTestFailures categorizes test failures by XSD feature
func ApplyDefaultValue ¶
ApplyDefaultValue applies a default value to an element or attribute if it's empty
func CombineEnumerations ¶
func CombineEnumerations(facets []FacetValidator) []string
CombineEnumerations combines multiple enumeration facets
func CountWildcardMatches ¶
func CountWildcardMatches(elements []xmldom.Element, wildcard *AnyElement, targetNamespace string) int
CountWildcardMatches counts how many elements match a wildcard
func ExtractNamespaces ¶
func ExtractNamespaces(doc xmldom.Document) map[string]NamespaceAttr
ExtractNamespaces extracts all xmlns namespace declarations from an XML document
func GenerateFailureReport ¶
func GenerateFailureReport(categories map[string]*FailureCategory) string
GenerateFailureReport creates a detailed failure analysis report
func GetBuiltinTypeValidator ¶
GetBuiltinTypeValidator returns a validator function for a built-in XSD type
func HasDefaultValue ¶
HasDefaultValue checks if an element or attribute declaration has a default value
func HasFixedValue ¶
HasFixedValue checks if an element or attribute declaration has a fixed value
func IsBuiltinType ¶
IsBuiltinType checks if a type is a built-in XSD type
func MatchesWildcard ¶
MatchesWildcard checks if an element matches a wildcard's namespace constraint
func NormalizeWhiteSpace ¶
NormalizeWhiteSpace normalizes whitespace according to the facet value
func ValidateFacets ¶
func ValidateFacets(value string, facets []FacetValidator, baseType Type) error
ValidateFacets validates a value against a list of facets
func ValidateListType ¶
ValidateListType validates a value against a list type A list type represents a space-separated list of values of the item type
func ValidateSchemaFile ¶
ValidateSchemaFile validates an XSD schema file and returns any errors
Types ¶
type AllowAnyContent ¶
type AllowAnyContent struct{}
AllowAnyContent is a content model that allows any child elements
type AnyAttribute ¶
AnyAttribute represents xs:anyAttribute
type AnyElement ¶
AnyElement represents xs:any wildcard
func (*AnyElement) MaxOccurs ¶
func (ae *AnyElement) MaxOccurs() int
func (*AnyElement) MinOccurs ¶
func (ae *AnyElement) MinOccurs() int
type AttributeDecl ¶
type AttributeDecl struct {
Name QName
Type Type
Use AttributeUse
Default string
Fixed string
}
AttributeDecl represents an attribute declaration
type AttributeGroup ¶
type AttributeGroup struct {
Name QName
Attributes []*AttributeDecl
}
AttributeGroup represents a group of attributes
type AttributeUse ¶
type AttributeUse string
AttributeUse represents attribute use
const ( OptionalUse AttributeUse = "optional" RequiredUse AttributeUse = "required" ProhibitedUse AttributeUse = "prohibited" )
type BuiltinType ¶
BuiltinType represents a built-in XSD type
func GetBuiltinType ¶
func GetBuiltinType(name string) *BuiltinType
GetBuiltinType returns a built-in type validator
type ComplexContent ¶
type ComplexContent struct {
Mixed bool
Base QName
Extension *Extension
Restriction *Restriction
}
ComplexContent represents complex content
func (*ComplexContent) MaxOccurs ¶
func (cc *ComplexContent) MaxOccurs() int
func (*ComplexContent) MinOccurs ¶
func (cc *ComplexContent) MinOccurs() int
type ComplexType ¶
type ComplexType struct {
QName QName
Content Content
Attributes []*AttributeDecl
AttributeGroup []QName
AnyAttribute *AnyAttribute
Mixed bool
Abstract bool
Final map[string]bool // final constraints: extension, restriction
DerivedByExtension bool // set true if this type (or its base chain) includes an extension
}
ComplexType represents an XSD complex type
func (*ComplexType) Name ¶
func (ct *ComplexType) Name() QName
type Diagnostic ¶
type Diagnostic struct {
Severity Severity `json:"severity"`
Code string `json:"code"`
Message string `json:"message"`
Position Position `json:"position"`
Tag string `json:"tag"`
Attribute string `json:"attribute,omitempty"`
SpecRef string `json:"spec_ref,omitempty"`
Hints []string `json:"hints,omitempty"`
Related []Related `json:"related,omitempty"`
}
Diagnostic represents a rustc-style validation diagnostic
type DiagnosticConverter ¶
type DiagnosticConverter struct {
// contains filtered or unexported fields
}
DiagnosticConverter converts XSD violations to rustc-style diagnostics
func NewDiagnosticConverter ¶
func NewDiagnosticConverter(fileName, source string) *DiagnosticConverter
NewDiagnosticConverter creates a new converter
func (*DiagnosticConverter) Convert ¶
func (dc *DiagnosticConverter) Convert(violations []Violation) []Diagnostic
Convert converts XSD violations to rustc-style diagnostics
type ElementDecl ¶
type ElementDecl struct {
Name QName
Type Type
MinOcc int // Renamed to avoid conflict with Particle interface method
MaxOcc int // -1 for unbounded, renamed to avoid conflict
Nillable bool
Abstract bool
SubstitutionGroup QName // Head element this element can substitute for
Block map[string]bool // Disallowed substitutions from @block
Default string
Fixed string
Constraints []*IdentityConstraint // Identity constraints (key, keyref, unique)
}
ElementDecl represents an element declaration
func (*ElementDecl) MaxOccurs ¶
func (ed *ElementDecl) MaxOccurs() int
func (*ElementDecl) MinOccurs ¶
func (ed *ElementDecl) MinOccurs() int
Particle interface implementation for inline ElementDecl
type ElementRef ¶
type ElementRef struct {
Ref QName
MinOcc int // Renamed to avoid conflict with method
MaxOcc int // Renamed to avoid conflict with method
}
ElementRef represents a reference to an element
func (*ElementRef) MaxOccurs ¶
func (er *ElementRef) MaxOccurs() int
func (*ElementRef) MinOccurs ¶
func (er *ElementRef) MinOccurs() int
type EnumerationFacet ¶
type EnumerationFacet struct {
Values []string
}
EnumerationFacet validates against a set of allowed values
func (*EnumerationFacet) Name ¶
func (f *EnumerationFacet) Name() string
type ErrorFormatter ¶
ErrorFormatter provides rustc-style error formatting
func (*ErrorFormatter) Format ¶
func (ef *ErrorFormatter) Format(diag Diagnostic, source string) string
Format formats a diagnostic in rustc style
type Extension ¶
type Extension struct {
Base QName
Attributes []*AttributeDecl
Content Content
AnyAttribute *AnyAttribute
}
Extension represents type extension
type FacetValidator ¶
FacetValidator validates a value against a facet constraint
func ParseFacet ¶
func ParseFacet(name string, value string) FacetValidator
ParseFacet parses a facet element and returns the appropriate FacetValidator
type FailureCategory ¶
type FailureCategory struct {
Name string
Description string
Count int
Examples []W3CTestResult
}
FailureCategory represents a category of test failures
type Field ¶
type Field struct {
XPath string // XPath expression to select field value
}
Field represents the xs:field element
type FractionDigitsFacet ¶
type FractionDigitsFacet struct {
Value int
}
FractionDigitsFacet validates number of fraction digits
func (*FractionDigitsFacet) Name ¶
func (f *FractionDigitsFacet) Name() string
type IdentityConstraint ¶
type IdentityConstraint struct {
Name string
Kind IdentityConstraintKind
Selector *Selector
Fields []*Field
Refer QName // For keyref, refers to a key or unique constraint
}
IdentityConstraint represents an identity constraint (key, keyref, or unique)
type IdentityConstraintKind ¶
type IdentityConstraintKind string
IdentityConstraintKind represents the type of identity constraint
const ( KeyConstraint IdentityConstraintKind = "key" KeyRefConstraint IdentityConstraintKind = "keyref" UniqueConstraint IdentityConstraintKind = "unique" )
type IdentityConstraintValidator ¶
type IdentityConstraintValidator struct {
// contains filtered or unexported fields
}
IdentityConstraintValidator validates identity constraints in XML documents
func NewIdentityConstraintValidator ¶
func NewIdentityConstraintValidator() *IdentityConstraintValidator
NewIdentityConstraintValidator creates a new identity constraint validator
func (*IdentityConstraintValidator) AddConstraint ¶
func (v *IdentityConstraintValidator) AddConstraint(constraint *IdentityConstraint)
AddConstraint adds an identity constraint to the validator
type LengthFacet ¶
type LengthFacet struct {
Value int
}
LengthFacet validates exact length
func (*LengthFacet) Name ¶
func (f *LengthFacet) Name() string
type MaxExclusiveFacet ¶
type MaxExclusiveFacet struct {
Value string
}
MaxExclusiveFacet validates maximum value (exclusive)
func (*MaxExclusiveFacet) Name ¶
func (f *MaxExclusiveFacet) Name() string
type MaxInclusiveFacet ¶
type MaxInclusiveFacet struct {
Value string
}
MaxInclusiveFacet validates maximum value (inclusive)
func (*MaxInclusiveFacet) Name ¶
func (f *MaxInclusiveFacet) Name() string
type MaxLengthFacet ¶
type MaxLengthFacet struct {
Value int
}
MaxLengthFacet validates maximum length
func (*MaxLengthFacet) Name ¶
func (f *MaxLengthFacet) Name() string
type MinExclusiveFacet ¶
type MinExclusiveFacet struct {
Value string
}
MinExclusiveFacet validates minimum value (exclusive)
func (*MinExclusiveFacet) Name ¶
func (f *MinExclusiveFacet) Name() string
type MinInclusiveFacet ¶
type MinInclusiveFacet struct {
Value string
}
MinInclusiveFacet validates minimum value (inclusive)
func (*MinInclusiveFacet) Name ¶
func (f *MinInclusiveFacet) Name() string
type MinLengthFacet ¶
type MinLengthFacet struct {
Value int
}
MinLengthFacet validates minimum length
func (*MinLengthFacet) Name ¶
func (f *MinLengthFacet) Name() string
type ModelGroup ¶
type ModelGroup struct {
Kind ModelGroupKind // sequence, choice, all
Particles []Particle
MinOcc int // Renamed to avoid conflict with method
MaxOcc int // Renamed to avoid conflict with method
}
ModelGroup represents a group of elements
func (*ModelGroup) MaxOccurs ¶
func (mg *ModelGroup) MaxOccurs() int
func (*ModelGroup) MinOccurs ¶
func (mg *ModelGroup) MinOccurs() int
type ModelGroupKind ¶
type ModelGroupKind string
ModelGroupKind represents the kind of model group
const ( SequenceGroup ModelGroupKind = "sequence" ChoiceGroup ModelGroupKind = "choice" AllGroup ModelGroupKind = "all" )
type NamespaceAttr ¶
type NamespaceAttr struct {
Prefix string // Namespace prefix (empty for default namespace)
URI string // Namespace URI
Attr xmldom.Attr // The xmlns attribute node
}
NamespaceAttr holds a namespace URI and its attribute node
type Particle ¶
type Particle interface {
MinOccurs() int
MaxOccurs() int
Validate(element xmldom.Element, schema *Schema) []Violation
}
Particle represents a particle in a content model
type PatternFacet ¶
type PatternFacet struct {
Pattern string
// contains filtered or unexported fields
}
PatternFacet validates against a regular expression pattern
func (*PatternFacet) Name ¶
func (f *PatternFacet) Name() string
type PatternLoader ¶
type PatternLoader struct {
Pattern string // Regex pattern to match against namespace
Loader SchemaLoaderFunc // Function to load the schema
// contains filtered or unexported fields
}
PatternLoader associates a pattern with a loader function
type Position ¶
type Position struct {
File string `json:"file"`
Line int `json:"line"`
Column int `json:"column"`
Offset int64 `json:"offset"`
}
Position contains source position information for a node
type ProcessContentsMode ¶
type ProcessContentsMode string
ProcessContentsMode defines how wildcard content should be processed
const ( // StrictProcess requires the element/attribute to be validated against its declaration StrictProcess ProcessContentsMode = "strict" // LaxProcess validates if a declaration is found, otherwise allows it LaxProcess ProcessContentsMode = "lax" // SkipProcess allows the element/attribute without validation SkipProcess ProcessContentsMode = "skip" )
type Restriction ¶
type Restriction struct {
Base QName
Facets []FacetValidator
// For complexContent restrictions
Content Content
Attributes []*AttributeDecl
AnyAttribute *AnyAttribute
}
Restriction represents a restriction on a type
type Schema ¶
type Schema struct {
TargetNamespace string
ElementDecls map[QName]*ElementDecl
TypeDefs map[QName]Type
AttributeGroups map[QName]*AttributeGroup
Groups map[QName]*ModelGroup
Imports []*Import
ImportedSchemas map[string]*Schema // Map of imported schemas by location
SubstitutionGroups map[QName][]QName // Maps head element to list of substitutable elements
BlockDefault map[string]bool // xs:schema@blockDefault tokens
FinalDefault map[string]bool // xs:schema@finalDefault tokens
ElementFormDefault string // "qualified" or "unqualified" (default)
AttributeFormDefault string // "qualified" or "unqualified" (default)
// Options
StrictContentModel bool // If true, use strict content-model validation
// contains filtered or unexported fields
}
Schema represents a compiled XSD schema
func LoadSchema ¶
LoadSchema loads and parses an XSD schema from a file
func LoadSchemaFromString ¶
LoadSchemaFromString loads a schema from a string with import/include support
func LoadSchemaWithImports ¶
LoadSchemaWithImports is a convenience function
func (*Schema) ResolveAttributeGroups ¶
func (s *Schema) ResolveAttributeGroups(ct *ComplexType) []*AttributeDecl
ResolveAttributeGroups resolves all attribute group references for a complex type
func (*Schema) ValidateContentModels ¶ added in v0.1.4
ValidateContentModels performs determinism (UPA) checks on compiled content models
type SchemaCache ¶
type SchemaCache struct {
BasePath string // Base path for resolving relative schema locations
// contains filtered or unexported fields
}
SchemaCache manages cached XSD schemas using sync.OnceValue per project rules
func NewSchemaCache ¶
func NewSchemaCache(basePath string) *SchemaCache
NewSchemaCache creates a new schema cache
func (*SchemaCache) Get ¶
func (sc *SchemaCache) Get(location string) (*Schema, error)
Get retrieves a schema from cache or loads it if not present
func (*SchemaCache) PreloadCommonTypes ¶
func (sc *SchemaCache) PreloadCommonTypes()
PreloadCommonTypes preloads commonly used XSD types for performance
func (*SchemaCache) Remove ¶
func (sc *SchemaCache) Remove(location string)
Remove removes a specific schema from cache
func (*SchemaCache) SetBasePath ¶
func (sc *SchemaCache) SetBasePath(path string)
SetBasePath sets the base path for resolving relative schema locations
type SchemaLoader ¶
type SchemaLoader struct {
// Base directory for resolving relative paths
BaseDir string
// contains filtered or unexported fields
}
SchemaLoader handles loading schemas with import/include support
func NewSchemaLoader ¶
func NewSchemaLoader(config SchemaLoaderConfig) (*SchemaLoader, error)
NewSchemaLoader creates a new schema loader with the given configuration
func NewSchemaLoaderSimple ¶
func NewSchemaLoaderSimple(baseDir string) *SchemaLoader
NewSchemaLoaderSimple creates a simple schema loader with just a base directory This is a convenience function for when you don't need custom loaders
func (*SchemaLoader) LoadSchemaForNamespace ¶
func (sl *SchemaLoader) LoadSchemaForNamespace(namespace string) (*Schema, error)
LoadSchemaForNamespace is deprecated - use LoadSchemasFromNamespaces instead This method cannot provide the xmlns attribute node that loaders need
func (*SchemaLoader) LoadSchemaWithImports ¶
func (sl *SchemaLoader) LoadSchemaWithImports(location string) (*Schema, error)
LoadSchemaWithImports loads a schema and all its imports/includes
func (*SchemaLoader) LoadSchemasFromNamespaces ¶
func (sl *SchemaLoader) LoadSchemasFromNamespaces(namespaces map[string]NamespaceAttr) (*Schema, error)
LoadSchemasFromNamespaces loads schemas for the given namespaces using configured loaders Returns a combined schema with all loaded schemas merged
type SchemaLoaderConfig ¶
type SchemaLoaderConfig struct {
// Base directory for resolving relative paths
BaseDir string
// HTTP client for remote loading (optional, defaults to http.DefaultClient)
HTTPClient *http.Client
// Pattern-based loaders for namespace resolution
Loaders []PatternLoader
}
SchemaLoaderConfig configures a SchemaLoader with dependency injection
type SchemaLoaderFunc ¶
SchemaLoaderFunc is a function that loads a schema for a given namespace attribute node The attr parameter is the xmlns attribute node from which the namespace URI can be extracted
type SchemaRegistry ¶
type SchemaRegistry struct {
// contains filtered or unexported fields
}
SchemaRegistry manages multiple schemas for different namespaces
func NewSchemaRegistry ¶
func NewSchemaRegistry() *SchemaRegistry
NewSchemaRegistry creates a new schema registry
func (*SchemaRegistry) GetForNamespace ¶
func (sr *SchemaRegistry) GetForNamespace(namespace string) (*Schema, bool)
GetForNamespace retrieves the schema for a namespace
func (*SchemaRegistry) Register ¶
func (sr *SchemaRegistry) Register(namespace string, schema *Schema)
Register registers a schema for a namespace
func (*SchemaRegistry) RegisterFile ¶
func (sr *SchemaRegistry) RegisterFile(namespace, location string) error
RegisterFile registers a schema from a file
func (*SchemaRegistry) SetDefault ¶
func (sr *SchemaRegistry) SetDefault(schema *Schema)
SetDefault sets the default schema for elements without namespaces
type SchemaValidator ¶
type SchemaValidator struct {
// contains filtered or unexported fields
}
SchemaValidator validates that an XSD schema document conforms to XSD rules
func NewSchemaValidator ¶
func NewSchemaValidator() *SchemaValidator
NewSchemaValidator creates a new schema validator
func (*SchemaValidator) ValidateSchema ¶
func (sv *SchemaValidator) ValidateSchema(doc xmldom.Document) []error
ValidateSchema validates that a schema document conforms to XSD rules
type Selector ¶
type Selector struct {
XPath string // XPath expression to select nodes
}
Selector represents the xs:selector element
type SimpleContent ¶
type SimpleContent struct {
Base QName
Extension *Extension
Restriction *Restriction
}
SimpleContent represents simple content in a complex type
func (*SimpleContent) MaxOccurs ¶
func (sc *SimpleContent) MaxOccurs() int
func (*SimpleContent) MinOccurs ¶
func (sc *SimpleContent) MinOccurs() int
type SimpleType ¶
type SimpleType struct {
QName QName
Base QName
Restriction *Restriction
List *List
Union *Union
}
SimpleType represents an XSD simple type
func (*SimpleType) Name ¶
func (st *SimpleType) Name() QName
type TotalDigitsFacet ¶
type TotalDigitsFacet struct {
Value int
}
TotalDigitsFacet validates total number of digits
func (*TotalDigitsFacet) Name ¶
func (f *TotalDigitsFacet) Name() string
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator validates XML documents against XSD schemas
func NewValidator ¶
NewValidator creates a new validator for a schema
type Violation ¶
type Violation struct {
Element xmldom.Element
Attribute string
Code string
Message string
Expected []string
Actual string
}
Violation represents a validation error
func ValidateAnyAttribute ¶
func ValidateAnyAttribute(attr xmldom.Node, wildcard *AnyAttribute, schema *Schema) []Violation
ValidateAnyAttribute validates attributes against xs:anyAttribute wildcard constraints
func ValidateAnyElement ¶
func ValidateAnyElement(elem xmldom.Element, wildcard *AnyElement, schema *Schema) []Violation
ValidateAnyElement validates an element against xs:any wildcard constraints
func ValidateAttributeFixedDefault ¶
func ValidateAttributeFixedDefault(attr xmldom.Node, decl *AttributeDecl, elem xmldom.Element) []Violation
ValidateAttributeFixedDefault validates fixed and default values for an attribute
func ValidateChildSequence ¶
ValidateChildSequence validates a sequence of child elements
func ValidateElementFixedDefault ¶
func ValidateElementFixedDefault(elem xmldom.Element, decl *ElementDecl) []Violation
ValidateElementFixedDefault validates fixed and default values for an element
func ValidateFixedValue ¶
ValidateFixedValue validates that an element or attribute has the required fixed value
func ValidateWildcardOccurrences ¶
func ValidateWildcardOccurrences(matchCount int, wildcard *AnyElement) []Violation
ValidateWildcardOccurrences validates that wildcard occurrences are within bounds
type W3CAnnotation ¶
type W3CAnnotation struct {
Documentation string `xml:"documentation"`
}
W3CAnnotation contains test documentation
type W3CCurrentStatus ¶
type W3CCurrentStatus struct {
Status string `xml:"status,attr"` // "accepted", "disputed", etc.
Date string `xml:"date,attr"`
}
W3CCurrentStatus tracks test acceptance status
type W3CDocReference ¶
type W3CDocReference struct {
Href string `xml:"href,attr"`
}
W3CDocReference links to specification documentation
type W3CExpected ¶
type W3CExpected struct {
Validity string `xml:"validity,attr"` // "valid", "invalid", or "notKnown"
}
W3CExpected indicates expected validity
type W3CInstanceDoc ¶
type W3CInstanceDoc struct {
Href string `xml:"href,attr"`
}
W3CInstanceDoc references an instance document
type W3CInstanceTest ¶
type W3CInstanceTest struct {
Name string `xml:"name,attr"`
InstanceDocument W3CInstanceDoc `xml:"instanceDocument"`
Expected W3CExpected `xml:"expected"`
Current W3CCurrentStatus `xml:"current"`
}
W3CInstanceTest tests whether an instance validates against a schema
type W3CSchemaDoc ¶
type W3CSchemaDoc struct {
Href string `xml:"href,attr"`
}
W3CSchemaDoc references a schema document
type W3CSchemaTest ¶
type W3CSchemaTest struct {
Name string `xml:"name,attr"`
SchemaDocument W3CSchemaDoc `xml:"schemaDocument"`
Expected W3CExpected `xml:"expected"`
Current W3CCurrentStatus `xml:"current"`
}
W3CSchemaTest tests whether a schema is valid or invalid
type W3CTestGroup ¶
type W3CTestGroup struct {
Name string `xml:"name,attr"`
Annotation *W3CAnnotation `xml:"annotation"`
DocReference *W3CDocReference `xml:"documentationReference"`
SchemaTests []W3CSchemaTest `xml:"schemaTest"`
InstanceTests []W3CInstanceTest `xml:"instanceTest"`
}
W3CTestGroup represents a test group containing related tests
type W3CTestResult ¶
type W3CTestResult struct {
TestSet string
TestGroup string
TestName string
TestType string // "schema" or "instance"
Expected string // "valid", "invalid", "notKnown"
Actual string // "valid", "invalid", "error"
Passed bool
Error error
SchemaPath string
InstancePath string
}
W3CTestResult captures the result of running a test
type W3CTestRunner ¶
type W3CTestRunner struct {
TestSuiteDir string
Results []W3CTestResult
Verbose bool
StrictContentModel bool
Grep string // optional substring filter on set/group/test names
}
W3CTestRunner runs W3C XSD conformance tests
func NewW3CTestRunner ¶
func NewW3CTestRunner(testSuiteDir string) *W3CTestRunner
NewW3CTestRunner creates a test runner for the W3C test suite
func (*W3CTestRunner) GenerateReport ¶
func (r *W3CTestRunner) GenerateReport() string
GenerateReport generates a summary report of test results
func (*W3CTestRunner) LoadTestSet ¶
func (r *W3CTestRunner) LoadTestSet(metadataPath string) (*W3CTestSet, error)
LoadTestSet loads a W3C test set from an XML file
func (*W3CTestRunner) RunAllTests ¶
func (r *W3CTestRunner) RunAllTests(pattern string) error
RunAllTests discovers and runs all test metadata files
func (*W3CTestRunner) RunMetadataFile ¶
func (r *W3CTestRunner) RunMetadataFile(metadataPath string) error
RunMetadataFile runs all tests from a single metadata file
func (*W3CTestRunner) RunTestSet ¶
func (r *W3CTestRunner) RunTestSet(testSet *W3CTestSet, metadataDir string)
RunTestSet runs all tests in a test set
type W3CTestSet ¶
type W3CTestSet struct {
XMLName xml.Name `xml:"testSet"`
Contributor string `xml:"contributor,attr"`
Name string `xml:"name,attr"`
TestGroups []W3CTestGroup `xml:"testGroup"`
}
W3CTestSet represents a test set from the W3C XSD test suite
type WhiteSpaceFacet ¶
type WhiteSpaceFacet struct {
Value string // "preserve", "replace", or "collapse"
}
WhiteSpaceFacet handles whitespace normalization
func (*WhiteSpaceFacet) Name ¶
func (f *WhiteSpaceFacet) Name() string
type WildcardNamespaceConstraint ¶
type WildcardNamespaceConstraint struct {
Mode string // "##any", "##other", "##targetNamespace", "##local", or space-separated list
Namespaces []string // Explicit list of allowed namespaces (when not using ##modes)
}
WildcardNamespaceConstraint represents namespace constraints for wildcards
func ParseNamespaceConstraint ¶
func ParseNamespaceConstraint(value string) *WildcardNamespaceConstraint
ParseNamespaceConstraint parses a namespace attribute value into a constraint
func (*WildcardNamespaceConstraint) Matches ¶
func (c *WildcardNamespaceConstraint) Matches(namespace, targetNamespace string) bool
Matches checks if a namespace matches this constraint