xsd

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2019 License: MIT Imports: 3 Imported by: 0

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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Schema

type Schema struct {
	// contains filtered or unexported fields
}

Schema represents an XML schema.

func Parse

func Parse(buf []byte) (*Schema, error)

Parse is used to parse an XML Schema Document to produce a Schema instance. Make sure to call Free() on the instance when you are done with it.

func ParseFromFile

func ParseFromFile(path string) (*Schema, error)

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.

func (*Schema) Free

func (s *Schema) Free()

Free frees the underlying C struct

func (*Schema) Pointer

func (s *Schema) Pointer() uintptr

Pointer returns the underlying C struct

func (*Schema) Validate

func (s *Schema) Validate(d types.Document) error

Validate takes in a XML document and validates it against the schema. If there are any problems, and error is returned.

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL