Skip to content

Package xsd ​

go
import "github.com/tim-riep/go-xslt/xsd"

A read-only view of a compiled XSD 1.0 or 1.1 schema. For a guided introduction see Reading a schema. To validate documents use engine.Validate.

Full generated documentation: pkg.go.dev/github.com/tim-riep/go-xslt/xsd

Compile ​

go
func Compile(req Request) (schema *Schema, diags []Diagnostic)

type Request struct {
	Schemas  []string // the first is the entry schema
	BaseDir  string   // resolves xs:import, xs:include, xs:redefine, xs:override
	Version  Version  // V10 (default) or V11
	Security Security // same type as engine.Security
}

On failure the schema is nil. A construct the compiler does not support is reported as such.

Schema ​

MethodReturns
GlobalElements() []*ElementAll global element declarations
GlobalTypes() []TypeDefinitionAll global type definitions
GlobalAttributes() []*AttributeDeclAll global attribute declarations
Element(xml.Name) *ElementOne global element
Type(xml.Name) TypeDefinitionOne type, including built-in types
SubstitutionMembers(head xml.Name) []*ElementThe members of a substitution group, transitively
Unresolved() []stringReferences to types the schema does not define

Element ​

Name(), Type(), Abstract(), Nillable(), Default(), Fixed(), SubstitutionGroups(), Documentation().

ComplexType ​

MethodReturns
Name()The type name; empty for an anonymous type
Base(), Derivation()The base type and extension or restriction
BuiltinBase()The built-in base type for simple content
ContentKind()ContentEmpty, ContentSimple, ContentElementOnly or ContentMixed
ContentModel() *ParticleThe effective content model
ContentParticles() []*ParticleThe particles of the top-level group
SimpleContent() *SimpleTypeThe type of simple content
Attributes() []*AttributeUseThe effective attributes
AttributeWildcard() *WildcardThe xs:anyAttribute, if any
Abstract(), Mixed(), IsSimple(), Documentation()

SimpleType ​

MethodReturns
Name(), Base(), BuiltinBase()Name, direct base, built-in base through restrictions
Variety()VarietyAtomic, VarietyList or VarietyUnion
ItemType(), MemberTypes()For list and union types
Facets(), Enumeration()The effective facets
IsSimple(), Documentation()

Particle ​

go
type Particle struct {
	MinOccurs     int
	MaxOccurs     int  // Unbounded (-1) for maxOccurs="unbounded"
	Term          Term // *Element, *ModelGroup or *Wildcard
	Documentation []Documentation
}

AttributeUse ​

go
type AttributeUse struct {
	Name        xml.Name
	Type        *SimpleType
	Use         Use // UseOptional, UseRequired or UseProhibited
	Default     string
	HasDefault  bool
	Fixed       string
	HasFixed    bool
	Declaration *AttributeDecl
	Documentation []Documentation
}

Constants ​

GroupConstants
VersionV10, V11
VarietyVarietyAtomic, VarietyList, VarietyUnion
ContentKindContentEmpty, ContentSimple, ContentElementOnly, ContentMixed
CompositorCompositorSequence, CompositorChoice, CompositorAll
UseUseOptional, UseRequired, UseProhibited
OccurrenceUnbounded (-1)

Released under the Apache License 2.0.