Ticket #104 (assigned enhancement)
Add spport for stream parsers to XPath
| Reported by: | ser | Owned by: | ser |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.1.9 |
| Component: | DOM | Version: | 3.1.4 |
| Severity: | minor | Keywords: | |
| Cc: | Ruby version: | 1.8.5 | |
| Operating system: | Linux |
Description (last modified by ser) (diff)
This will enhance the XPath interpreter such that it can operate on streams.
There are, currently, the following stream parsers:
- lightparser
- pullparser
- sax2parser
- streamparser
- ultralightparser
The use case for the PullParser?, StreamParser?, and LightParser? are similar, so only the PullParser? is described.
Sample input
input = "<a><b><c id='1'/><c>x</c></b></a>"
SAX2Parser Use Case
p = SAX2Parser.new(input)
found = false
p.listen( "//c[@id='1']" ) { |uri, local, qname, attrs|
if attrs['id'] == '1'
found = true
else
raise "Found wrong c"
end
}
raise "c not found" unless found
PullParser?
p = PullParser.new(input)
found = false
for event in p
if event.matches("//c[text() == 'x']")
if event[1]['id'].nil?
found = true
else
raise "Found wrong c"
end
end
end
raise "c not found" unless found
Change History
Note: See
TracTickets for help on using
tickets.
