News for hackers. Stuff that matters.
Re:Log Everything as JSON. Make Your Life Easier. by deno on Saturday April 28, 2012 @12:50AM (#3902065)
Navigation to any portion of the tree does not imply any need to keep the entire document in memory at once.

Worst case scenario XPath expression will not yield any results before traversing the entire tree. However any XPath 1.0 (and I imagine 2.0 is no different in that regard) can be compiled into a deterministic state machine (DFA), which only needs to keep tabs on how many elements it has seen and what conditions has been met.

What XPath 1.0 specifically doesn’t allow are arbitrary sub-expressions in predicates. Those would be problematic in certain conditions.

The only potential issue with performance is when running a large number of XPEs against a single stream. So there are various techniques to remedy that, including merging state machines for branching expression etc.

Re:Log Everything as JSON. Make Your Life Easier. by empthought on Saturday April 28, 2012 @08:52AM (#3902827)
There's a following:: axis in XPath which lets you look ahead to arbitrary elements. So the processor needs to load the document into memory, which of course is not streaming.
Re:Log Everything as JSON. Make Your Life Easier. by deno on Saturday April 28, 2012 @10:27AM (#3903021)
I don’t see how this axis itself is a problem. Could you provide a specific example?
Re:Log Everything as JSON. Make Your Life Easier. by empthought on Saturday April 28, 2012 @07:06PM (#3904428)
Just /node/node2/following::* in a predicate or whatever. Perhaps you're conflating XPath-as-used with XPath-as-specified? http://msdn.microsoft.com/en-us/library/ms950778.aspx explains that you can't support all of XPath (even 1.0) and process things the way that you describe.
Re:Log Everything as JSON. Make Your Life Easier. by deno on Saturday April 28, 2012 @11:39PM (#3905006)
Right, they completely eliminate any buffering. That’s very strict, but you’re right. I thought you meant that there’s a subset of XPath that can’t work on anything but DOM.
Re:Log Everything as JSON. Make Your Life Easier. by empthought on Sunday April 29, 2012 @10:35AM (#3906049)
Yeah, that's all. The reason it's relevant is that XPath processors often value conformance over expanding the utility of their system. I didn't want someone going off and using libxslt or xalan expecting it to process things in a memory-efficient manner.