The SAX interface of the xml4c2 parser

roddey at us.ibm.com roddey at us.ibm.com
Tue Oct 26 00:37:26 BST 1999




>I don't like returning "const XMLCh*" instead of "const wstring&" or
>"const string&" (even though an approach like this would be more
>efficient for an expat wrapper).  I don't need the index out of range
>warning capability, because I iterate through the AttributeList
>entries anyway.
>

wstring is not available on all the platforms. We have to support lots of
platforms and a plain character array pointer is the universal format that
everyone can understand.

>I don't like giving an AttributeList& argument to
>DocumentHandler::startElement(), instead of an
>AttributeList*, because this rules out the possibility
>of passing a null-pointer on for the cases that don't
>have an attribute list.
>

That's what the length method of the attribute list is for. Just query it for
the number of elements. A reference to an attribute list is more consistent with
the Java interface and is more convenient for the end user. For performance
reasons, most practical parsers would keep around one list object per parser
instance which is just passed out over and over again (as apposed to
constructing one on every start element callout), so there would be no
performance overhead concerns. And it means that the code that handles it can be
simpler. It doesn't have to test first for null then do the loop. It just does
the loop. If there are zero elements, the loop is never entered.

----------------------------------------
Dean Roddey
Software Weenie
IBM Center for Java Technology - Silicon Valley
roddey at us.ibm.com



xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at ic.ac.uk the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)





More information about the Xml-dev mailing list