Documentation ¶
Overview ¶
Package xsd contains some of the tools available from libxml2 that allows you to validate your XML against an XSD
This is basically all you need to do:
schema, err := xsd.Parse(xsdsrc) if err != nil { panic(err) } defer schema.Free() if err := schema.Validate(doc); err != nil{ for _, e := range err.(SchemaValidationErr).Error() { println(e.Error()) } }
Index ¶
Constants ¶
const ValueVCCreate = 1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
func WithPath ¶
WithPath provides a hint to the XSD parser as to where the document being parsed is located at.
This is useful when you must resolve relative paths inside a document, because to use relative paths the parser needs to know the reference location (i.e. location of the document being parsed). In case where you are parsing using `ParseFromFile()` this is handled automatically by the `ParseFromFile` method, but if you are using `Parse` method this is required
If the path is provided as a relative path, the current directory should be obtainable via `os.Getwd` when this call is made, otherwise path resolution may fail in weird ways.
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema represents an XML schema.
func ParseFromFile ¶
ParseFromFile is used to parse an XML schema using only the file path. Make sure to call Free() on the instance when you are done with it.
type SchemaValidationError ¶
type SchemaValidationError struct {
// contains filtered or unexported fields
}
SchemaValidationError is returned when the Validate() function finds errors. When there are multiple errors, you may access them using the Errors() method
func (SchemaValidationError) Error ¶
func (sve SchemaValidationError) Error() string
Error method fulfils the error interface
func (SchemaValidationError) Errors ¶
func (sve SchemaValidationError) Errors() []error
Errors returns the list of errors found