(t *testing.T)
| 596 | } |
| 597 | |
| 598 | func 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 | |
| 636 | func TestDirective(t *testing.T) { |
| 637 | s := `<?xml version="1.0" encoding="UTF-8"?> |
nothing calls this directly
no test coverage detected
searching dependent graphs…