示例#1
0
func (t *TextConstruct) Validate() xmlutils.ParserError {
	err := utils.NewErrorAggregator()

	t.ValidateCommonAttributes(t.name, &err)

	return err.ErrorObject()
}
示例#2
0
文件: date.go 项目: apognu/xml
func (d *Date) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	d.Extension.Validate(&error)

	return error.ErrorObject()
}
示例#3
0
func (o *OutOfLineContent) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	xmlutils.ValidateElements("out of line", &error, o.Type, o.Src)

	return error.ErrorObject()
}
示例#4
0
文件: unescaped.go 项目: apognu/xml
func (u *UnescapedContent) Validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	u.Extension.Validate(&error)

	return error.ErrorObject()
}
示例#5
0
文件: inreplyto.go 项目: apognu/xml
func (i *InReplyTo) Validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	xmlutils.ValidateElements("in-reply-to", &error, i.Ref, i.Href, i.Source, i.Type)

	return error.ErrorObject()
}
示例#6
0
func (i *InlineOtherContent) ProcessStartElement(el xmlutils.StartElement) (xmlutils.Visitor, xmlutils.ParserError) {
	err := utils.NewErrorAggregator()

	if i.depth.IsRoot() {
		for _, attr := range el.Attr {
			switch attr.Name.Local {
			case "type":
				i.Type.Value = attr.Value
				i.Type.IncOccurence()

			}
		}

	} else {
		if error := i.Encoder.EncodeToken(el); error != nil {
			err.NewError(xmlutils.NewError(XHTMLEncodeToStringError, "cannot encode XHTML"))
		}
		if i.depth.Level > 0 {
			i.hasChild = true
		}
	}

	i.depth.Down()

	return i, nil
}
示例#7
0
文件: source.go 项目: apognu/xml
func (s *Source) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	xmlutils.ValidateElements("source", &error, s.Url)
	s.Extension.Validate(&error)

	return error.ErrorObject()
}
示例#8
0
文件: enclosure.go 项目: apognu/xml
func (e *Enclosure) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	xmlutils.ValidateElements("enclosure", &error, e.Url, e.Length, e.Type)
	e.Extension.Validate(&error)

	return error.ErrorObject()
}
示例#9
0
文件: channel.go 项目: apognu/xml
func (c *Channel) validate() xmlutils.ParserError {
	err := utils.NewErrorAggregator()

	xmlutils.ValidateOccurenceCollection("channel", &err, c.Occurences)
	c.Extension.Validate(&err)

	return err.ErrorObject()
}
示例#10
0
func (d *Date) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	d.Extension.Validate(&error)
	d.ValidateCommonAttributes("date", &error)

	return error.ErrorObject()
}
示例#11
0
文件: category.go 项目: apognu/xml
func (c *Category) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	xmlutils.ValidateElements("category", &error, c.Domain)
	c.Extension.Validate(&error)

	return error.ErrorObject()
}
示例#12
0
文件: content.go 项目: apognu/xml
func (c *Content) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	c.Extension.Validate(&error)
	c.ValidateCommonAttributes("content", &error)

	return error.ErrorObject()
}
示例#13
0
文件: image.go 项目: apognu/xml
func (i *Image) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	xmlutils.ValidateElements("image", &error, i.Url.Content, i.Title.Content, i.Link.Content, i.Width.Content, i.Height.Content, i.Description.Content)
	i.Extension.Validate(&error)

	return error.ErrorObject()
}
示例#14
0
文件: cloud.go 项目: apognu/xml
func (c *Cloud) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	xmlutils.ValidateElements("cloud", &error, c.Domain, c.Port, c.Path, c.RegisterProcedure, c.Protocol)
	c.Extension.Validate(&error)

	return error.ErrorObject()
}
示例#15
0
文件: guid.go 项目: apognu/xml
func (g *Guid) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	xmlutils.ValidateElements("guid", &error, g.IsPermalink)
	g.Extension.Validate(&error)

	return error.ErrorObject()
}
示例#16
0
文件: logo.go 项目: apognu/xml
func (l *Logo) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	xmlutils.ValidateElement("logo", l.Iri, &error)
	l.ValidateCommonAttributes("logo", &error)
	l.Extension.Validate(&error)

	return error.ErrorObject()
}
示例#17
0
文件: link.go 项目: apognu/xml
func (l *Link) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	xmlutils.ValidateElements("link", &error, l.Href, l.Rel, l.Type, l.HrefLang, l.Title, l.Length)
	l.Extension.Validate(&error)
	l.ValidateCommonAttributes("link", &error)

	return error.ErrorObject()
}
示例#18
0
文件: icon.go 项目: apognu/xml
func (i *Icon) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	xmlutils.ValidateElement("icon", i.Iri, &error)
	i.Extension.Validate(&error)
	i.ValidateCommonAttributes("icon", &error)

	return error.ErrorObject()
}
示例#19
0
文件: generator.go 项目: apognu/xml
func (g *Generator) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	xmlutils.ValidateElements("generator", &error, g.Uri, g.Version)
	g.Extension.Validate(&error)
	g.ValidateCommonAttributes("generator", &error)

	return error.ErrorObject()
}
示例#20
0
文件: category.go 项目: apognu/xml
func (c *Category) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	xmlutils.ValidateElements("category", &error, c.Term, c.Label, c.Scheme)
	c.ValidateCommonAttributes("category", &error)

	c.Extension.Validate(&error)

	return error.ErrorObject()
}
示例#21
0
文件: source.go 项目: apognu/xml
func (s *Source) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	xmlutils.ValidateOccurenceCollection("source", &error, s.Occurences)
	s.Extension.Validate(&error)
	s.validateLinks(&error)
	s.ValidateCommonAttributes("source", &error)

	return error.ErrorObject()
}
示例#22
0
func (p *Person) validate() xmlutils.ParserError {

	error := utils.NewErrorAggregator()

	xmlutils.ValidateOccurences(p.name, &error, p.Name.Content.Occurence, p.Uri.Content.Occurence, p.Email.Content.Occurence)
	p.ValidateCommonAttributes(p.name, &error)
	p.Extension.Validate(&error)

	return error.ErrorObject()

}
示例#23
0
func (b *BasicElement) Validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	b.Extension.Validate(&error)

	if err := b.Content.Validate(); err != nil {
		error.NewError(xmlutils.NewError(err.Flag(), fmt.Sprintf("%s's %s", b.name.Local, err.Msg())))
	}

	return error.ErrorObject()
}
示例#24
0
func (i *InlineOtherContent) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	xmlutils.ValidateElements("inlineothercontent", &error, i.Type)

	if strings.HasPrefix(i.Type.Value, "text/") && i.hasChild {
		error.NewError(xmlutils.NewError(LeafElementHasChild, "text content should not have child"))
	}

	return error.ErrorObject()
}
示例#25
0
文件: item.go 项目: apognu/xml
func (i *Item) validate() xmlutils.ParserError {
	err := utils.NewErrorAggregator()

	xmlutils.ValidateOccurenceCollection("item", &err, i.Occurences)
	i.Extension.Validate(&err)

	if i.Occurences.Count("description") == 0 && i.Occurences.Count("title") == 0 {
		err.NewError(xmlutils.NewError(MissingAttribute, "item should have at least a title or a description"))
	}

	return err.ErrorObject()
}
示例#26
0
文件: feed.go 项目: apognu/xml
func (f *Feed) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	xmlutils.ValidateOccurenceCollection("feed", &error, f.Occurences)
	f.Extension.Validate(&error)

	f.validateLinks(&error)
	f.validateAuthors(&error)
	f.validateEntries(&error)
	f.ValidateCommonAttributes("feed", &error)

	return error.ErrorObject()
}
示例#27
0
文件: link.go 项目: apognu/xml
func (u *Updated) Validate() xmlutils.ParserError {
	errAgg := utils.NewErrorAggregator()
	link, ok := u.Parent.(*atom.Link)
	if !ok {
		errAgg.NewError(xmlutils.NewError(NotInLinkElement, "updated attr should be placed in link element"))

	} else {
		if link.Rel.String() != "replies" {
			errAgg.NewError(xmlutils.NewError(LinkNotReplies, "link element should avec a 'replies' rel for this extension"))
		}
	}

	return errAgg.ErrorObject()
}
示例#28
0
文件: entry.go 项目: apognu/xml
func (e *Entry) validate() xmlutils.ParserError {
	error := utils.NewErrorAggregator()

	e.validateLinks(&error)
	e.validateAuthors(&error)
	xmlutils.ValidateOccurenceCollection("entry", &error, e.Occurences)
	e.Extension.Validate(&error)
	e.ValidateCommonAttributes("entry", &error)

	if e.Occurences.Count("summary") == 0 && !e.Content.HasReadableContent() {
		error.NewError(xmlutils.NewError(MissingSummary, "Summary must be provided or Content must contain XML media type, XHTML or text"))
	}

	return error.ErrorObject()
}
示例#29
0
文件: link.go 项目: apognu/xml
func (c *Count) Validate() xmlutils.ParserError {
	errAgg := utils.NewErrorAggregator()
	link, ok := c.Parent.(*atom.Link)
	if !ok {
		errAgg.NewError(xmlutils.NewError(NotInLinkElement, "count attr should be placed in link element"))

	} else {
		if link.Rel.String() != "replies" {
			errAgg.NewError(xmlutils.NewError(LinkNotReplies, "link element should avec a 'replies' rel for this extension"))
		}
	}
	if err := c.Validator(c.Name().Local, c.Content); err != nil {
		errAgg.NewError(err)
	}

	return errAgg.ErrorObject()
}
示例#30
0
func (i *InlineXHTMLContent) ProcessStartElement(el xmlutils.StartElement) (xmlutils.Visitor, xmlutils.ParserError) {
	err := utils.NewErrorAggregator()
	if i.depth.Level == 0 && el.Name.Local != "div" {
		err.NewError(xmlutils.NewError(XHTMLRootNodeNotDiv, "Inline XHTML root node must be a div"))
	}

	if i.completed == true {
		err.NewError(xmlutils.NewError(NotUniqueChild, "Inline XHTML should be contained in a unique node"))
	}

	i.depth.Down()
	if error := i.CheckXHTMLSpace(el); error != nil {
		err.NewError(error)
	}
	if error := i.EncodeXHTMLToken(el); error != nil {
		err.NewError(xmlutils.NewError(XHTMLEncodeToStringError, "cannot encode XHTML"))
	}

	return i, err.ErrorObject()
}