Exemplo n.º 1
0
func _TestThrEntryToTestVisitor(t testThrEntry) xmlutils.TestVisitor {
	customError := xmlutils.NewErrorChecker(xmlutils.DisableAllError)

	customError.EnableErrorChecking("in-reply-to", atom.MissingAttribute)
	customError.EnableErrorChecking("in-reply-to", atom.AttributeDuplicated)
	customError.EnableErrorChecking("entry", atom.AttributeDuplicated)
	customError.EnableErrorChecking("link", LinkNotReplies)
	customError.EnableErrorChecking("link", NotInLinkElement)
	customError.EnableErrorChecking(xmlutils.AllError, atom.NotPositiveNumber)

	testVisitor := xmlutils.TestVisitor{
		XML:                t.XML,
		ExpectedError:      nil,
		ExpectedVisitor:    t.ExpectedThrEntry,
		VisitorConstructor: testThrEntryConstructor,
		Validator:          testThrEntryValidator,
		CustomError:        &customError,
	}

	if t.ExpectedError != nil {
		testVisitor.ExpectedError = t.ExpectedError
	}

	return testVisitor
}
Exemplo n.º 2
0
func ExampleParseOptions() {
	// the input feed is not compliant to spec
	f, err := os.Open("testdata/atom.xml")
	if err != nil {
		return
	}

	// the input feed should be 100% compliant to spec...
	flags := xmlutils.NewErrorChecker(xmlutils.EnableAllError)

	//... but it is OK if Atom entry does not have <updated> field
	flags.DisableErrorChecking("entry", atom.MissingDate)

	options := feed.ParseOptions{ExtensionManager: extension.Manager{},
		ErrorFlags: &flags}

	myfeed, err := feed.Parse(f, options)

	if err != nil {
		fmt.Printf("Cannot parse feed:\n%s\n", err)
		return
	}

	fmt.Printf("FEED '%s'\n", myfeed.Title)

	// Output:
	//Cannot parse feed:
	//in 'feed':
	//[MissingId]
	//	feed's id should exist
}
Exemplo n.º 3
0
Arquivo: parse.go Projeto: apognu/xml
func init() {
	errorFlags := xmlutils.NewErrorChecker(xmlutils.DisableAllError)
	DefaultOptions = ParseOptions{
		extension.Manager{},
		&errorFlags,
	}
}