On 28/11/10 15:02, Peter Davis wrote:
> On 11/24/2010 7:04 PM, Peter Flynn wrote:
>> Basically, the parser has to look at every character in the input XML
>>> data, to determine where "<" and">" occur. So in the process of doing
>>> that, it could also be identifying pre-determined strings, like element
>>> names. Otherwise, whether it's SAX or DOM, all it's tell the calling
>>> application that there are elements.
>> I don't think that's correct. At least I really hope not.
> Well, at some level, the software has to examine the actual string data
> to identify the characters. I'm not sure how much overhead there is in
> re-examining the same strings again and again, but there has to be
Indeed. If it does it. My understanding is that it only happens once,
when the parser reads the document, so all the data needed must be
gathered on that one pass. The accumulated names and other node and arc
data is assembled in memory, and the resulting tree handed to the
application for consumption. From a brief read of the documentation for
XML::Parse, yaxx, Expat, Python's parse(), Lark/Larval, and LibXML, and
they all appear to pass the name and other node data in the parse tree.
I will send a few key people email asking if this is true or if I have
the wrong end of the stick.
> If my XML consists just of "<blah/>," then a parser has to read
> this to determine that it's a single empty element whose name is
> "blah." It then either gives me a tree containing the element (DOM), or
> calls my 'beginElement' and 'endElement' callbacks (SAX). Either way, I
> now have to do string comparisons against the name of this element in
> order to figure out that it's a "blah," as opposed to a "whosis" or a
Surely it passes the node data, including the name, as part of the tree?
There should be no need to go back to the original document.
> I'll take a closer look at it, but my preference would be for a one-pass
> solution. I may be able to push some of the actual image reading to
> TeX/LaTeX/DVI, since those files will have to be retrieved and opened
> again there anyway.
You could look at LuaTeX for doing this during TeX execution.
> Thanks so much! I'll definitely look into this approach. I'm
> anticipating documents using tens of thousands of images, though many of
> them may recur. I'll have to weigh the alternatives.
In two catalogue applications I worked on, the image data turned out to
be available in a database anyway, so I was able to arrange for the
height, width, resolution, and colorspace to be added to the exported
XML as attributes, which made life much easier. If your documents have
an automated background, it might be worth asking some questions.