MCPcopy Create free account
hub / github.com/antchfx/xmlquery / TestStreamParser_DefaultNamespace

Function TestStreamParser_DefaultNamespace

parse_test.go:598–634  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

596}
597
598func TestStreamParser_DefaultNamespace(t *testing.T) {
599 s := `
600 <Objects xmlns="http://example.com/schema/2007/someschema">
601 <Object id="ObjectA">ObjectA</Object>
602 <Object id="ObjectB">ObjectB</Object>
603 <Object id="ObjectC">ObjectD</Object>
604 </Objects>`
605
606 sp, err := CreateStreamParser(strings.NewReader(s), "//Objects/*[namespace-uri()=\"http://example.com/schema/2007/someschema\" and local-name()=\"Object\"]")
607 if err != nil {
608 t.Fatal(err.Error())
609 }
610
611 n, err := sp.Read()
612 if err != nil {
613 t.Fatal(err.Error())
614 }
615
616 var x = `<Object id="ObjectA">ObjectA</Object>`
617 testOutputXML(t, "first call result", x, n)
618
619 n, err = sp.Read()
620 if err != nil {
621 t.Fatal(err.Error())
622 }
623
624 x = `<Object id="ObjectB">ObjectB</Object>`
625 testOutputXML(t, "second call result", x, n)
626
627 n, err = sp.Read()
628 if err != nil {
629 t.Fatal(err.Error())
630 }
631
632 x = `<Object id="ObjectC">ObjectD</Object>`
633 testOutputXML(t, "third call result", x, n)
634}
635
636func TestDirective(t *testing.T) {
637 s := `<?xml version="1.0" encoding="UTF-8"?>

Callers

nothing calls this directly

Calls 3

CreateStreamParserFunction · 0.85
testOutputXMLFunction · 0.85
ReadMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…