CreateStreamParserWithOptions is like CreateStreamParser, but with custom options
( r io.Reader, options ParserOptions, streamElementXPath string, streamElementFilter ...string, )
| 452 | |
| 453 | // CreateStreamParserWithOptions is like CreateStreamParser, but with custom options |
| 454 | func CreateStreamParserWithOptions( |
| 455 | r io.Reader, |
| 456 | options ParserOptions, |
| 457 | streamElementXPath string, |
| 458 | streamElementFilter ...string, |
| 459 | ) (*StreamParser, error) { |
| 460 | elemXPath, err := getQuery(streamElementXPath) |
| 461 | if err != nil { |
| 462 | return nil, fmt.Errorf("invalid streamElementXPath '%s', err: %s", streamElementXPath, err.Error()) |
| 463 | } |
| 464 | elemFilter := (*xpath.Expr)(nil) |
| 465 | if len(streamElementFilter) > 0 { |
| 466 | elemFilter, err = getQuery(streamElementFilter[0]) |
| 467 | if err != nil { |
| 468 | return nil, fmt.Errorf("invalid streamElementFilter '%s', err: %s", streamElementFilter[0], err.Error()) |
| 469 | } |
| 470 | } |
| 471 | parser := createParser(r) |
| 472 | options.apply(parser) |
| 473 | sp := &StreamParser{ |
| 474 | p: parser, |
| 475 | } |
| 476 | sp.p.streamElementXPath = elemXPath |
| 477 | sp.p.streamElementFilter = elemFilter |
| 478 | return sp, nil |
| 479 | } |
| 480 | |
| 481 | // Read returns a target node that satisfies the XPath specified by caller at |
| 482 | // StreamParser creation time. If there is no more satisfying target nodes after |
no test coverage detected
searching dependent graphs…