Example #1
0
func (c *CommonAttributes) InitCommonAttributes() {
	c.Base = xmlutils.NewElement("base", "", IsValidIRI)
	c.Base.SetOccurence(xmlutils.NewOccurence("base", xmlutils.UniqueValidator(AttributeDuplicated)))

	c.Lang = xmlutils.NewElement("lang", "", xmlutils.Nop)
	c.Lang.SetOccurence(xmlutils.NewOccurence("lang", xmlutils.UniqueValidator(AttributeDuplicated)))

}
Example #2
0
File: item.go Project: apognu/xml
func (i *Item) init() {

	i.Title.Content = xmlutils.NewElement("title", "", xmlutils.Nop)
	i.Link.Content = xmlutils.NewElement("link", "", xmlutils.Nop)
	i.Author.Content = xmlutils.NewElement("author", "", xmlutils.Nop)
	i.Comments.Content = xmlutils.NewElement("comments", "", xmlutils.Nop)

	i.Title.Parent = i
	i.Link.Parent = i
	i.Description.Parent = i
	i.Author.Parent = i
	i.Comments.Parent = i
	i.Enclosure.Parent = i
	i.Guid.Parent = i
	i.PubDate.Parent = i
	i.Source.Parent = i

	i.Occurences = xmlutils.NewOccurenceCollection(
		xmlutils.NewOccurence("title", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("link", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("description", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("author", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("comments", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("enclosure", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("guid", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("pubdate", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("source", xmlutils.UniqueValidator(AttributeDuplicated)),
	)
}
Example #3
0
func NewOutOfLineContent() *OutOfLineContent {
	o := OutOfLineContent{depth: xmlutils.NewDepthWatcher()}

	o.Type = xmlutils.NewElement("type", "", outOfLineTypeIsValid)
	o.Type.SetOccurence(xmlutils.NewOccurence("type", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	o.Src = xmlutils.NewElement("src", "", IsValidIRI)
	o.Src.SetOccurence(xmlutils.NewOccurence("src", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	o.depth.SetMaxDepth(1)
	return &o
}
Example #4
0
File: entry.go Project: apognu/xml
func (e *Entry) init() {

	e.Content.Parent = e
	e.Id.Parent = e
	e.Published.Parent = e
	e.Rights.Parent = e
	e.Source.Parent = e
	e.Summary.Parent = e
	e.Title.Parent = e
	e.Updated.Parent = e

	e.InitCommonAttributes()

	e.Occurences = xmlutils.NewOccurenceCollection(
		xmlutils.NewOccurence("content", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("id", xmlutils.ExistsAndUniqueValidator(MissingId, IdDuplicated)),
		xmlutils.NewOccurence("published", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("rights", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("source", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("summary", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("title", xmlutils.ExistsAndUniqueValidator(MissingTitle, TitleDuplicated)),
		xmlutils.NewOccurence("updated", xmlutils.ExistsAndUniqueValidator(MissingDate, AttributeDuplicated)),
	)

}
Example #5
0
func NewEnclosure() *Enclosure {
	e := Enclosure{depth: xmlutils.NewDepthWatcher()}

	e.Url = xmlutils.NewElement("url", "", xmlutils.Nop)
	e.Url.SetOccurence(xmlutils.NewOccurence("url", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	e.Length = xmlutils.NewElement("length", "", xmlutils.Nop)
	e.Length.SetOccurence(xmlutils.NewOccurence("length", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	e.Type = xmlutils.NewElement("type", "", xmlutils.Nop)
	e.Type.SetOccurence(xmlutils.NewOccurence("type", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	return &e
}
Example #6
0
func (p *Person) init() {

	p.Name.Content = xmlutils.NewElement("name", "", xmlutils.Nop)
	p.Name.Content.SetOccurence(xmlutils.NewOccurence("name", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	p.Uri.Content = xmlutils.NewElement("uri", "", IsValidIRI)
	p.Uri.Content.SetOccurence(xmlutils.NewOccurence("uri", xmlutils.UniqueValidator(AttributeDuplicated)))

	p.Email.Content = xmlutils.NewElement("email", "", xmlutils.Nop)
	p.Email.Content.SetOccurence(xmlutils.NewOccurence("email", xmlutils.UniqueValidator(AttributeDuplicated)))

	p.InitCommonAttributes()

}
Example #7
0
File: feed.go Project: apognu/xml
func (f *Feed) init() {

	f.Generator.Parent = f
	f.Icon.Parent = f
	f.Id.Parent = f
	f.Logo.Parent = f
	f.Rights.Parent = f
	f.Subtitle.Parent = f
	f.Title.Parent = f
	f.Updated.Parent = f

	f.InitCommonAttributes()

	f.Occurences = xmlutils.NewOccurenceCollection(
		xmlutils.NewOccurence("generator", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("icon", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("logo", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("id", xmlutils.ExistsAndUniqueValidator(MissingId, IdDuplicated)),
		xmlutils.NewOccurence("rights", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("subtitle", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("title", xmlutils.ExistsAndUniqueValidator(MissingTitle, TitleDuplicated)),
		xmlutils.NewOccurence("updated", xmlutils.ExistsAndUniqueValidator(MissingDate, AttributeDuplicated)),
	)

}
Example #8
0
func NewGenerator() *Generator {
	g := Generator{depth: xmlutils.NewDepthWatcher()}

	g.Uri = xmlutils.NewElement("uri", "", IsValidIRI)
	g.Uri.SetOccurence(xmlutils.NewOccurence("uri", xmlutils.UniqueValidator(AttributeDuplicated)))

	g.Version = xmlutils.NewElement("version", "", xmlutils.Nop)
	g.Version.SetOccurence(xmlutils.NewOccurence("version", xmlutils.UniqueValidator(AttributeDuplicated)))

	g.InitCommonAttributes()

	g.depth.SetMaxDepth(1)
	return &g
}
Example #9
0
func NewCategory() *Category {
	c := Category{depth: xmlutils.NewDepthWatcher()}

	c.Term = xmlutils.NewElement("term", "", xmlutils.Nop)
	c.Term.SetOccurence(xmlutils.NewOccurence("term", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	c.Scheme = xmlutils.NewElement("scheme", "", IsValidIRI)
	c.Scheme.SetOccurence(xmlutils.NewOccurence("scheme", xmlutils.UniqueValidator(AttributeDuplicated)))

	c.Label = xmlutils.NewElement("label", "", xmlutils.Nop)
	c.Label.SetOccurence(xmlutils.NewOccurence("label", xmlutils.UniqueValidator(AttributeDuplicated)))

	c.InitCommonAttributes()

	return &c
}
Example #10
0
File: source.go Project: apognu/xml
func NewSource() *Source {
	s := Source{depth: xmlutils.NewDepthWatcher()}

	s.Url = xmlutils.NewElement("url", "", xmlutils.Nop)
	s.Url.SetOccurence(xmlutils.NewOccurence("url", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	return &s
}
Example #11
0
func NewCategory() *Category {
	c := Category{depth: xmlutils.NewDepthWatcher()}

	c.Domain = xmlutils.NewElement("domain", "", xmlutils.Nop)
	c.Domain.SetOccurence(xmlutils.NewOccurence("domain", xmlutils.UniqueValidator(AttributeDuplicated)))

	return &c
}
Example #12
0
func newInReplyTo() *InReplyTo {
	i := InReplyTo{depth: xmlutils.NewDepthWatcher()}

	i.Ref = xmlutils.NewElement("ref", "", atom.IsAbsoluteIRI)
	i.Ref.SetOccurence(xmlutils.NewOccurence("ref", xmlutils.ExistsAndUniqueValidator(atom.MissingAttribute, atom.AttributeDuplicated)))

	i.Href = xmlutils.NewElement("href", "", atom.IsValidIRI)
	i.Href.SetOccurence(xmlutils.NewOccurence("href", xmlutils.UniqueValidator(atom.AttributeDuplicated)))

	i.Type = xmlutils.NewElement("type", "", xmlutils.Nop)
	i.Type.SetOccurence(xmlutils.NewOccurence("type", xmlutils.UniqueValidator(atom.AttributeDuplicated)))

	i.Source = xmlutils.NewElement("source", "", atom.IsValidIRI)
	i.Source.SetOccurence(xmlutils.NewOccurence("source", xmlutils.UniqueValidator(atom.AttributeDuplicated)))

	return &i
}
Example #13
0
File: guid.go Project: apognu/xml
func NewGuid() *Guid {
	g := Guid{depth: xmlutils.NewDepthWatcher()}

	g.IsPermalink = xmlutils.NewElement("isPermalink", "true", xmlutils.Nop)
	g.IsPermalink.SetOccurence(xmlutils.NewOccurence("isPermalink", xmlutils.UniqueValidator(AttributeDuplicated)))

	return &g
}
Example #14
0
func NewInlineOtherContent() *InlineOtherContent {
	i := InlineOtherContent{hasChild: false}

	i.Type = xmlutils.NewElement("type", "", IsValidMIME)
	i.Type.SetOccurence(xmlutils.NewOccurence("type", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))
	i.Content = &bytes.Buffer{}

	i.Encoder = xml.NewEncoder(i.Content)
	return &i
}
Example #15
0
File: repo.go Project: apognu/xml
func (r *Repository) AddElement(name xml.Name, constructor ElementConstructor, occValidator xmlutils.OccurenceValidator) error {

	if index := r.findElement(name); index != -1 {
		return errors.New("an extension of this name already exists")
	}

	r.elements = append(r.elements, eElement{name: name, constructor: constructor})
	r.Occ.AddOccurence(xmlutils.NewOccurence(xmlNameToString(name), occValidator))

	return nil
}
Example #16
0
File: cloud.go Project: apognu/xml
func NewCloud() *Cloud {
	c := Cloud{depth: xmlutils.NewDepthWatcher()}

	c.Domain = xmlutils.NewElement("domain", "", xmlutils.Nop)
	c.Domain.SetOccurence(xmlutils.NewOccurence("domain", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	c.Port = xmlutils.NewElement("port", "", xmlutils.Nop)
	c.Port.SetOccurence(xmlutils.NewOccurence("port", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	c.Path = xmlutils.NewElement("path", "", xmlutils.Nop)
	c.Path.SetOccurence(xmlutils.NewOccurence("path", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	c.RegisterProcedure = xmlutils.NewElement("registerProcedure", "", xmlutils.Nop)
	c.RegisterProcedure.SetOccurence(xmlutils.NewOccurence("registerProcedure", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	c.Protocol = xmlutils.NewElement("protocol", "", xmlutils.Nop)
	c.Protocol.SetOccurence(xmlutils.NewOccurence("protocol", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	return &c
}
Example #17
0
File: repo.go Project: apognu/xml
func (r *Repository) AddAttr(name xml.Name, constructor AttrConstructor, attrDuplicatedFlag utils.Flag) error {

	if index := r.findAttr(name); index != -1 {
		return errors.New("an extension of this name already exists")
	}

	r.attrs = append(r.attrs, eAttr{name: name, constructor: constructor})
	r.Occ.AddOccurence(xmlutils.NewOccurence(xmlNameToString(name), xmlutils.UniqueValidator(attrDuplicatedFlag)))

	return nil
}
Example #18
0
File: link.go Project: apognu/xml
func NewLink() *Link {
	l := Link{depth: xmlutils.NewDepthWatcher()}

	l.Href = xmlutils.NewElement("href", "", IsValidIRI)
	l.Href.SetOccurence(xmlutils.NewOccurence("href", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	l.Rel = xmlutils.NewElement("rel", "alternate", xmlutils.Nop)
	l.Rel.SetOccurence(xmlutils.NewOccurence("rel", xmlutils.UniqueValidator(AttributeDuplicated)))

	l.Type = xmlutils.NewElement("type", "", IsValidMIME)
	l.Type.SetOccurence(xmlutils.NewOccurence("type", xmlutils.UniqueValidator(AttributeDuplicated)))

	l.HrefLang = xmlutils.NewElement("hreflang", "", xmlutils.Nop)
	l.HrefLang.SetOccurence(xmlutils.NewOccurence("hreflang", xmlutils.UniqueValidator(AttributeDuplicated)))

	l.Title = xmlutils.NewElement("title", "", xmlutils.Nop)
	l.Title.SetOccurence(xmlutils.NewOccurence("title", xmlutils.UniqueValidator(AttributeDuplicated)))

	l.Length = xmlutils.NewElement("length", "", IsValidLength)
	l.Length.SetOccurence(xmlutils.NewOccurence("length", xmlutils.UniqueValidator(AttributeDuplicated)))

	l.InitCommonAttributes()

	return &l
}
Example #19
0
File: image.go Project: apognu/xml
func (i *Image) init() {
	i.Url.Content = xmlutils.NewElement("url", "", xmlutils.Nop)
	i.Url.Content.SetOccurence(xmlutils.NewOccurence("url", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	i.Title.Content = xmlutils.NewElement("title", "", xmlutils.Nop)
	i.Title.Content.SetOccurence(xmlutils.NewOccurence("title", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	i.Link.Content = xmlutils.NewElement("link", "", xmlutils.Nop)
	i.Link.Content.SetOccurence(xmlutils.NewOccurence("link", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)))

	i.Width.Content = xmlutils.NewElement("width", "", xmlutils.Nop)
	i.Width.Content.SetOccurence(xmlutils.NewOccurence("width", xmlutils.UniqueValidator(AttributeDuplicated)))

	i.Height.Content = xmlutils.NewElement("height", "", xmlutils.Nop)
	i.Height.Content.SetOccurence(xmlutils.NewOccurence("height", xmlutils.UniqueValidator(AttributeDuplicated)))

	i.Description.Content = xmlutils.NewElement("description", "", xmlutils.Nop)
	i.Description.Content.SetOccurence(xmlutils.NewOccurence("description", xmlutils.UniqueValidator(AttributeDuplicated)))

	i.Url.Parent = i
	i.Title.Parent = i
	i.Link.Parent = i
	i.Width.Parent = i
	i.Height.Parent = i
	i.Description.Parent = i
}
Example #20
0
File: source.go Project: apognu/xml
func (s *Source) init() {

	s.Generator.Parent = s
	s.Icon.Parent = s
	s.Id.Parent = s
	s.Logo.Parent = s
	s.Rights.Parent = s
	s.Subtitle.Parent = s
	s.Title.Parent = s
	s.Updated.Parent = s

	s.Occurences = xmlutils.NewOccurenceCollection(
		xmlutils.NewOccurence("generator", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("icon", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("logo", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("id", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)),
		xmlutils.NewOccurence("rights", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("subtitle", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("title", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)),
		xmlutils.NewOccurence("updated", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)),
	)

	s.InitCommonAttributes()
}
Example #21
0
func (c *Channel) init() {

	c.Title.Content = xmlutils.NewElement("title", "", xmlutils.Nop)
	c.Link.Content = xmlutils.NewElement("link", "", IsValidIRI)
	c.Language.Content = xmlutils.NewElement("language", "", xmlutils.Nop)
	c.Copyright.Content = xmlutils.NewElement("copyright", "", xmlutils.Nop)
	c.ManagingEditor.Content = xmlutils.NewElement("managingeditor", "", xmlutils.Nop)
	c.Webmaster.Content = xmlutils.NewElement("webmaster", "", xmlutils.Nop)
	c.Generator.Content = xmlutils.NewElement("generator", "", xmlutils.Nop)
	c.Docs.Content = xmlutils.NewElement("docs", "", xmlutils.Nop)
	c.Ttl.Content = xmlutils.NewElement("ttl", "", xmlutils.Nop)
	c.Rating.Content = xmlutils.NewElement("rating", "", xmlutils.Nop)
	c.SkipHours.Content = xmlutils.NewElement("skiphours", "", xmlutils.Nop)
	c.SkipDays.Content = xmlutils.NewElement("skipdays", "", xmlutils.Nop)

	c.Title.Parent = c
	c.Link.Parent = c
	c.Description.Parent = c
	c.Language.Parent = c
	c.Copyright.Parent = c
	c.ManagingEditor.Parent = c
	c.Webmaster.Parent = c
	c.PubDate.Parent = c
	c.LastBuildDate.Parent = c
	c.Generator.Parent = c
	c.Docs.Parent = c
	c.Cloud.Parent = c
	c.Ttl.Parent = c
	c.Image.Parent = c
	c.Rating.Parent = c
	c.SkipHours.Parent = c
	c.SkipDays.Parent = c

	c.Occurences = xmlutils.NewOccurenceCollection(
		xmlutils.NewOccurence("title", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)),
		xmlutils.NewOccurence("link", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)),
		xmlutils.NewOccurence("description", xmlutils.ExistsAndUniqueValidator(MissingAttribute, AttributeDuplicated)),
		xmlutils.NewOccurence("language", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("copyright", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("managingeditor", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("webmaster", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("pubdate", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("lastbuilddate", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("generator", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("docs", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("cloud", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("ttl", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("image", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("rating", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("skiphours", xmlutils.UniqueValidator(AttributeDuplicated)),
		xmlutils.NewOccurence("skipdays", xmlutils.UniqueValidator(AttributeDuplicated)),
	)

}