Documentation ¶
Index ¶
- Variables
- func CreateBaseIndexFile(outputDir string, allFiles []string) error
- func FlushSimpleType(st *SimpleType)
- func GetFileList(path string, mask string) (files []string, err error)
- func MakeFirstUpperCase(s string) string
- func PrepareOutputDir(path string) error
- func ToSnakeCase(input string) string
- type Attribute
- type AttributeGroup
- type Choice
- type CodeGenerator
- func (gen *CodeGenerator) GenGo() error
- func (gen *CodeGenerator) GenTypeScript() error
- func (gen *CodeGenerator) GoAttribute(v *Attribute)
- func (gen *CodeGenerator) GoAttributeGroup(v *AttributeGroup)
- func (gen *CodeGenerator) GoAttributeGroupValidation(v *AttributeGroup)
- func (gen *CodeGenerator) GoBaseFile(file string)
- func (gen *CodeGenerator) GoComplexType(v *ComplexType)
- func (gen *CodeGenerator) GoComplexTypeValidation(v *ComplexType)
- func (gen *CodeGenerator) GoElement(v *Element)
- func (gen *CodeGenerator) GoGroup(v *Group)
- func (gen *CodeGenerator) GoSimpleType(v *SimpleType)
- func (gen *CodeGenerator) GoSimpleTypeValidation(v *SimpleType)
- func (gen *CodeGenerator) TypeScriptAttribute(v *Attribute)
- func (gen *CodeGenerator) TypeScriptAttributeGroup(v *AttributeGroup)
- func (gen *CodeGenerator) TypeScriptComplexType(v *ComplexType)
- func (gen *CodeGenerator) TypeScriptElement(v *Element)
- func (gen *CodeGenerator) TypeScriptGroup(v *Group)
- func (gen *CodeGenerator) TypeScriptSimpleType(v *SimpleType)
- type ComplexType
- type Element
- type Group
- type Lang
- type Options
- func (opt *Options) EndAny(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndAnyAttribute(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndAttribute(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndAttributeGroup(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndChoice(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndComplexType(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndElement(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndEnumeration(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndExtension(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndFractionDigits(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndGroup(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndLength(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndMaxExclusive(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndMaxInclusive(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndMaxLength(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndMinExclusive(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndMinInclusive(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndMinLength(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndPattern(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndRestriction(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndSimpleType(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndTotalDigits(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndUnion(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) EndWhiteSpace(ele xml.EndElement, protoTree []interface{}) (err error)
- func (opt *Options) Gen() error
- func (opt *Options) GetValueType(value string, XSDSchema []interface{}) (valueType string, err error)
- func (opt *Options) OnAny(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnAnyAttribute(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnAttribute(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnAttributeGroup(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnCharData(ele string, protoTree []interface{}) (err error)
- func (opt *Options) OnChoice(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnComplexType(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnElement(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnEnumeration(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnExtension(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnGroup(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnImport(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnInclude(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnList(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnMaxLength(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnMinLength(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnPattern(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnRestriction(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnSchema(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnSimpleType(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) OnUnion(ele xml.StartElement, protoTree []interface{}) (err error)
- func (opt *Options) Parse() (err error)
- type Restriction
- type SimpleType
- type Stack
Constants ¶
This section is empty.
Variables ¶
var BaseTypeTmpl = strings.ReplaceAll(`package %s
import (
"encoding/json"
"encoding/xml"
"errors"
"fmt"
"github.com/google/uuid"
"strconv"
"strings"
)
// NodeID используется для маппинга элементов из бд и структуры
type NodeID struct {
NodeID *uuid.UUID \\xml:"-" json:"node_id,omitempty"\\
}
func (t *NodeID) Scan(el *Element) error {
if el.ID != uuid.Nil {
t.NodeID = &el.ID
}
return nil
}
func (t *NodeID) Read(el *Element) error {
if t.NodeID != nil {
el.ID = *t.NodeID
}
return nil
}
type UnsignedInt string
func (u *UnsignedInt) Validate() error {
_, err := strconv.ParseUint(string(*u), 10, 32)
return err
}
/* Additional fields */
var nameSpaceAliases = make(map[string]string)
type AdditionalFieldsType []AdditionalField
type AdditionalField struct {
xml.Attr
}
func (a *AdditionalField) UnmarshalXMLAttr(attr xml.Attr) error {
a.Attr = attr
if attr.Name.Local != "" && strings.Contains(attr.Value, "//") {
nameSpaceAliases[attr.Value] = attr.Name.Local
}
return nil
}
func (a *AdditionalField) MarshalXMLAttr(_ xml.Name) (xml.Attr, error) {
space := a.Name.Space
if strings.Contains(space, "//") {
space = nameSpaceAliases[space]
}
if space != "" {
space += ":"
}
return xml.Attr{
Name: xml.Name{
//Space: a.FieldName.Space,
Local: space + a.Name.Local,
},
Value: a.Value,
}, nil
}
type AdditionalFields struct {
AdditionalFields AdditionalFieldsType \\xml:",any,attr"\\
CustomElements []AnyHolder \\xml:",any"\\
}
type AnyHolder struct {
MModel
}
type MModel struct {
XMLName xml.Name
Attr []xml.Attr \\xml:",any,attr"\\
XML string \\xml:",innerxml"\\
}
func (a *AnyHolder) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var model MModel
err := d.DecodeElement(&model, &start)
a.MModel = model
return err
}
func (a *AnyHolder) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
space := a.MModel.XMLName.Space
if strings.Contains(space, "//") {
space = nameSpaceAliases[space]
}
if space != "" {
space += ":"
}
am := MModel{
XMLName: xml.Name{
Space: "",
Local: space + a.XMLName.Local,
},
Attr: a.Attr,
XML: a.XML,
}
return e.Encode(am)
}
var (
_ xml.Unmarshaler = (*AnyHolder)(nil)
_ xml.Marshaler = (*AnyHolder)(nil)
)
type Validator interface {
Validate() error
}
func CheckValidate(v interface{}) error {
if fn, ok := v.(Validator); ok {
return fn.Validate()
}
return nil
}
type UnionContent struct {
Content string \\xml:",chardata" json:",omitempty"\\
}
func (u UnionContent) MarshalJSON() ([]byte, error) {
return []byte("\"" + u.Content + "\""), nil
}
func (u *UnionContent) UnmarshalJSON(v []byte) error {
if len(v) > 0 {
u.Content = strings.Trim(string(v), "\"")
}
return nil
}
func (u UnionContent) String() string {
return u.Content
}
var (
_ json.Unmarshaler = (*UnionContent)(nil)
_ json.Marshaler = (*UnionContent)(nil)
_ fmt.Stringer = (*UnionContent)(nil)
)
// "ComplexType"
// UnitSlice - хак чтобы побороть []uint32
type UnitSlice struct {
NodeID
Content string \\xml:",chardata" json:",omitempty"\\
}
func (t *UnitSlice) CreateElement(xmlTag string, level, pos uint, parentEl *Element) (*Element, error) {
if xmlTag == "" {
return nil, errors.New("UnitSlice.CreateElement empty tag ")
}
el := NewElement(xmlTag, level, pos, parentEl)
if t.NodeID.NodeID != nil {
el.ID = *t.NodeID.NodeID
}
el.Content = t.Content
return el, nil
}
`, `\\`, "`")
var BuildInTypes = map[string][]string{
"anyType": {"string", "string", "char", "String", "String"},
"ENTITIES": {"[]string", "Array<string>", "char[]", "List<String>", "Vec<String>"},
"ENTITY": {"string", "string", "char", "String", "String"},
"ID": {"string", "string", "char", "String", "String"},
"IDREF": {"string", "string", "char", "String", "String"},
"IDREFS": {"[]string", "Array<string>", "char[]", "List<String>", "Vec<String>"},
"NCName": {"string", "string", "char", "String", "String"},
"NMTOKEN": {"string", "string", "char", "String", "String"},
"NMTOKENS": {"[]string", "Array<string>", "char[]", "List<String>", "Vec<String>"},
"NOTATION": {"[]string", "Array<string>", "char[]", "List<String>", "Vec<String>"},
"Name": {"string", "string", "char", "String", "String"},
"QName": {"xml.Name", "any", "char", "String", "String"},
"anyURI": {"string", "string", "char", "QName", "String"},
"base64Binary": {"[]byte", "Uint8Array", "char[]", "List<Byte>", "String"},
"boolean": {"bool", "boolean", "bool", "Boolean", "bool"},
"byte": {"byte", "any", "char[]", "Byte", "u8"},
"date": {"time.Time", "string", "char", "Byte", "u8"},
"dateTime": {"time.Time", "string", "char", "Byte", "u8"},
"decimal": {"float64", "number", "float", "Float", "f64"},
"double": {"float64", "number", "float", "Float", "f64"},
"duration": {"string", "string", "char", "String", "String"},
"float": {"float", "number", "float", "Float", "f64"},
"gDay": {"time.Time", "string", "char", "String", "String"},
"gMonth": {"time.Time", "string", "char", "String", "String"},
"gMonthDay": {"time.Time", "string", "char", "String", "String"},
"gYear": {"time.Time", "string", "char", "String", "String"},
"gYearMonth": {"time.Time", "string", "char", "String", "String"},
"hexBinary": {"[]byte", "Uint8Array", "char[]", "List<Byte>", "String"},
"int": {"int", "number", "int", "Integer", "i32"},
"integer": {"int", "number", "int", "Integer", "i32"},
"language": {"string", "string", "char", "String", "String"},
"long": {"int64", "number", "int", "Long", "i64"},
"negativeInteger": {"int", "number", "int", "Integer", "i32"},
"nonNegativeInteger": {"int", "number", "int", "Integer", "u32"},
"normalizedString": {"string", "string", "char", "String", "String"},
"nonPositiveInteger": {"int", "number", "int", "Integer", "i32"},
"positiveInteger": {"int", "number", "int", "Integer", "u32"},
"short": {"int16", "number", "int", "Integer", "i16"},
"string": {"string", "string", "char", "String", "String"},
"time": {"time.Time", "string", "char", "String", "String"},
"token": {"string", "string", "char", "String", "String"},
"unsignedByte": {"byte", "any", "char", "Byte", "u8"},
"unsignedInt": {"uint32", "number", "unsigned int", "Integer", "u32"},
"unsignedLong": {"uint64", "number", "unsigned int", "Long", "u64"},
"unsignedShort": {"uint16", "number", "unsigned int", "Short", "u16"},
"xml:lang": {"string", "string", "char", "String", "String"},
"xml:space": {"string", "string", "char", "String", "String"},
"xml:base": {"string", "string", "char", "String", "String"},
"xml:id": {"string", "string", "char", "String", "String"},
}
BuildInTypes defines the correspondence between Go, TypeScript, C, Java, Rust languages and data types in XSD. https://www.w3.org/TR/xmlschema-2/#datatype
Functions ¶
func CreateBaseIndexFile ¶ added in v1.0.3
func FlushSimpleType ¶ added in v1.0.0
func FlushSimpleType(st *SimpleType)
func GetFileList ¶
GetFileList get a list of file by given path.
func MakeFirstUpperCase ¶
MakeFirstUpperCase make the first letter of a string uppercase.
func PrepareOutputDir ¶
PrepareOutputDir provide a method to create the output directory by given path.
func ToSnakeCase ¶
ToSnakeCase converts the provided string to snake_case.
Types ¶
type Attribute ¶
type Attribute struct { Name string Doc string Type string Plural bool Default *string Optional bool // {value constraint} //Optional. A pair consisting of a value and one of default, fixed. Fixed string // todo: Implement for validation SimpleTypeInside *SimpleType }
Attribute declarations provide for: Local validation of attribute information item values using a simple type definition; Specifying default or fixed values for attribute information items. https://www.w3.org/TR/xmlschema-1/structures.html#element-attribute
type AttributeGroup ¶
type AttributeGroup struct { Doc string Name string Ref string Attributes []*Attribute AttributeGroup []*AttributeGroup // contains filtered or unexported fields }
AttributeGroup definitions do not participate in ·validation· as such, but the {attribute uses} and {attribute wildcard} of one or more complex type definitions may be constructed in whole or part by reference to an attribute group. Thus, attribute group definitions provide a replacement for some uses of XML's parameter entity facility. Attribute group definitions are provided primarily for reference from the XML representation of schema components (see <complexType> and <attributeGroup>). https://www.w3.org/TR/xmlschema-1/structures.html#Attribute_Group_Definition
type CodeGenerator ¶
type CodeGenerator struct { Lang string OutputDir string File string Field string Package string Imports map[string]struct{} ProtoTree []interface{} StructAST map[string]string StructFieldName map[string]struct{} JsonTag bool Validator bool // если задан то генерируем файл с базовыми типами BaseTypeFile bool // contains filtered or unexported fields }
CodeGenerator holds code generator overrides and runtime data that are used when generate code from proto tree.
func (*CodeGenerator) GenGo ¶
func (gen *CodeGenerator) GenGo() error
GenGo generate Go programming language source code for XML schema definition files.
func (*CodeGenerator) GenTypeScript ¶
func (gen *CodeGenerator) GenTypeScript() error
GenTypeScript generate TypeScript programming language source code for XML schema definition files.
func (*CodeGenerator) GoAttribute ¶
func (gen *CodeGenerator) GoAttribute(v *Attribute)
GoAttribute generates code for attribute XML schema in Go language syntax.
func (*CodeGenerator) GoAttributeGroup ¶
func (gen *CodeGenerator) GoAttributeGroup(v *AttributeGroup)
GoAttributeGroup generates code for attribute group XML schema in Go language syntax.
func (*CodeGenerator) GoAttributeGroupValidation ¶ added in v1.0.0
func (gen *CodeGenerator) GoAttributeGroupValidation(v *AttributeGroup)
GoAttributeGroupValidation ...
func (*CodeGenerator) GoBaseFile ¶
func (gen *CodeGenerator) GoBaseFile(file string)
func (*CodeGenerator) GoComplexType ¶
func (gen *CodeGenerator) GoComplexType(v *ComplexType)
GoComplexType generates code for complex type XML schema in Go language syntax.
func (*CodeGenerator) GoComplexTypeValidation ¶ added in v1.0.0
func (gen *CodeGenerator) GoComplexTypeValidation(v *ComplexType)
validate for ComplexType
func (*CodeGenerator) GoElement ¶
func (gen *CodeGenerator) GoElement(v *Element)
GoElement generates code for element XML schema in Go language syntax.
func (*CodeGenerator) GoGroup ¶
func (gen *CodeGenerator) GoGroup(v *Group)
GoGroup generates code for group XML schema in Go language syntax.
func (*CodeGenerator) GoSimpleType ¶
func (gen *CodeGenerator) GoSimpleType(v *SimpleType)
GoSimpleType generates code for simple type XML schema in Go language syntax.
func (*CodeGenerator) GoSimpleTypeValidation ¶ added in v1.0.0
func (gen *CodeGenerator) GoSimpleTypeValidation(v *SimpleType)
func (*CodeGenerator) TypeScriptAttribute ¶
func (gen *CodeGenerator) TypeScriptAttribute(v *Attribute)
TypeScriptAttribute generates code for attribute XML schema in TypeScript language syntax.
func (*CodeGenerator) TypeScriptAttributeGroup ¶
func (gen *CodeGenerator) TypeScriptAttributeGroup(v *AttributeGroup)
TypeScriptAttributeGroup generates code for attribute group XML schema in TypeScript language syntax.
func (*CodeGenerator) TypeScriptComplexType ¶
func (gen *CodeGenerator) TypeScriptComplexType(v *ComplexType)
TypeScriptComplexType generates code for complex type XML schema in TypeScript language syntax.
func (*CodeGenerator) TypeScriptElement ¶
func (gen *CodeGenerator) TypeScriptElement(v *Element)
TypeScriptElement generates code for element XML schema in TypeScript language syntax.
func (*CodeGenerator) TypeScriptGroup ¶
func (gen *CodeGenerator) TypeScriptGroup(v *Group)
TypeScriptGroup generates code for group XML schema in TypeScript language syntax.
func (*CodeGenerator) TypeScriptSimpleType ¶
func (gen *CodeGenerator) TypeScriptSimpleType(v *SimpleType)
TypeScriptSimpleType generates code for simple type XML schema in TypeScript language syntax.
type ComplexType ¶
type ComplexType struct { Doc string Name string Base string Anonymous bool Elements []*Element Attributes []*Attribute Groups []*Group AttributeGroup []*AttributeGroup Mixed bool EmbeddedStructName string AnyElements bool AnyAttributes bool }
ComplexType definitions are identified by their {name} and {target namespace}. Except for anonymous complex type definitions (those with no {name}), since type definitions (i.e. both simple and complex type definitions taken together) must be uniquely identified within an ·XML Schema·, no complex type definition can have the same name as another simple or complex type definition. Complex type {name}s and {target namespace}s are provided for reference from instances, and for use in the XML representation of schema components (specifically in <element>). See References to schema components across namespaces for the use of component identifiers when importing one schema into another. https://www.w3.org/TR/xmlschema-1/structures.html#element-complexType
type Element ¶
type Element struct { Doc string Name string Wildcard bool Type string Abstract bool Plural bool PluralOptional bool Optional bool Nillable bool Default string }
Element declarations provide for: Local validation of element information item values using a type definition; Specifying default or fixed values for an element information items; Establishing uniquenesses and reference constraint relationships among the values of related elements and attributes; Controlling the substitutability of elements through the mechanism of element substitution groups. https://www.w3.org/TR/xmlschema-1/#cElement_Declarations
type Group ¶
type Group struct { Doc string Name string Elements []*Element Groups []*Group Plural bool Ref string }
Group (model group) definitions are provided primarily for reference from the XML Representation of Complex Type Definitions. Thus, model group definitions provide a replacement for some uses of XML's parameter entity facility. https://www.w3.org/TR/xmlschema-1/structures.html#cModel_Group_Definitions
type Options ¶
type Options struct { FilePath string FileDir string InputDir string OutputDir string Extract bool Lang Lang Package string IncludeMap map[string]bool LocalNameNSMap map[string]string NSSchemaLocationMap map[string]string ParseFileList map[string]bool ParseFileMap map[string][]interface{} ProtoTree []interface{} RemoteSchema map[string][]byte InElement string CurrentEle string InGroup int InUnion bool InAttributeGroup bool SimpleType *Stack ComplexType *Stack Element *Stack Attribute *Stack Group *Stack AttributeGroup *Stack CodeGenerator *CodeGenerator Log logrus.Ext1FieldLogger // for elements inside <xs:choice >... </xs:choice> OutChoice *Choice TypeScriptOptions struct { // add "declare" to all classes //DeclareClass bool BaseIndexFileImport string } }
Options holds user-defined overrides and runtime data that are used when parsing from an XSD document.
func NewOptions ¶
func NewParser ¶
NewParser creates a new parser options for the Parse. Useful for XML schema parsing.
func (*Options) EndAny ¶
func (opt *Options) EndAny(ele xml.EndElement, protoTree []interface{}) (err error)
func (*Options) EndAnyAttribute ¶
func (opt *Options) EndAnyAttribute(ele xml.EndElement, protoTree []interface{}) (err error)
func (*Options) EndAttribute ¶
func (opt *Options) EndAttribute(ele xml.EndElement, protoTree []interface{}) (err error)
EndAttribute handles parsing event on the attribute end elements.
func (*Options) EndAttributeGroup ¶
func (opt *Options) EndAttributeGroup(ele xml.EndElement, protoTree []interface{}) (err error)
EndAttributeGroup handles parsing event on the attributeGroup end elements.
func (*Options) EndChoice ¶ added in v1.0.0
func (opt *Options) EndChoice(ele xml.EndElement, protoTree []interface{}) (err error)
EndRestriction handles parsing event on the restriction end elements.
func (*Options) EndComplexType ¶
func (opt *Options) EndComplexType(ele xml.EndElement, protoTree []interface{}) (err error)
EndComplexType handles parsing event on the complex end elements.
func (*Options) EndElement ¶
func (opt *Options) EndElement(ele xml.EndElement, protoTree []interface{}) (err error)
EndElement handles parsing event on the element end elements.
func (*Options) EndEnumeration ¶
func (opt *Options) EndEnumeration(ele xml.EndElement, protoTree []interface{}) (err error)
EndEnumeration handles parsing event on the enumeration end elements. Enumeration defines a list of acceptable values.
func (*Options) EndExtension ¶
func (opt *Options) EndExtension(ele xml.EndElement, protoTree []interface{}) (err error)
func (*Options) EndFractionDigits ¶
func (opt *Options) EndFractionDigits(ele xml.EndElement, protoTree []interface{}) (err error)
EndFractionDigits handles parsing event on the fractionDigits end elements. Enumeration Defines a list of acceptable values. FractionDigits specifies the maximum number of decimal places allowed. Must be equal to or greater than zero.
func (*Options) EndGroup ¶
func (opt *Options) EndGroup(ele xml.EndElement, protoTree []interface{}) (err error)
EndGroup handles parsing event on the group end elements.
func (*Options) EndLength ¶
func (opt *Options) EndLength(ele xml.EndElement, protoTree []interface{}) (err error)
EndLength handles parsing event on the length end elements. Length specifies the exact number of characters or list items allowed. Must be equal to or greater than zero.
func (*Options) EndMaxExclusive ¶
func (opt *Options) EndMaxExclusive(ele xml.EndElement, protoTree []interface{}) (err error)
EndMaxExclusive handles parsing event on the maxExclusive end elements. MaxExclusive specifies the upper bounds for numeric values (the value must be less than this value).
func (*Options) EndMaxInclusive ¶
func (opt *Options) EndMaxInclusive(ele xml.EndElement, protoTree []interface{}) (err error)
EndMaxInclusive handles parsing event on the maxInclusive end elements. MaxInclusive specifies the upper bounds for numeric values (the value must be less than or equal to this value).
func (*Options) EndMaxLength ¶
func (opt *Options) EndMaxLength(ele xml.EndElement, protoTree []interface{}) (err error)
EndMaxLength handles parsing event on the maxLength end elements. MaxLength specifies the maximum number of characters or list items allowed. Must be equal to or greater than zero.
func (*Options) EndMinExclusive ¶
func (opt *Options) EndMinExclusive(ele xml.EndElement, protoTree []interface{}) (err error)
EndMinExclusive handles parsing event on the minExclusive end elements. MinExclusive specifies the lower bounds for numeric values (the value must be greater than this value).
func (*Options) EndMinInclusive ¶
func (opt *Options) EndMinInclusive(ele xml.EndElement, protoTree []interface{}) (err error)
EndMinInclusive handles parsing event on the minInclusive end elements. MinInclusive specifies the lower bounds for numeric values (the value must be greater than or equal to this value).
func (*Options) EndMinLength ¶
func (opt *Options) EndMinLength(ele xml.EndElement, protoTree []interface{}) (err error)
EndMinLength handles parsing event on the minLength end elements. MinLength specifies the minimum number of characters or list items allowed. Must be equal to or greater than zero.
func (*Options) EndPattern ¶
func (opt *Options) EndPattern(ele xml.EndElement, protoTree []interface{}) (err error)
EndPattern handles parsing event on the pattern end elements. Pattern defines the exact sequence of characters that are acceptable.
func (*Options) EndRestriction ¶
func (opt *Options) EndRestriction(ele xml.EndElement, protoTree []interface{}) (err error)
EndRestriction handles parsing event on the restriction end elements.
func (*Options) EndSimpleType ¶
func (opt *Options) EndSimpleType(ele xml.EndElement, protoTree []interface{}) (err error)
EndSimpleType handles parsing event on the simpleType end elements.
func (*Options) EndTotalDigits ¶
func (opt *Options) EndTotalDigits(ele xml.EndElement, protoTree []interface{}) (err error)
EndTotalDigits handles parsing event on the totalDigits end elements. TotalDigits specifies the exact number of digits allowed. Must be greater than zero.
func (*Options) EndUnion ¶
func (opt *Options) EndUnion(ele xml.EndElement, protoTree []interface{}) (err error)
EndUnion handles parsing event on the union end elements.
func (*Options) EndWhiteSpace ¶
func (opt *Options) EndWhiteSpace(ele xml.EndElement, protoTree []interface{}) (err error)
EndWhiteSpace handles parsing event on the whiteSpace end elements. WhiteSpace specifies how white space (line feeds, tabs, spaces, and carriage returns) is handled.
func (*Options) GetValueType ¶
func (opt *Options) GetValueType(value string, XSDSchema []interface{}) (valueType string, err error)
GetValueType convert XSD schema value type to the build-in type for the given value and proto tree.
func (*Options) OnAny ¶
func (opt *Options) OnAny(ele xml.StartElement, protoTree []interface{}) (err error)
func (*Options) OnAnyAttribute ¶
func (opt *Options) OnAnyAttribute(ele xml.StartElement, protoTree []interface{}) (err error)
Attributes
func (*Options) OnAttribute ¶
func (opt *Options) OnAttribute(ele xml.StartElement, protoTree []interface{}) (err error)
OnAttribute handles parsing event on the attribute start elements. All attributes are declared as simple types.
func (*Options) OnAttributeGroup ¶
func (opt *Options) OnAttributeGroup(ele xml.StartElement, protoTree []interface{}) (err error)
OnAttributeGroup handles parsing event on the attributeGroup start elements. The attributeGroup element is used to group a set of attribute declarations so that they can be incorporated as a group into complex type definitions.
func (*Options) OnCharData ¶
OnCharData handles parsing event on the documentation start elements. The documentation element specifies information to be read or used by users within an annotation element.
func (*Options) OnChoice ¶ added in v1.0.0
func (opt *Options) OnChoice(ele xml.StartElement, protoTree []interface{}) (err error)
OnRestriction handles parsing event on the restriction start elements. The restriction element defines restrictions on a simpleType, simpleContent, or complexContent definition.
func (*Options) OnComplexType ¶
func (opt *Options) OnComplexType(ele xml.StartElement, protoTree []interface{}) (err error)
OnComplexType handles parsing event on the complex start elements. A complex element contains other elements and/or attributes.
func (*Options) OnElement ¶
func (opt *Options) OnElement(ele xml.StartElement, protoTree []interface{}) (err error)
OnElement handles parsing event on the element start elements.
func (*Options) OnEnumeration ¶
func (opt *Options) OnEnumeration(ele xml.StartElement, protoTree []interface{}) (err error)
OnEnumeration handles parsing event on the enumeration start elements.
func (*Options) OnExtension ¶
func (opt *Options) OnExtension(ele xml.StartElement, protoTree []interface{}) (err error)
func (*Options) OnGroup ¶
func (opt *Options) OnGroup(ele xml.StartElement, protoTree []interface{}) (err error)
OnGroup handles parsing event on the group start elements. The group element is used to define a group of elements to be used in complex type definitions.
func (*Options) OnImport ¶
func (opt *Options) OnImport(ele xml.StartElement, protoTree []interface{}) (err error)
OnImport handles parsing event on the import start elements. The list element defines a simple type element as a list of values of a specified data type.
func (*Options) OnInclude ¶
func (opt *Options) OnInclude(ele xml.StartElement, protoTree []interface{}) (err error)
OnInclude handles parsing event on the include start elements. The list element defines a simple type element as a list of values of a specified data type.
func (*Options) OnList ¶
func (opt *Options) OnList(ele xml.StartElement, protoTree []interface{}) (err error)
OnList handles parsing event on the list start elements. The list element defines a simple type element as a list of values of a specified data type.
func (*Options) OnMaxLength ¶ added in v1.0.0
func (opt *Options) OnMaxLength(ele xml.StartElement, protoTree []interface{}) (err error)
func (*Options) OnMinLength ¶
func (opt *Options) OnMinLength(ele xml.StartElement, protoTree []interface{}) (err error)
func (*Options) OnPattern ¶ added in v1.0.0
func (opt *Options) OnPattern(ele xml.StartElement, protoTree []interface{}) (err error)
func (*Options) OnRestriction ¶
func (opt *Options) OnRestriction(ele xml.StartElement, protoTree []interface{}) (err error)
OnRestriction handles parsing event on the restriction start elements. The restriction element defines restrictions on a simpleType, simpleContent, or complexContent definition.
func (*Options) OnSchema ¶
func (opt *Options) OnSchema(ele xml.StartElement, protoTree []interface{}) (err error)
OnSchema handles parsing event on the schema start elements. Schema is the root element of every XML Schema.
func (*Options) OnSimpleType ¶
func (opt *Options) OnSimpleType(ele xml.StartElement, protoTree []interface{}) (err error)
OnSimpleType handles parsing event on the simpleType start elements. The simpleType element defines a simple type and specifies the constraints and information about the values of attributes or text-only elements.
type Restriction ¶
type Restriction struct { Doc string Precision int Enum []string Min, Max float64 MinLength, MaxLength int Pattern []string }
Restriction are used to define acceptable values for XML elements or attributes. Restriction on XML elements are called facets. https://www.w3.org/TR/xmlschema-1/structures.html#element-restriction
type SimpleType ¶
type SimpleType struct { Doc string Name string Base string // то что записано в схеме OrigBase string Anonymous bool List bool Union bool MemberTypes map[string]string Restriction Restriction OrigName string }
SimpleTypeInside definitions provide for constraining character information item [children] of element and attribute information items. https://www.w3.org/TR/xmlschema-1/#Simple_Type_Definitions
func FindSimpleType ¶ added in v1.0.0
func FindSimpleType(name string) (*SimpleType, bool)
Source Files ¶
- cache.go
- config.go
- genGo.go
- genGoValidator.go
- genTypeScript.go
- parser.go
- proto.go
- schema.go
- stack.go
- templates.go
- utils.go
- xmlAny.go
- xmlAttribute.go
- xmlAttributeGroup.go
- xmlCharData.go
- xmlChoice.go
- xmlComplexType.go
- xmlElement.go
- xmlEnumeration.go
- xmlExtension.go
- xmlFractionDigits.go
- xmlGroup.go
- xmlImport.go
- xmlInclude.go
- xmlLength.go
- xmlList.go
- xmlMaxExclusive.go
- xmlMaxInclusive.go
- xmlMaxLength.go
- xmlMinExclusive.go
- xmlMinInclusive.go
- xmlMinLength.go
- xmlPattern.go
- xmlRestriction.go
- xmlSchema.go
- xmlSimpleType.go
- xmlTotalDigits.go
- xmlUnion.go
- xmlWhiteSpace.go