From kevin@myplaceonline.com Sun Nov 3 03:57:13 2002 From: kevin@myplaceonline.com (Kevin) Date: Sat, 2 Nov 2002 22:57:13 -0500 Subject: [Expat-discuss] XMLParse Handlers Message-ID: <000501c282ed$18310140$19354742@computer> I am having a problem with Expat. I think the problem is the fact that I am trying to implement it within a class. Maybe not. Here is the error: textdb.cpp:65: no matches converting function `elementStart' to type `void (*) (void *, const XML_Char *, const XML_Char **)' textdb.h:31: candidates are: void textdb::TextDB::elementStart (void *, const char *, const char **) here is the line it is complaining about, followed by the elementStart and elementEnd methods, which are class member methods: XML_SetElementHandler(parser, elementStart, elementEnd); void TextDB::elementStart(void *data, const char *el, const char **attr) { printf("EL: %s\n",el); } void TextDB::elementEnd(void *data, const char *el) { } What's wrong? Thanks, Kevin From karl@waclawek.net Sun Nov 3 05:07:53 2002 From: karl@waclawek.net (Karl Waclawek) Date: Sun, 3 Nov 2002 00:07:53 -0500 Subject: [Expat-discuss] XMLParse Handlers References: <000501c282ed$18310140$19354742@computer> Message-ID: <000701c282f6$f7b5d5d0$0207a8c0@karl> Yes, the handlers you have to set with Expat must be clean function pointers. Member methods are not compatible, since they have a hidden *this* parameter. Static methods should be OK, but I am no C++ expert. Karl ----- Original Message ----- From: "Kevin" To: Sent: Saturday, November 02, 2002 10:57 PM Subject: [Expat-discuss] XMLParse Handlers > I am having a problem with Expat. I think the problem is the fact that > I am trying to implement it within a class. Maybe not. Here is the > error: > > > > textdb.cpp:65: no matches converting function `elementStart' to type > > `void (*) (void *, const XML_Char *, const XML_Char **)' > > textdb.h:31: candidates are: void textdb::TextDB::elementStart (void *, > > const char *, const char **) > > > > here is the line it is complaining about, followed by the elementStart > and elementEnd methods, which are class member methods: > > > > XML_SetElementHandler(parser, elementStart, elementEnd); > > > > void TextDB::elementStart(void *data, const char *el, const char **attr) > { > > printf("EL: %s\n",el); > > } > > > > void TextDB::elementEnd(void *data, const char *el) { > > } > > > > What's wrong? > > > > Thanks, > > Kevin > > > > > > _______________________________________________ > Expat-discuss mailing list > Expat-discuss@libexpat.org > http://mail.libexpat.org/mailman/listinfo/expat-discuss From kevin@myplaceonline.com Sun Nov 3 06:22:11 2002 From: kevin@myplaceonline.com (Kevin) Date: Sun, 3 Nov 2002 01:22:11 -0500 Subject: [Expat-discuss] XMLParse Handlers In-Reply-To: <000701c282f6$f7b5d5d0$0207a8c0@karl> Message-ID: <000a01c28301$58934e50$19354742@computer> So is there anyway around this, or is event handling just inherently anti-object oriented? Thanks again, Kevin -----Original Message----- From: Karl Waclawek [mailto:karl@waclawek.net] Sent: Sunday, November 03, 2002 12:08 AM To: kevin@myplaceonline.com; expat-discuss@libexpat.org Subject: Re: [Expat-discuss] XMLParse Handlers Yes, the handlers you have to set with Expat must be clean function pointers. Member methods are not compatible, since they have a hidden *this* parameter. Static methods should be OK, but I am no C++ expert. Karl ----- Original Message ----- From: "Kevin" To: Sent: Saturday, November 02, 2002 10:57 PM Subject: [Expat-discuss] XMLParse Handlers > I am having a problem with Expat. I think the problem is the fact that > I am trying to implement it within a class. Maybe not. Here is the > error: > > > > textdb.cpp:65: no matches converting function `elementStart' to type > > `void (*) (void *, const XML_Char *, const XML_Char **)' > > textdb.h:31: candidates are: void textdb::TextDB::elementStart (void *, > > const char *, const char **) > > > > here is the line it is complaining about, followed by the elementStart > and elementEnd methods, which are class member methods: > > > > XML_SetElementHandler(parser, elementStart, elementEnd); > > > > void TextDB::elementStart(void *data, const char *el, const char **attr) > { > > printf("EL: %s\n",el); > > } > > > > void TextDB::elementEnd(void *data, const char *el) { > > } > > > > What's wrong? > > > > Thanks, > > Kevin > > > > > > _______________________________________________ > Expat-discuss mailing list > Expat-discuss@libexpat.org > http://mail.libexpat.org/mailman/listinfo/expat-discuss From karl@waclawek.net Sun Nov 3 07:21:39 2002 From: karl@waclawek.net (Karl Waclawek) Date: Sun, 3 Nov 2002 02:21:39 -0500 Subject: [Expat-discuss] XMLParse Handlers References: <000a01c28301$58934e50$19354742@computer> Message-ID: <000f01c28309$aa20dd20$0207a8c0@karl> Well, Expat is written in C which does not support OO that well. However, there are OO wrappers for Expat if that is what you prefer. Check out the links at http://www.libexpat.org. Karl ----- Original Message ----- From: "Kevin" To: "'Karl Waclawek'" ; Sent: Sunday, November 03, 2002 1:22 AM Subject: RE: [Expat-discuss] XMLParse Handlers > So is there anyway around this, or is event handling just inherently > anti-object oriented? > > Thanks again, > Kevin > > -----Original Message----- > From: Karl Waclawek [mailto:karl@waclawek.net] > Sent: Sunday, November 03, 2002 12:08 AM > To: kevin@myplaceonline.com; expat-discuss@libexpat.org > Subject: Re: [Expat-discuss] XMLParse Handlers > > Yes, the handlers you have to set with Expat must be clean > function pointers. Member methods are not compatible, since > they have a hidden *this* parameter. > > Static methods should be OK, but I am no C++ expert. > > Karl > > ----- Original Message ----- > From: "Kevin" > To: > Sent: Saturday, November 02, 2002 10:57 PM > Subject: [Expat-discuss] XMLParse Handlers > > > > I am having a problem with Expat. I think the problem is the fact > that > > I am trying to implement it within a class. Maybe not. Here is the > > error: > > > > > > > > textdb.cpp:65: no matches converting function `elementStart' to type > > > > `void (*) (void *, const XML_Char *, const XML_Char **)' > > > > textdb.h:31: candidates are: void textdb::TextDB::elementStart (void > *, > > > > const char *, const char **) > > > > > > > > here is the line it is complaining about, followed by the elementStart > > and elementEnd methods, which are class member methods: > > > > > > > > XML_SetElementHandler(parser, elementStart, elementEnd); > > > > > > > > void TextDB::elementStart(void *data, const char *el, const char > **attr) > > { > > > > printf("EL: %s\n",el); > > > > } > > > > > > > > void TextDB::elementEnd(void *data, const char *el) { > > > > } > > > > > > > > What's wrong? > > > > > > > > Thanks, > > > > Kevin > > > > > > > > > > > > _______________________________________________ > > Expat-discuss mailing list > > Expat-discuss@libexpat.org > > http://mail.libexpat.org/mailman/listinfo/expat-discuss > > From karl@waclawek.net Sun Nov 3 16:46:41 2002 From: karl@waclawek.net (Karl Waclawek) Date: Sun, 3 Nov 2002 11:46:41 -0500 Subject: [Expat-discuss] XMLParse Handlers References: <000f01c28353$696c88c0$19354742@computer> Message-ID: <000701c28358$960cfef0$0207a8c0@karl> > Actually, what I did is made the startElement and endElement methods > static, and passed the "this" pointer as the User data. However, I'm > thinking that there might be possible threading issues here. Is this > worry warranted? If so, I've never dealt with threads in C++, how would > this situation be "synchronized?" An Expat parser instance should only be used from within a thread. That is, calling XML_Parse(Buffer), setting handlers and such is not thread safe. However, if the handlers passed to Expat are themselves thread-safe then that should be OK, since the call direction is reversed, i.e. Expat is not the callee, but the caller. Now, if you need to call XML_Parse(Buffer) from different threads then you should wrap the call into another call which can be made thread-safe, e.g. using critical sections or mutexes. But I am no expert on how to use those in C++. > (and thanks for the link, I checked out the OO wrappers, and they look > good, but I'll try the above method first since I already wrote a lot of > code that way) It seems the most current wrapper is Arabica, btw. Karl From cepek@gama.fsv.cvut.cz Tue Nov 5 09:34:07 2002 From: cepek@gama.fsv.cvut.cz (Ales Cepek) Date: 05 Nov 2002 10:34:07 +0100 Subject: [Expat-discuss] Re: XMLParse Handlers References: <000701c282f6$f7b5d5d0$0207a8c0@karl> <000a01c28301$58934e50$19354742@computer> Message-ID: <87bs54fjhs.fsf@GaMa.fsv.cvut.cz> "Kevin" writes: Hi, we are using expat 1.1 in our C++ project GNU GaMa. You can either look at the sources from CVS http://savannah.gnu.org/projects/gama/ (directory gamalib/xml/*) or let me know and I will send you the relevant source codes to your personal email address. I hope that differences between old version 1.1 and the lates version are not important in this case. Ales > So is there anyway around this, or is event handling just inherently > anti-object oriented? > > Thanks again, > Kevin > > -----Original Message----- > From: Karl Waclawek [mailto:karl@waclawek.net] > Sent: Sunday, November 03, 2002 12:08 AM > To: kevin@myplaceonline.com; expat-discuss@libexpat.org > Subject: Re: [Expat-discuss] XMLParse Handlers > > Yes, the handlers you have to set with Expat must be clean > function pointers. Member methods are not compatible, since > they have a hidden *this* parameter. > > Static methods should be OK, but I am no C++ expert. > > Karl > From aweegh@weegh-it.nl Thu Nov 7 11:04:02 2002 From: aweegh@weegh-it.nl (A. op de Weegh) Date: Thu, 07 Nov 2002 12:04:02 +0100 Subject: [Expat-discuss] Line too long??? Message-ID: <000701c2864d$6235ec20$0200000a@weeghit.intra> Hi all, I have this XML file which contains a line of 1067 characters in length. Expat complains about a not well formed line (invalid token) at position 779. Here's my line (note that is is not divided over several lines in the text file). Position 779 is the dot between 'LVL' and 'datum'. Is my line too long, or is there another problem. If my line is too long, how do I split it up? Thanx, Alex ----- Weegh-IT Klaas Keurisstraat 4 1761 CL Anna Paulowna Tel.: 0223-535 956 Fax: 0223-535 945 http://www.weegh-it.nl/ From karl@waclawek.net Thu Nov 7 14:33:23 2002 From: karl@waclawek.net (Karl Waclawek) Date: Thu, 7 Nov 2002 09:33:23 -0500 Subject: [Expat-discuss] Line too long??? References: <000701c2864d$6235ec20$0200000a@weeghit.intra> Message-ID: <001401c2866a$a0b02930$9e539696@citkwaclaww2k> > Hi all, > I have this XML file which contains a line of 1067 characters in length. > Expat complains about a not well formed line (invalid token) at position > 779. Here's my line (note that is is not divided over several lines in the > text file). Check if there are any invalid characters in the attribute value that you would need to escape. Specs are at: http://www.w3.org/TR/REC-xml.html Karl From john@osborntech.com Fri Nov 15 15:02:23 2002 From: john@osborntech.com (John Osborn) Date: Fri, 15 Nov 2002 09:02:23 -0600 Subject: [Expat-discuss] Empty Tags Message-ID: I would like to have my CharacterDataHandler called even when the tags are empty. Is there a way to do this? I know I can tell if a tag was empty from the EndElement handler, but it's too late at that point. From john@osborntech.com Fri Nov 15 16:24:12 2002 From: john@osborntech.com (John Osborn) Date: Fri, 15 Nov 2002 10:24:12 -0600 Subject: [Expat-discuss] Empty Tags In-Reply-To: <77BBB49BC061D211814E00A0C9EA23E32FD8B8@COMPANYWATCH> Message-ID: I think what I'm going to end up doing is going with DOM instead of SAX style processing. This will work ok for my app because the XML doesn't get too large. Life would be easier if expat would have an optional mode that, when enabled, would cause the characterdatahandler to be called with NULL data and length set to zero when tags are empty. -----Original Message----- From: Warren Crossing [mailto:wcrossing@companywatch.net] Sent: Friday, November 15, 2002 9:08 AM To: john@osborntech.com Subject: RE: [Expat-discuss] Empty Tags no, i usually build a sort of state machine within the callbak handler to track weather i build the character buffer or not. help? > -----Original Message----- > From: John Osborn [SMTP:john@osborntech.com] > Sent: Friday, November 15, 2002 3:02 PM > To: expat-discuss@libexpat.org > Subject: [Expat-discuss] Empty Tags > > I would like to have my CharacterDataHandler called even when the tags are > empty. Is there a way to do this? I know I can tell if a tag was empty > from the EndElement handler, but it's too late at that point. > > > _______________________________________________ > Expat-discuss mailing list > Expat-discuss@libexpat.org > http://mail.libexpat.org/mailman/listinfo/expat-discuss > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This message is intended only for the addressee and may contain information that is confidential or privileged. Unauthorised use is strictly prohibited and may be unlawful. If you are not the addressee, you should not read, copy, disclose or otherwise use this message, except for the purpose of delivery to the addressee. If you have received this in error, please delete and advise us immediately. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Although Company Watch makes every reasonable effort to keep its network and systems free from viruses, the company accepts no responsibility for computer viruses transmitted through this mail or in any attachments. It is your responsibility to virus scan any attachments we send to you. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From karl@waclawek.net Fri Nov 15 16:37:16 2002 From: karl@waclawek.net (Karl Waclawek) Date: Fri, 15 Nov 2002 11:37:16 -0500 Subject: [Expat-discuss] Empty Tags References: Message-ID: <015001c28cc5$41d1a720$9e539696@citkwaclaww2k> > I think what I'm going to end up doing is going with DOM instead of SAX > style processing. This will work ok for my app because the XML doesn't get > too large. > > Life would be easier if expat would have an optional mode that, when > enabled, would cause the characterdatahandler to be called with NULL data > and length set to zero when tags are empty. Just wrap the end element handler. That is, Expat calls your wrapper handler, this one in turn checks if the element is empty, and if yes, it calls the application's character handler before it calls the application's end element handler. Karl From john@osborntech.com Fri Nov 15 16:53:02 2002 From: john@osborntech.com (John Osborn) Date: Fri, 15 Nov 2002 10:53:02 -0600 Subject: [Expat-discuss] Empty Tags In-Reply-To: <015001c28cc5$41d1a720$9e539696@citkwaclaww2k> Message-ID: That will work. Should have thought of that myself. Thanks! -----Original Message----- From: Karl Waclawek [mailto:karl@waclawek.net] Sent: Friday, November 15, 2002 10:37 AM To: john@osborntech.com; expat-discuss@libexpat.org Subject: Re: [Expat-discuss] Empty Tags > I think what I'm going to end up doing is going with DOM instead of SAX > style processing. This will work ok for my app because the XML doesn't get > too large. > > Life would be easier if expat would have an optional mode that, when > enabled, would cause the characterdatahandler to be called with NULL data > and length set to zero when tags are empty. Just wrap the end element handler. That is, Expat calls your wrapper handler, this one in turn checks if the element is empty, and if yes, it calls the application's character handler before it calls the application's end element handler. Karl From karl@waclawek.net Tue Nov 19 19:55:54 2002 From: karl@waclawek.net (Karl Waclawek) Date: Tue, 19 Nov 2002 14:55:54 -0500 Subject: [Expat-discuss] Expat and malicious XML Message-ID: <00dd01c29005$ab91a3c0$9e539696@citkwaclaww2k> Recently we got notified by Sanctum Inc. about a security vulnerability in Expat. As it turns out, any conforming parser is vulnerable, so this is not an Expat problem. The attack basically consists of including an ordered list of internal entity declarations, each having two or more references to the previous entity. For instance, using two references each time will result in a total of sum(i=1 to N)2^i internal entity references to resolve for N such entity declarations. This is at least a CPU hog, but can also turn into a memory hog if parameter entities are used. The question is, should there anything be done in Expat to counter such an attack. Should the counter measures be outside of Expat? How important is it to have some counter measure features in Expat, if it can also be done without touching Expat. Here is what we have considered so far: 1) Have Expat limit the number of open internal entities (i.e. limit nesting level of entities), adding an API to set that level. IMO, this excludes too many "proper" XML documents, but is not a big deal to implement. 2) Have Expat calculate the "fan-out" of an entity while parsing the DTD, according to this recursive algorithm: - start with fan-out = 0 - for each entity reference, increment fan-out by (1 + fan-out of referenced entity) And add an API to set a fan-out threshold. Depending on the order of appearance of entity declarations (general entity references don't require an existing declaration since they are not resolved at DTD parsing time) this may require the implementation to manage a list of unresolved fan-outs until the end of the DTD is reached. So the implementation is more involved here. But this will calculate the true impact of the attack more accurately. For parameter entity references this will be accompanied by using up memory, so in this case one may have to stop parsing at the first entity declaration exceeding the threshold. 3) Without touching Expat: Put parser in its own thread, assign a proper thread priority and kill thread if a certain timeout threshold has passed. This can make coding more tricky, but has the advantage to work for any (as yet unknown) attack that makes the parser eat CPU cycles or memory. 4) Like 3) but with modified memory handler API to allow monitoring of memory allocations for individual parser instances. Does anybody have additional suggestions and/or comments to the above? What would be your preferences (considering that some one has to find the time to actually implement any new features in Expat)? Karl From phantom2023@hotmail.com Wed Nov 20 02:33:24 2002 From: phantom2023@hotmail.com (Rob R) Date: Tue, 19 Nov 2002 20:33:24 -0600 Subject: [Expat-discuss] Newbie here.. need urgent help :( Message-ID: Hello, Im new, and Im really interested in Expat. I have a XML document in a format similar to this Slicer description here slicer.bmp Lurker description here lurker.bmp I have many entries, each with a new name, description and picture. What I need to do is parse it given the name of the creature to get the description and picture file name. Does anyone have a tutorial on this? _________________________________________________________________ STOP MORE SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail From karl@waclawek.net Thu Nov 21 01:44:32 2002 From: karl@waclawek.net (Karl Waclawek) Date: Wed, 20 Nov 2002 20:44:32 -0500 Subject: [Expat-discuss] Should xmlwf default to using memory mapped files Message-ID: <000b01c290ff$89f573e0$0207a8c0@karl> It seems that large XML files are more common nowadays. Since xmlwf defaults to using memory mapped files, this means that checking large files can cause "out of memory" errors, if this behaviour is not turned off using the -r option. I am trying to get feedback from the list if we should change the default to regular I/O, and add a -m option for those situations where ultimate performance is the goal. This can improve the speed of xmlwf by about 15%, as reported by an Expat user. Karl From chaiml@post.tau.ac.il Mon Nov 18 16:37:24 2002 From: chaiml@post.tau.ac.il (chaiml@post.tau.ac.il) Date: Mon, 18 Nov 2002 18:37:24 +0200 (IST) Subject: [Expat-discuss] Terminating the parser Message-ID: <1037637444.3dd917447530e@webmail.tau.ac.il> Hi, Suppose I detect an error in one of the handlers (e.g., in the StartElementHandler). How do I tell Expat to stop parsing the document? The handlers are all defined as void, so I can't return an error code to Expat. Is there some error flag that I can turn on and the parser will check? Thanks, Chaim Linhart (chaiml@post.tau.ac.il). From karl@waclawek.net Thu Nov 21 14:02:08 2002 From: karl@waclawek.net (Karl Waclawek) Date: Thu, 21 Nov 2002 09:02:08 -0500 Subject: [Expat-discuss] Terminating the parser References: <1037637444.3dd917447530e@webmail.tau.ac.il> Message-ID: <000901c29166$94570da0$9e539696@citkwaclaww2k> > Hi, > Suppose I detect an error in one of the handlers (e.g., > in the StartElementHandler). > How do I tell Expat to stop parsing the document? > The handlers are all defined as void, so I can't return an error code to Expat. > Is there some error flag that I can turn on and the parser will check? Depends on the language you are calling Expat from. In C++ or Delphi I would raise/throw an exception. In C, one can use setjmp/longjmp. Check out the mailing list archives - this has been discussed in the past couple of months. Currently there is no such return value for handlers. A workaround would be to clear all handlers when the error is detected, set a flag, and stop processing when the next call to XML_GetBuffer/XMLParseBuffer comes up. Karl From Bruce_Bailey@adp.com Thu Nov 21 15:52:56 2002 From: Bruce_Bailey@adp.com (Bruce Bailey) Date: Thu, 21 Nov 2002 07:52:56 -0800 Subject: [Expat-discuss] Need Help Compiling Expat on old system Message-ID: Hi I have been struggling to build expat 1.95.5 on Motorola system V r3. = The compiler is version 1.8.6m1 Green Hills C compiler. For some reason = it doesn't appear to understand some of the macros used in the expat = library. In any case, to make any kind of progress at all, I have made = the changes listed below. Does anyone have any suggestions to make the = might help an older compiler build expat? I'm wondering if perhaps an = earlier version of expat might work better. I have tried installing the = current version of the GNU compiler on my Motorola system, but no luck = in getting that installed. TIA, Bruce Added option -X316 to makefile compile flags CFLAGS =3D -g -X316 Added cast to malloc assignments (lib/xmlparse.c 661): (struct XML_ParserStruct*) Added casts to malloc/realloc function assignments (lib/xmlparse.c = 664,665): (void *(*)(size_t)) (void *(*)(void *, size_t)) Added missing stddef.h (copied from linux) #ifndef _LINUX_STDDEF_H #define _LINUX_STDDEF_H #undef NULL #if defined(__cplusplus) #define NULL 0 #else #define NULL ((void *)0) #endif #undef offsetof #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif Commented out lib/expat.h (736 and 738) /*#define XML_STATUS_ERROR XML_STATUS_ERROR*/ /*#define XML_STATUS_OK XML_STATUS_OK*/ Replaced lib/xmlparse.c 1597 return V2(XML_MAJOR_VERSION, XML_MINOR_VERSION, XML_MICRO_VERSION); with return ""; Changed NS(func_name) to func_name in lib/xmltok_ns.c :%s/NS(\([^)]*\))/\1/gc Bruce Bailey 2525 SW First Avenue Portland, OR 97201 (503) 294-4206 Bruce_Bailey@adp.com From allan.saywitz@pb.com Thu Nov 21 17:28:15 2002 From: allan.saywitz@pb.com (allan.saywitz@pb.com) Date: Thu, 21 Nov 2002 11:28:15 -0600 Subject: [Expat-discuss] Can XML_Parse return a list of all errors if file not well-formed? Message-ID: Can XML_Parse return a list of all errors if file is not well-formed? The reason is our users are running MVS and VSE and unfortunately I couldn't find them any xml editors available to them. So they may need to edit the xml files themselves and they will probably make some errors. Any information would be very appreciative! thanks allan saywitz Pitney Bowes allan.saywitz@pb.com (630) 435-7424 From karl@waclawek.net Thu Nov 21 18:15:15 2002 From: karl@waclawek.net (Karl Waclawek) Date: Thu, 21 Nov 2002 13:15:15 -0500 Subject: [Expat-discuss] Can XML_Parse return a list of all errors if file not well-formed? References: Message-ID: <008701c29189$f0c9cfa0$9e539696@citkwaclaww2k> > Can XML_Parse return a list of all errors if file is not well-formed? > > The reason is our users are running MVS and VSE and unfortunately I > couldn't find them any xml editors available to them. So they may need to > edit the xml files themselves and they will probably make some errors. > > Any information would be very appreciative! Unfortunately, Expat stops at the first error. However, the XML editors I have tried have the same behaviour. It would not always be easy for an XML parser to continue parsing after an error was encountered! Karl From omagrane@anthill.es Thu Nov 21 18:40:32 2002 From: omagrane@anthill.es (Oriol) Date: Thu, 21 Nov 2002 19:40:32 +0100 Subject: [Expat-discuss] Trouble using static expat in MS VC 6 Message-ID: <003001c2918d$79ce88b0$0201a8c0@amd> Hi, I've installed and successfully built expat 1.95.5 under Visual C 6. However, problems arise when I try to use it. I need to statically link the expat library to my program, but after = a successful compilation, the linker stops with this error: = MyProgram.obj : "error LNK2001: unresolved external symbol = __imp__XML_ParserCreate" The library paths already include the directory where libexpat.lib = lives, so the problem is not a missing library. Furthermore I've declared the symbol XML_STATIC in = Resources->Preprocessor, but the problem still remains. Any idea? =20 Oriol From karl@waclawek.net Thu Nov 21 18:58:05 2002 From: karl@waclawek.net (Karl Waclawek) Date: Thu, 21 Nov 2002 13:58:05 -0500 Subject: [Expat-discuss] Trouble using static expat in MS VC 6 References: <003001c2918d$79ce88b0$0201a8c0@amd> Message-ID: <00a201c2918f$ec87aa60$9e539696@citkwaclaww2k> You may have linked to the Dll import library instead of the static library. They have the same names, but should be in different Release directories. The upcoming version of Expat will have a different naming scheme, with the name post-fixed according to the version of the runtime library used (multi-threaded or not, etc.). By default it will build as libexpatMT.lib. Karl ----- Original Message ----- From: "Oriol" To: Sent: Thursday, November 21, 2002 1:40 PM Subject: [Expat-discuss] Trouble using static expat in MS VC 6 Hi, I've installed and successfully built expat 1.95.5 under Visual C 6. However, problems arise when I try to use it. I need to statically link the expat library to my program, but after a successful compilation, the linker stops with this error: MyProgram.obj : "error LNK2001: unresolved external symbol __imp__XML_ParserCreate" The library paths already include the directory where libexpat.lib lives, so the problem is not a missing library. Furthermore I've declared the symbol XML_STATIC in Resources->Preprocessor, but the problem still remains. Any idea? From omagrane@anthill.es Thu Nov 21 20:09:27 2002 From: omagrane@anthill.es (Oriol) Date: Thu, 21 Nov 2002 21:09:27 +0100 Subject: [Expat-discuss] Trouble using static expat in MS VC 6 Message-ID: <004f01c29199$e5a33f20$0201a8c0@amd> Hi, Karl! Thank you for your quick reply! After building expat-1.95.5 I obtained four different subdirectories with libraries in: Debug, Debug_static, Release and Release_static. So I added "libexpat.lib" to Project->Settings->Link->Library modules, and the path to this library in Tools->Options->Directories->Libraries. So I think I am linking the static library, not the dll. Is it right? What else could be that external reference error due? Thank you very much again. Oriol ----- Original Message ----- From: "Karl Waclawek" To: "Oriol" ; Sent: Thursday, November 21, 2002 7:58 PM Subject: Re: [Expat-discuss] Trouble using static expat in MS VC 6 > You may have linked to the Dll import library instead of the static library. > They have the same names, but should be in different Release directories. > > The upcoming version of Expat will have a different naming scheme, > with the name post-fixed according to the version of the runtime > library used (multi-threaded or not, etc.). By default it will > build as libexpatMT.lib. > > Karl > > ----- Original Message ----- > From: "Oriol" > To: > Sent: Thursday, November 21, 2002 1:40 PM > Subject: [Expat-discuss] Trouble using static expat in MS VC 6 > > > > Hi, > I've installed and successfully built expat 1.95.5 under Visual C 6. > However, problems arise when I try to use it. > I need to statically link the expat library to my program, but after a successful compilation, > the linker stops with this error: MyProgram.obj : "error LNK2001: unresolved external symbol > __imp__XML_ParserCreate" > The library paths already include the directory where libexpat.lib lives, so the problem is not > a missing library. > Furthermore I've declared the symbol XML_STATIC in Resources->Preprocessor, but the problem > still remains. > Any idea? > > > From karl@waclawek.net Thu Nov 21 20:20:52 2002 From: karl@waclawek.net (Karl Waclawek) Date: Thu, 21 Nov 2002 15:20:52 -0500 Subject: [Expat-discuss] Trouble using static expat in MS VC 6 References: <004f01c29199$e5a33f20$0201a8c0@amd> Message-ID: <004401c2919b$7d2bdc20$9e539696@citkwaclaww2k> Check the "elements" example project in the Expat workspace. It has a dependency on expat_static. Check the Link page in the project settings. Does the Additional Library Path field show something like ..\lib\Release_static ? Make sure that the libexpat.lib the linker finds is the right one. If in doubt, rename all instances of libexpat.lib except for the right one, and see what the linker reports. Karl ----- Original Message ----- From: "Oriol" To: Sent: Thursday, November 21, 2002 3:09 PM Subject: Re: [Expat-discuss] Trouble using static expat in MS VC 6 > Hi, Karl! Thank you for your quick reply! > After building expat-1.95.5 I obtained four different subdirectories > with libraries in: Debug, Debug_static, Release and Release_static. So I > added "libexpat.lib" to Project->Settings->Link->Library modules, and the > path to this library in Tools->Options->Directories->Libraries. > So I think I am linking the static library, not the dll. > Is it right? > What else could be that external reference error due? > > Thank you very much again. > > Oriol > > > > ----- Original Message ----- > From: "Karl Waclawek" > To: "Oriol" ; > Sent: Thursday, November 21, 2002 7:58 PM > Subject: Re: [Expat-discuss] Trouble using static expat in MS VC 6 > > > > You may have linked to the Dll import library instead of the static > library. > > They have the same names, but should be in different Release directories. > > > > The upcoming version of Expat will have a different naming scheme, > > with the name post-fixed according to the version of the runtime > > library used (multi-threaded or not, etc.). By default it will > > build as libexpatMT.lib. > > > > Karl > > > > ----- Original Message ----- > > From: "Oriol" > > To: > > Sent: Thursday, November 21, 2002 1:40 PM > > Subject: [Expat-discuss] Trouble using static expat in MS VC 6 > > > > > > > > Hi, > > I've installed and successfully built expat 1.95.5 under Visual C 6. > > However, problems arise when I try to use it. > > I need to statically link the expat library to my program, but after a > successful compilation, > > the linker stops with this error: MyProgram.obj : "error LNK2001: > unresolved external symbol > > __imp__XML_ParserCreate" > > The library paths already include the directory where libexpat.lib > lives, so the problem is not > > a missing library. > > Furthermore I've declared the symbol XML_STATIC in > Resources->Preprocessor, but the problem > > still remains. > > Any idea? > > > > > > > > > > _______________________________________________ > Expat-discuss mailing list > Expat-discuss@libexpat.org > http://mail.libexpat.org/mailman/listinfo/expat-discuss > From omagrane@anthill.es Thu Nov 21 20:48:17 2002 From: omagrane@anthill.es (Oriol) Date: Thu, 21 Nov 2002 21:48:17 +0100 Subject: [Expat-discuss] Trouble using static expat in MS VC 6 References: <004f01c29199$e5a33f20$0201a8c0@amd> <004401c2919b$7d2bdc20$9e539696@citkwaclaww2k> Message-ID: <005e01c2919f$522cf1e0$0201a8c0@amd> Hello, again, Karl. My Link tab in Project->Settings does not show any "Additional Library Path field". I have "Category", a reset button, "Output file name", "Object/library modules", a few checkboxs and "Project Options". I suppose you mean the "Object/library modules" field. In the case of "elements" example, the "Object/library modules" field contains "odbccp32.lib libexpat.lib kernel32.lib user32.lib gdi32.lib..." etc, etc, etc. A lot of different libraries, although libexpat.lib is included. Additionally, in my project, I've renamed all the .dll files and .lib files to .bak except the libexpat.lib in "Debug_static\libexpat.lib", so it is the only libexpat library in the system. However when I try to compile my program the same error appears. Could it be an incompatibility with the default libraries? Why the "elements" example declares so many libraries? Oriol ----- Original Message ----- From: "Karl Waclawek" To: "Oriol" ; Sent: Thursday, November 21, 2002 9:20 PM Subject: Re: [Expat-discuss] Trouble using static expat in MS VC 6 > Check the "elements" example project in the Expat workspace. > It has a dependency on expat_static. Check the Link page > in the project settings. Does the Additional Library Path > field show something like ..\lib\Release_static ? > > Make sure that the libexpat.lib the linker finds is the right one. > If in doubt, rename all instances of libexpat.lib except for > the right one, and see what the linker reports. > > Karl > > ----- Original Message ----- > From: "Oriol" > To: > Sent: Thursday, November 21, 2002 3:09 PM > Subject: Re: [Expat-discuss] Trouble using static expat in MS VC 6 > > > > Hi, Karl! Thank you for your quick reply! > > After building expat-1.95.5 I obtained four different subdirectories > > with libraries in: Debug, Debug_static, Release and Release_static. So I > > added "libexpat.lib" to Project->Settings->Link->Library modules, and the > > path to this library in Tools->Options->Directories->Libraries. > > So I think I am linking the static library, not the dll. > > Is it right? > > What else could be that external reference error due? > > > > Thank you very much again. > > > > Oriol > > > > > > > > ----- Original Message ----- > > From: "Karl Waclawek" > > To: "Oriol" ; > > Sent: Thursday, November 21, 2002 7:58 PM > > Subject: Re: [Expat-discuss] Trouble using static expat in MS VC 6 > > > > > > > You may have linked to the Dll import library instead of the static > > library. > > > They have the same names, but should be in different Release directories. > > > > > > The upcoming version of Expat will have a different naming scheme, > > > with the name post-fixed according to the version of the runtime > > > library used (multi-threaded or not, etc.). By default it will > > > build as libexpatMT.lib. > > > > > > Karl > > > > > > ----- Original Message ----- > > > From: "Oriol" > > > To: > > > Sent: Thursday, November 21, 2002 1:40 PM > > > Subject: [Expat-discuss] Trouble using static expat in MS VC 6 > > > > > > > > > > > > Hi, > > > I've installed and successfully built expat 1.95.5 under Visual C 6. > > > However, problems arise when I try to use it. > > > I need to statically link the expat library to my program, but after a > > successful compilation, > > > the linker stops with this error: MyProgram.obj : "error LNK2001: > > unresolved external symbol > > > __imp__XML_ParserCreate" > > > The library paths already include the directory where libexpat.lib > > lives, so the problem is not > > > a missing library. > > > Furthermore I've declared the symbol XML_STATIC in > > Resources->Preprocessor, but the problem > > > still remains. > > > Any idea? > > > > > > > > > > > > > > > > > _______________________________________________ > > Expat-discuss mailing list > > Expat-discuss@libexpat.org > > http://mail.libexpat.org/mailman/listinfo/expat-discuss > > > From karl@waclawek.net Thu Nov 21 21:01:16 2002 From: karl@waclawek.net (Karl Waclawek) Date: Thu, 21 Nov 2002 16:01:16 -0500 Subject: [Expat-discuss] Trouble using static expat in MS VC 6 References: <004f01c29199$e5a33f20$0201a8c0@amd><004401c2919b$7d2bdc20$9e539696@citkwaclaww2k> <005e01c2919f$522cf1e0$0201a8c0@amd> Message-ID: <008301c291a1$21f7b800$9e539696@citkwaclaww2k> > Hello, again, Karl. > My Link tab in Project->Settings does not show any "Additional Library > Path field". I have "Category", a reset button, "Output file name", > "Object/library modules", a few checkboxs and "Project Options". > I suppose you mean the "Object/library modules" field. > In the case of "elements" example, the "Object/library modules" field > contains "odbccp32.lib libexpat.lib kernel32.lib user32.lib gdi32.lib..." > etc, etc, etc. On the same page (Category = Input) you should have the "Additional Library Path field". > A lot of different libraries, although libexpat.lib is included. > Additionally, in my project, I've renamed all the .dll files and .lib > files to .bak except the libexpat.lib in "Debug_static\libexpat.lib", so it > is the only libexpat library in the system. > However when I try to compile my program the same error appears. > Could it be an incompatibility with the default libraries? Why the > "elements" example declares so many libraries? Does the elements project compile for you? All I can tell you from here is: Try to duplicate as much from the elements project's settings as makes sense. Karl From dino@aiesec.pwr.wroc.pl Thu Nov 21 21:50:17 2002 From: dino@aiesec.pwr.wroc.pl (Marcin Zdun) Date: Thu, 21 Nov 2002 22:50:17 +0100 (CET) Subject: [Expat-discuss] Trouble using static expat in MS VC 6 In-Reply-To: <003001c2918d$79ce88b0$0201a8c0@amd> Message-ID: On Thu, 21 Nov 2002, Oriol wrote: > > Hi, > I've installed and successfully built expat 1.95.5 under Visual C 6. > However, problems arise when I try to use it. [...] >Furthermore I've declared the symbol XML_STATIC in For me, #defining _STATIC (without XML) works. Look into expat.h, line 21. If your copy doesn't check this symbol, ensure you have all symbols leading to "type __cdecl" version of XMLPARSEAPI(type). -- mz /************************************************ Hey, tell me the truth. Are we still in the Game? transCendeZ *************************************************/ From omagrane@anthill.es Thu Nov 21 22:02:52 2002 From: omagrane@anthill.es (Oriol) Date: Thu, 21 Nov 2002 23:02:52 +0100 Subject: [Expat-discuss] Trouble using static expat in MS VC 6 References: <004f01c29199$e5a33f20$0201a8c0@amd><004401c2919b$7d2bdc20$9e539696@citkwaclaww2k> <005e01c2919f$522cf1e0$0201a8c0@amd> <008301c291a1$21f7b800$9e539696@citkwaclaww2k> Message-ID: <006301c291a9$bde5f4e0$0201a8c0@amd> Problem found!!! I was linking statically MFC and expat did not like it. So changing the option in Project->Settings->General->Microsoft Foundation Classes to "Use MFC in a Shared DLL", it works. I don't know where's exactly the problem, so... does anybody know a way of linking MFC statically and still having expat working? Thank you! Oriol P.S. Thanks a lot, Karl, for your time. ----- Original Message ----- From: "Karl Waclawek" To: "Oriol" ; Sent: Thursday, November 21, 2002 10:01 PM Subject: Re: [Expat-discuss] Trouble using static expat in MS VC 6 > > > Hello, again, Karl. > > My Link tab in Project->Settings does not show any "Additional Library > > Path field". I have "Category", a reset button, "Output file name", > > "Object/library modules", a few checkboxs and "Project Options". > > I suppose you mean the "Object/library modules" field. > > In the case of "elements" example, the "Object/library modules" field > > contains "odbccp32.lib libexpat.lib kernel32.lib user32.lib gdi32.lib..." > > etc, etc, etc. > > On the same page (Category = Input) you should have the > "Additional Library Path field". > > > A lot of different libraries, although libexpat.lib is included. > > Additionally, in my project, I've renamed all the .dll files and .lib > > files to .bak except the libexpat.lib in "Debug_static\libexpat.lib", so it > > is the only libexpat library in the system. > > However when I try to compile my program the same error appears. > > Could it be an incompatibility with the default libraries? Why the > > "elements" example declares so many libraries? > > Does the elements project compile for you? > All I can tell you from here is: Try to duplicate as much from the > elements project's settings as makes sense. > > Karl > From karl@waclawek.net Thu Nov 21 22:12:42 2002 From: karl@waclawek.net (Karl Waclawek) Date: Thu, 21 Nov 2002 17:12:42 -0500 Subject: [Expat-discuss] Trouble using static expat in MS VC 6 References: <004f01c29199$e5a33f20$0201a8c0@amd><004401c2919b$7d2bdc20$9e539696@citkwaclaww2k><005e01c2919f$522cf1e0$0201a8c0@amd><008301c291a1$21f7b800$9e539696@citkwaclaww2k> <006301c291a9$bde5f4e0$0201a8c0@amd> Message-ID: <00e901c291ab$1cd23ad0$9e539696@citkwaclaww2k> > > Problem found!!! I was linking statically MFC and expat did not like it. > So changing the option in Project->Settings->General->Microsoft > Foundation Classes to "Use MFC in a Shared DLL", it works. > I don't know where's exactly the problem, so... does anybody know a way > of linking MFC statically and still having expat working? > > Thank you! > > Oriol > > P.S. Thanks a lot, Karl, for your time. You are welcome. :-) This may be related to the Shared MFC Dll issue: The next version will have instructions (..\Win32\ReadMe.txt) to build three different versions of the static lib, to match how the application is linked to the runtime library. I am not sure, but this may also have to match how MFC is linked in. Karl From karl@waclawek.net Thu Nov 21 22:14:01 2002 From: karl@waclawek.net (Karl Waclawek) Date: Thu, 21 Nov 2002 17:14:01 -0500 Subject: [Expat-discuss] Trouble using static expat in MS VC 6 References: Message-ID: <00ef01c291ab$4beacf30$9e539696@citkwaclaww2k> > On Thu, 21 Nov 2002, Oriol wrote: > > > > > Hi, > > I've installed and successfully built expat 1.95.5 under Visual C 6. > > However, problems arise when I try to use it. > [...] > >Furthermore I've declared the symbol XML_STATIC in > > For me, #defining _STATIC (without XML) works. Look into expat.h, line 21. > If your copy doesn't check this symbol, ensure you have all symbols > leading to "type __cdecl" version of XMLPARSEAPI(type). I forgot how it was in 1.95.5, but the current CVS requires XML_STATIC instead of _STATIC. Karl From karl@waclawek.net Sun Nov 24 13:54:45 2002 From: karl@waclawek.net (Karl Waclawek) Date: Sun, 24 Nov 2002 08:54:45 -0500 Subject: [Expat-discuss] Re: Expat - terminating the parser References: Message-ID: <001101c293c1$0c45d6f0$0207a8c0@karl> Hi Chaim, I have cc'ed this to the list - since others may have something to say on that topic too. > Thanks for your answer. > I'm using Expat from C++. If I throw an exception from a > callback, could it have any "undesirable" side effects > (e.g., memory leaks, undefined parser status)? In other > words, is Expat designed in a way that the user may safely > throw exceptions from handlers? I know the Expat code to a degree, and as far as I can tell, there are no situations where heap memory is allocated with only local variables referencing it before a handler is called. Therefore - IMO - calling XML_ParserFree should always work properly even when terminating through an exception. However, I have not studied every single handler call from that angle. I have tested this with Delphi (not C++) and there did not appear to be memory leaks because of that. There is one situation when an element declaration is reported, where the content model passed to the handler has to be freed by the handler. In that case you have to catch the exception in the handler, free the content model, and then re-throw the exception. Regards, Karl From omagrane@anthill.es Tue Nov 26 09:13:18 2002 From: omagrane@anthill.es (Oriol) Date: Tue, 26 Nov 2002 10:13:18 +0100 Subject: [Expat-discuss] Charset trouble Message-ID: <000801c2952c$10316f10$0201a8c0@amd> Hello! While parsing XML, expat always converts entity coded chars = ("&#code;") to unicode, regardless of the charset I specified in = XML_CreateParser (which is ISO-8859-1). So my application always shows = every coded char in XML as a two-char string. Does the parser always = encode to unicode? How can I solve it without compiling in unicode? Must = I use a unicode-to-ansi conversion function and pass every returned = string to it? Thank you! Oriol From karl@waclawek.net Tue Nov 26 14:03:03 2002 From: karl@waclawek.net (Karl Waclawek) Date: Tue, 26 Nov 2002 09:03:03 -0500 Subject: [Expat-discuss] Charset trouble References: <000801c2952c$10316f10$0201a8c0@amd> Message-ID: <000d01c29554$8971c000$9e539696@citkwaclaww2k> > While parsing XML, expat always converts entity coded chars ("&#code;") to unicode, > regardless of the charset I specified in XML_CreateParser (which is ISO-8859-1). That specifies just the input encoding. Expat will always output Unicode (UTF-8 or UTF-16). > So my application always shows every coded char in XML as a two-char string. > Does the parser always encode to unicode? How can I solve it without compiling in unicode? > Must I use a unicode-to-ansi conversion function and pass every returned string to it? I don't think the XML specs allow anything else but Unicode for output. The best approach would be to make your whole application use Unicode internally (and maybe even externally). Karl From xcross@us.ibm.com Tue Nov 26 14:29:00 2002 From: xcross@us.ibm.com (Chris Cross) Date: Tue, 26 Nov 2002 09:29:00 -0500 Subject: [Expat-discuss] building validation on top of expat Message-ID: I've read this here several times, that validation can be built on top of Expat. For the relative newbie, how would you do this? What's the general approach? thanks, chris Karl Waclawek karl@waclawek.net Fri, 4 Oct 2002 00:34:53 -0400 > As described in the document of 1.95.5, there is a new function XML_UseForeignDTD added. > I am not sure what this function is used for exactly. If the XML document does not specify an external DTD, setting this flag will make Expat request an external DTD anyway, thus allowing you to supply a DTD of your choice. > But my question is that is the new version of Expat a validating parser? No, and there are no plans to make it one. Validation can be built on top of Expat, however. Karl From jpeixoto@quidgest.pt Wed Nov 27 19:53:28 2002 From: jpeixoto@quidgest.pt (=?iso-8859-1?Q?Jo=E3o_Peixoto?=) Date: Wed, 27 Nov 2002 19:53:28 -0000 Subject: [Expat-discuss] Special characters parsing Message-ID: <000701c2964e$a8ecc560$0600a8c0@quidgest.pt> Hi, =20 I=92m new using Expat code, so I think this list was the best tool form = my knowledge. My proble is simple: When I=92m parsing a XML doc without special characters from my country (Portuguese), it works fine, but otherwise it doesn,t parse. =20 By debug I saw that the problem stays on INVALID_CASES call. =20 Can anybody solves my problem, please? =20 regards: Jo=E3o Peixoto =20 Software Engineer www.quidgest.pt =20 From fdrake@acm.org Wed Nov 27 19:59:30 2002 From: fdrake@acm.org (Fred L. Drake, Jr.) Date: Wed, 27 Nov 2002 14:59:30 -0500 Subject: [Expat-discuss] Special characters parsing In-Reply-To: <000701c2964e$a8ecc560$0600a8c0@quidgest.pt> References: <000701c2964e$a8ecc560$0600a8c0@quidgest.pt> Message-ID: <15845.9250.67190.151342@grendel.zope.com> Jo=E3o Peixoto writes: > I'm new using Expat code, so I think this list was the best tool for= m my > knowledge. My proble is simple: When I'm parsing a XML doc without > special characters from my country (Portuguese), it works fine, but > otherwise it doesn,t parse. Jo=E3o, Have you checked that your document is encoded in an encoding that Expat supports? If it is not in utf-16 or utf-8, your document will need to include an XML Declaration that specified the document encoding. -Fred --=20 Fred L. Drake, Jr. PythonLabs at Zope Corporation From carlos@pehoe.civil.ist.utl.pt Sat Nov 30 21:31:01 2002 From: carlos@pehoe.civil.ist.utl.pt (Carlos Pereira) Date: Sat, 30 Nov 2002 21:31:01 GMT Subject: [Expat-discuss] clarification Message-ID: <200211302131.gAULV1805656@pehoe.civil.ist.utl.pt> According to Simon St. Laurent, XML Elements of Style, these declarations should both be valid: but at least to me Expat seems to require the version="1.0" attribute, as for example, this is accepted: Is Simon wrong? Did the XML specification change? Could someone comment on this? Carlos