xml-stream | Made for Node | Parser library
kandi X-RAY | xml-stream Summary
kandi X-RAY | xml-stream Summary
XML stream parser based on Expat. Made for Node.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Parse the XML into an element .
- XmlStream constructor .
- Emits a given element .
- Computes a final state for a given selector .
- The abstract implementation of the FinitEmitter .
- Parse event .
- Emits children of given elements .
- Execute all callbackbacks .
- setup file stream
- Emits an element and its descendants .
xml-stream Key Features
xml-stream Examples and Code Snippets
Community Discussions
Trending Discussions on xml-stream
QUESTION
here's some xml i'm parsing:
...ANSWER
Answered 2020-Oct-25 at 06:59tl;dr In tag' "row" parseAttributes parseContent
, the check
function belongs to parseAttributes
, not to parseContent
.
xml-conduit is (notably) designed around the following invariants:
- when parsers are of type
ConduitT Event o m (Maybe a)
, theMaybe
layer encodes whetherEvent
s have been consumed tag' parseName parseAttributes parseContent
consumesEvent
s if and only if bothparseName
andparseAttributes
succeedtag' parseName parseAttributes parseContent
runsparseContent
if and only if bothparseName
andparseAttributes
succeed
In parseDoc
:
- the
check
function is called in theparseContent
part; at this stage,tag'
is already committed to consumeEvent
s, as per invariant 2 - a stack of 2
Maybe
layers arejoin
ed together:- the output of the
check
function, which encodes whether the currentelement is relevant
- the "standard"
Maybe
layer fromtag'
signature, which encodes whetherEvent
s have been consumed, as per invariant 1
- the output of the
This essentially breaks invariant 1: when check
returns Nothing
, parseDoc
returns Nothing
despite consuming Event
s of the whole element.
This results in undefined behavior of all combinators of xml-conduit, notably
many'
(analyzed below.)
The many'
combinator relies on invariant 1 to do its job.
It is defined as many' consumer = manyIgnore consumer ignoreAnyTreeContent
, that is:
- try
consumer
- if
consumer
returnsNothing
, then skip element or content usingignoreAnyTreeContent
, assuming it hasn't been consumed yet byconsumer
, and recurse back to step (1)
In your case, consumer
returns Nothing
for the Daily Update 10.20.2020
item, even though the complete element has been consumed. Therefore,
ignoreAnyTreeContent
is run as a means to skip that particular , but actually ends up skipping the next one instead (
Weekly Report 10.14.2020
).
Move the check
logic to the parseAttributes
part, so that Event
consumption becomes coupled to whether check
passes.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install xml-stream
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page