ml

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: MIT Imports: 6 Imported by: 12

Documentation

Index

Constants

View Source
const (
	//NamespaceXML is a XML namespace
	NamespaceXML = "http://www.w3.org/XML/1998/namespace"

	//NamespaceRelationships is a namespace for OOXML relationships
	NamespaceRelationships = "http://schemas.openxmlformats.org/officeDocument/2006/relationships"

	//NamespaceVML is general VML drawings namespace
	NamespaceVML = "urn:schemas-microsoft-com:vml"

	//NamespaceVMLOffice is general VML Office drawings namespace
	NamespaceVMLOffice = "urn:schemas-microsoft-com:office:office"

	//NamespaceVMLExcel is Excel related VML drawing namespace
	NamespaceVMLExcel = "urn:schemas-microsoft-com:office:excel"

	//NamespaceVMLWord is Word related VML drawing namespace
	NamespaceVMLWord = "urn:schemas-microsoft-com:office:word"

	//NamespaceVMLPowerPoint is PowerPoint related VML drawing namespace
	NamespaceVMLPowerPoint = "urn:schemas-microsoft-com:office:powerpoint"

	//NamespaceDrawing is general DrawingML namespace
	NamespaceDrawing = "http://schemas.openxmlformats.org/drawingml/2006/main"

	//NamespaceDrawingExcel is a namespace for Excel DrawingML definition
	NamespaceDrawingExcel = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"

	//NamespaceDrawingWord is a namespace for Word DrawingML definition
	NamespaceDrawingWord = "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"

	//NamespaceDrawingChart is a namespace for Chart DrawingML definition
	NamespaceDrawingChart = "http://schemas.openxmlformats.org/drawingml/2006/chart"
)

Variables

View Source
var AttrPreserveSpace = xml.Attr{
	Name:  xml.Name{Space: NamespaceXML, Local: "space"},
	Value: "preserve",
}

AttrPreserveSpace is common attr to preserve space

Functions

func ApplyNamespacePrefix

func ApplyNamespacePrefix(namespace string, name xml.Name) xml.Name

ApplyNamespacePrefix adds namespace prefix to Local name and drops Space name

func Namespaces

func Namespaces(namespaces ...string) []xml.Attr

Namespaces transform list of namespaces into list of related attributes

Types

type ContentType

type ContentType string

type ContentTypes

type ContentTypes struct {
	XMLName xml.Name `xml:"http://schemas.openxmlformats.org/package/2006/content-types Types"`

	Overrides []*TypeOverride `xml:"Override"`
	Defaults  []*TypeDefault  `xml:"Default"`
}

ContentTypes is a direct mapping of XSD type

type OptionalIndex

type OptionalIndex *int

OptionalIndex is custom type to allow encode/decode optional 0-based indexes, where 0 should not be omitted

type Property

type Property string

Property is common type of property for strings. E.g.: <propName val="abcdef"/>

func (*Property) MarshalXML

func (p *Property) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Property) UnmarshalXML

func (p *Property) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type PropertyBool

type PropertyBool bool

PropertyBool is special type of property for booleans. E.g.: <propName val="true"/>, <propName/>, <propName val="false"/>

func (*PropertyBool) MarshalXML

func (p *PropertyBool) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*PropertyBool) UnmarshalXML

func (p *PropertyBool) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type PropertyDouble

type PropertyDouble float64

PropertyDouble is special type of property for doubles. E.g.: <propName val="123.456"/>

func (*PropertyDouble) MarshalXML

func (p *PropertyDouble) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*PropertyDouble) UnmarshalXML

func (p *PropertyDouble) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type PropertyInt

type PropertyInt int

PropertyInt is special type of property for integers. E.g.: <propName val="123"/>

func (*PropertyInt) MarshalXML

func (p *PropertyInt) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*PropertyInt) UnmarshalXML

func (p *PropertyInt) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type RID

type RID string

RID is a helper type for marshaling references for relationship - r:id

func (RID) MarshalXMLAttr

func (r RID) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

type RIDName

type RIDName string

RIDName is a helper type for marshaling namespace for relationships

func (RIDName) MarshalXMLAttr

func (r RIDName) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

type Relation

type Relation struct {
	ID         string       `xml:"Id,attr"`
	Target     string       `xml:",attr"`
	Type       RelationType `xml:",attr"`
	TargetMode TargetMode   `xml:",attr,omitempty"`
}

Relation is a direct mapping of XSD type

type RelationType

type RelationType string

RelationType is a type to encode XSD type

type Relationships

type Relationships struct {
	XMLName       xml.Name   `xml:"http://schemas.openxmlformats.org/package/2006/relationships Relationships"`
	Relationships []Relation `xml:"Relationship"`
}

Relationships is a direct mapping of XSD type

func (*Relationships) BeforeMarshalXML

func (r *Relationships) BeforeMarshalXML() interface{}

BeforeMarshalXML mark Relationships as non valid in case if there is no any relations inside

type Reserved

type Reserved struct {
	XMLName  xml.Name
	InnerXML string `xml:",innerxml"`
	ReservedAttributes
}

Reserved is special type that catches all inner content AS IS to save original information - used to mark 'non implemented' elements

func (*Reserved) Hash

func (r *Reserved) Hash() index.Code

Hash builds hash code for all required values of Reserved to use as unique index

type ReservedAttributes

type ReservedAttributes struct {
	Attrs []xml.Attr `xml:",any,attr"`
}

ReservedAttributes is a special type that catches all not captured attributes AS IS to save original information

func (ReservedAttributes) ResolveNamespacePrefixes

func (r ReservedAttributes) ResolveNamespacePrefixes()

ResolveNamespacePrefixes transforms namespaces into namespaces prefixes

type ReservedElements

type ReservedElements struct {
	Nodes []Reserved `xml:",any"`
}

ReservedElements is a special type that catches all not captured nested elements AS IS to save original information

func (ReservedElements) ResolveNamespacePrefixes

func (r ReservedElements) ResolveNamespacePrefixes()

ResolveNamespacePrefixes tries to resolve namespace and apply prefix for it for all reserved elements

type TargetMode

type TargetMode byte

TargetMode is a type to encode XSD type

const (
	TargetModeInternal TargetMode = iota
	TargetModeExternal
)

func (*TargetMode) MarshalXMLAttr

func (r *TargetMode) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (*TargetMode) UnmarshalXMLAttr

func (r *TargetMode) UnmarshalXMLAttr(attr xml.Attr) error

type TriStateBlankFalse

type TriStateBlankFalse TriStateType

TriStateBlankFalse is subtype of TriStateType - during decoding process convert blank value to false value

func (TriStateBlankFalse) MarshalXML

func (t TriStateBlankFalse) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML marshal TriStateBlankFalse as element

func (TriStateBlankFalse) MarshalXMLAttr

func (t TriStateBlankFalse) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

MarshalXMLAttr marshal TriStateBlankFalse as attribute

func (*TriStateBlankFalse) UnmarshalXML

func (t *TriStateBlankFalse) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshal TriStateType as element

func (*TriStateBlankFalse) UnmarshalXMLAttr

func (t *TriStateBlankFalse) UnmarshalXMLAttr(attr xml.Attr) error

UnmarshalXMLAttr unmarshal TriStateType as attribute

type TriStateBlankTrue

type TriStateBlankTrue TriStateType

TriStateBlankTrue is subtype of TriStateType - during decoding process convert blank value to true value

func (TriStateBlankTrue) MarshalXML

func (t TriStateBlankTrue) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML marshal TriStateBlankTrue as element

func (TriStateBlankTrue) MarshalXMLAttr

func (t TriStateBlankTrue) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

MarshalXMLAttr marshal TriStateBlankTrue as attribute

func (*TriStateBlankTrue) UnmarshalXML

func (t *TriStateBlankTrue) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshal TriStateBlankTrue as element

func (*TriStateBlankTrue) UnmarshalXMLAttr

func (t *TriStateBlankTrue) UnmarshalXMLAttr(attr xml.Attr) error

UnmarshalXMLAttr unmarshal TriStateBlankTrue as attribute

type TriStateType

type TriStateType byte

TriStateType is helper type to encode optional booleans 'true', 'false', 'default' to make it possible to omit 'default' or encode 'false' value if required

const (
	TriStateBlank TriStateType = iota
	TriStateTrue
	TriStateFalse
)

List of all possible values for TriStateType

func TriState

func TriState(state interface{}) TriStateType

TriState is helper function that return TriState for boolean type

func (TriStateType) MarshalXML

func (t TriStateType) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML marshal TriStateType as element

func (TriStateType) MarshalXMLAttr

func (t TriStateType) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

MarshalXMLAttr marshal TriStateType as attribute

func (TriStateType) String

func (t TriStateType) String() string

String returns string presentation of TriStateType

func (*TriStateType) UnmarshalXML

func (t *TriStateType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML unmarshal TriStateType as element

func (*TriStateType) UnmarshalXMLAttr

func (t *TriStateType) UnmarshalXMLAttr(attr xml.Attr) error

UnmarshalXMLAttr unmarshal TriStateType as attribute

type TypeDefault

type TypeDefault struct {
	Extension   string      `xml:",attr"`
	ContentType ContentType `xml:",attr"`
}

TypeDefault is a direct mapping of XSD type

type TypeOverride

type TypeOverride struct {
	PartName    string      `xml:",attr"`
	ContentType ContentType `xml:",attr"`
}

TypeOverride is a direct mapping of XSD type

Jump to

Keyboard shortcuts

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