From karl at waclawek.net Sat Aug 2 20:27:57 2003 From: karl at waclawek.net (Karl Waclawek) Date: Sat Aug 2 19:26:10 2003 Subject: [Expat-discuss] Reading DTDs References: <000801c3548d$6be900e0$6101a8c0@funkytown> Message-ID: <01a001c3594d$b4c50330$0207a8c0@karl> > and then in main: > XML_SetElementDeclHandler(parser, DTDElements); > problem is that now the program does absolutely nothing. Do errors are generated. > The program ends and it doesn't look like any events are generated. > Any ideas? There should be a setting that turns parameter entity parsing on. Explained in the docs. Karl From brent at psislidell.com Tue Aug 5 10:25:03 2003 From: brent at psislidell.com (Brent Bartels) Date: Tue Aug 5 10:24:04 2003 Subject: [Expat-discuss] DTD Parsing - (Opps forgot the attachment) Message-ID: <3F2FBE3F.108@psislidell.com> Thanks for your reply. Your correct there is such a setting that is explained in the docs. I forgot to include that with my pseudo code. I'll send a short sample of what I'm talking about as an attachment (since I can't get the formating right in Netscape). I have a feeling this has something to do with the ExternalEntityRef handler but the documentation on this is a little thin. A good example would help. Just getting an explanation on the list would be a step in the right direction. :-) Thanks again, Brent Karl Waclawek wrote: >>and then in main: >> > >>XML_SetElementDeclHandler(parser, DTDElements); >> > >>problem is that now the program does absolutely nothing. Do errors are generated. > The program >> >ends and it doesn't look like any events are generated. > >>Any ideas? >> > >There should be a setting that turns parameter entity parsing on. >Explained in the docs. > >Karl > > >_______________________________________________ >Expat-discuss mailing list >Expat-discuss@libexpat.org >http://mail.libexpat.org/mailman/listinfo/expat-discuss > -------------- next part -------------- #include #include "expat.h" static void DTDElements(void *userData, const XML_Char *name, XML_Content *model) { printf("Element Name: %s\n", model->name); printf("Number of Children: %d\n", model->numchildren); } int main(int argc, char *argv[]) { char buf[BUFSIZ]; XML_Parser parser = XML_ParserCreate(NULL); int done; int depth = 0; XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS); XML_SetUserData(parser, &depth); XML_SetElementDeclHandler(parser, DTDElements); do { size_t len = fread(buf, 1, sizeof(buf), stdin); done = len < sizeof(buf); if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR) { fprintf(stderr, "%s at line %d\n", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser)); return 1; } } while (!done); XML_ParserFree(parser); return 0; } From karl at waclawek.net Tue Aug 5 13:29:24 2003 From: karl at waclawek.net (Karl Waclawek) Date: Tue Aug 5 12:27:30 2003 Subject: [Expat-discuss] DTD Parsing - (Opps forgot the attachment) References: <3F2FBE3F.108@psislidell.com> Message-ID: <001a01c35b6e$bb5fe520$0207a8c0@karl> > Thanks for your reply. Your correct there is such a setting that is > explained in the docs. I forgot to include that with my pseudo code. > I'll send a short sample of what I'm talking about as an attachment > (since I can't get the formating right in Netscape). I have a feeling > this has something to do with the ExternalEntityRef handler but the > documentation on this is a little thin. A good example would help. > Just getting an explanation on the list would be a step in the right > direction. :-) Depends on your XML document. If all your DTD declarations are in the internal subset, then your code should work, after having a brief look. Best example to study is xmlwf, since it implements an ExternalEntityRef handler, AFAIK. All external entities need to be parsed within an ExternalEntityRef handler, using a parser instance created with XML_ExternalEntityParserCreate(). Karl From brent at psislidell.com Tue Aug 5 13:04:31 2003 From: brent at psislidell.com (Brent Bartels) Date: Tue Aug 5 13:03:30 2003 Subject: [Expat-discuss] DTD Parsing - (Opps forgot the attachment) References: <3F2FBE3F.108@psislidell.com> <001a01c35b6e$bb5fe520$0207a8c0@karl> Message-ID: <3F2FE39F.3060506@psislidell.com> Thanks Karl. I had tried making the DTD internal before but apparently with the wrong code. Ideally though I'd like to do this with external DTDs, I'll start working on that soon. Brent Karl Waclawek wrote: >>Thanks for your reply. Your correct there is such a setting that is >>explained in the docs. I forgot to include that with my pseudo code. >> I'll send a short sample of what I'm talking about as an attachment >>(since I can't get the formating right in Netscape). I have a feeling >>this has something to do with the ExternalEntityRef handler but the >>documentation on this is a little thin. A good example would help. >> Just getting an explanation on the list would be a step in the right >>direction. :-) >> > >Depends on your XML document. If all your DTD declarations >are in the internal subset, then your code should work, >after having a brief look. > >Best example to study is xmlwf, since it implements an ExternalEntityRef >handler, AFAIK. All external entities need to be parsed within >an ExternalEntityRef handler, using a parser instance created with >XML_ExternalEntityParserCreate(). > >Karl > >_______________________________________________ >Expat-discuss mailing list >Expat-discuss@libexpat.org >http://mail.libexpat.org/mailman/listinfo/expat-discuss > From lphiri at nc.rr.com Wed Aug 6 21:33:43 2003 From: lphiri at nc.rr.com (Lindani Phiri) Date: Wed Aug 6 20:32:39 2003 Subject: [Expat-discuss] Any known Memory fragmentation issues with Expat? In-Reply-To: References: Message-ID: <3F319E67.1000404@nc.rr.com> I am considering usiing expat on a real time system with zero tolerence for memory fragmentation (expected to run 24/7/365). My app runs on VxWorks platform and we have had problems malloc and realloc functions before. Are there any known issues with Expat with regards to memory fragmentation? I have noticed that Expat allows one to specify a Memory Allocation suites. What are the design considerations when designing these? Thanks, L. From fdrake at acm.org Thu Aug 7 01:54:01 2003 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu Aug 7 00:54:43 2003 Subject: [Expat-discuss] Any known Memory fragmentation issues with Expat? In-Reply-To: <3F319E67.1000404@nc.rr.com> References: <3F319E67.1000404@nc.rr.com> Message-ID: <16177.56169.791192.677731@grendel.zope.com> Lindani Phiri writes: > I am considering usiing expat on a real time system with zero tolerence > for memory fragmentation > (expected to run 24/7/365). > My app runs on VxWorks platform and we have had problems malloc and > realloc functions before. > > Are there any known issues with Expat with regards to memory fragmentation? I don't know that anyone has looked into this issue. > I have noticed that Expat allows one to specify a Memory Allocation > suites. What are > the design considerations when designing these? As far as Expat is concerned, the set of functions passed for this must behave the same way that the API for malloc/realloc/free behave. Expat does not provide a way to associate state with these functions, so any internal state they maintain is global. The functions can implement any allocation policy they need to; an arena-based policy would be very reasonable, and could help deal with fragmentation in small-memory systems. By default, the malloc/realloc/free functions linked with the application are used, so an application can control the allocator at that level if desired. A more flexible interface is likely to be provided in Expat 3 (sorry, no ETA). -Fred -- Fred L. Drake, Jr. PythonLabs at Zope Corporation From toni.uusitalo at luukku.com Thu Aug 14 02:50:54 2003 From: toni.uusitalo at luukku.com (Toni Uusitalo) Date: Thu Aug 14 08:14:03 2003 Subject: [Expat-discuss] regression tests (runtests.c) as xml files Message-ID: <5.2.0.9.0.20030814014719.00c165b8@pop-112.luukku.com> Hi, Are expat check testcases (in runtests.c) available as xml files somewhere? TIA From smesser at xmission.com Thu Aug 14 16:09:24 2003 From: smesser at xmission.com (Steve Messer) Date: Thu Aug 14 17:07:05 2003 Subject: [Expat-discuss] Beginner question Message-ID: <000501c362a8$59e0ac30$0400a8c0@neon> Hi all, I am new to XML parsing and I am trying to find out how to use the @#!~ beast. I have looked everywhere (except the right spot) for examples on using the expat parser. I don't need another example on how to make an outline .. . how to list the elements... Where is an example that actually does something like retrieving the different types of data? Like int, float, string etc. Maybe I am just dense but all the examples seem to show the obvious stuff. Thanks, Steve From dr at netscape.com Thu Aug 14 15:17:34 2003 From: dr at netscape.com (Dan Rosen) Date: Thu Aug 14 17:22:49 2003 Subject: [Expat-discuss] Beginner question In-Reply-To: <000501c362a8$59e0ac30$0400a8c0@neon> References: <000501c362a8$59e0ac30$0400a8c0@neon> Message-ID: <3F3BFC6E.2000204@netscape.com> Hi Steve, The thing you have to understand about XML (at least at the level Expat is concerned with) is that there are no real "data types" per se. XML has no concept of int, float or string; for the most part, it's all just text data. It's entirely up to your application to intepret that text. So, for example, say you have some XML data looking like: ... And you want to get the total price of the items on your shopping cart. You'd have an element handler that converts the price attribute value to a float (using sprintf or whatever) and adds that value to a variable holding the running total. Make sense? Cheers, dr Steve Messer wrote: > Hi all, > > I am new to XML parsing and I am trying to find out how to use the @#!~ > beast. > > I have looked everywhere (except the right spot) for examples on using > the expat parser. > > I don't need another example on how to make an outline .. . how to list > the elements... > Where is an example that actually does something like retrieving the > different types of data? > > Like int, float, string etc. > > Maybe I am just dense but all the examples seem to show the obvious > stuff. > > Thanks, > > Steve > _______________________________________________ > Expat-discuss mailing list > Expat-discuss@libexpat.org > http://mail.libexpat.org/mailman/listinfo/expat-discuss From smesser at xmission.com Thu Aug 14 22:07:19 2003 From: smesser at xmission.com (Steve Messer) Date: Thu Aug 14 23:05:22 2003 Subject: [Expat-discuss] Beginner Question Message-ID: <000201c362da$5a13de70$0400a8c0@neon> Hey dr, First, thanks for your response. I realize that at the expat level there is no data types. The example you gave is one of the forms I tend to see a lot. Pants and price are just attributes of name. But what if you have something like this the following: en_US
MEDIUM
F mi mph in in While parsing I know when I have found the element ut for example. Having found the tag in the startElement(void *userData, const char *name, const char **atts) function how do I get the value F? In the startelement handler I have the following code. What I don't under stand is where is the data "F" in the above given example? if(strcmp( el, "ut" ) == 0 ) { printf(" found %s", el); printf("\n"); } Maybe I am missing the use of a handler or something simple. Sorry if this is a stupid question. Thanks, Steve From k.buckley at lancaster.ac.uk Fri Aug 15 11:16:21 2003 From: k.buckley at lancaster.ac.uk (Kev Buckley) Date: Fri Aug 15 14:25:31 2003 Subject: [Expat-discuss] Re: Beginner Question In-Reply-To: <000201c362da$5a13de70$0400a8c0@neon> from "Steve Messer" at Aug 14, 2003 09:07:19 PM Message-ID: Hi. As well as the start and end handlers for a pair of tags, you need to specify a char handler for the text (data ?) in between tags. Presumably, your start handler would have tracked the fact that you are in the "chain" ... at the point that the char handler returns the string "F" to your application. You then extract the string with the char handler and, because you've kept track of where you are, you store it wherever it should go. The examples in the Expat source tarball detail this. The docs make it even clearer as you get to see just how many handlers there are ! Kevin > Pants and price are just attributes of name. But what if you have > something like this the following: > > > en_US >
MEDIUM
> F > mi > mph > in > in > > > While parsing I know when I have found the element ut for example. > > Having found the tag in the > startElement(void *userData, const char *name, const char **atts) > function how do I get the value F? > > > In the startelement handler I have the following code. What I don't > under stand is where is the data "F" in the above given example? > > if(strcmp( el, "ut" ) == 0 ) > { > printf(" found %s", el); > printf("\n"); > } > > Maybe I am missing the use of a handler or something simple. > > Sorry if this is a stupid question. > > Thanks, > > Steve > > _______________________________________________ > Expat-discuss mailing list > Expat-discuss@libexpat.org > http://mail.libexpat.org/mailman/listinfo/expat-discuss > -- Regards, ---------------------------------------------------------------------- * Kevin M. Buckley e-mail: K.Buckley@lancaster.ac.uk * * * * Systems Administrator * * Computer Centre * * Lancaster University Voice: +44 (0) 1524 5 93718 * * LANCASTER. LA1 4YW Fax : +44 (0) 1524 5 25113 * * England. * * * * My PC runs Linux/GNU, you still computing the Bill Gate$' way ? * ---------------------------------------------------------------------- From dr at netscape.com Fri Aug 15 12:51:26 2003 From: dr at netscape.com (Dan Rosen) Date: Fri Aug 15 14:56:40 2003 Subject: [Expat-discuss] Beginner Question In-Reply-To: <000201c362da$5a13de70$0400a8c0@neon> References: <000201c362da$5a13de70$0400a8c0@neon> Message-ID: <3F3D2BAE.8070608@netscape.com> Hi Steve, I see what you're asking. The general question here is, how do you get at the content (rather than attributes) of a specific element? First of all, remember that the parser looks at all the data sequentially, so all your callbacks will be invoked sequentially. Given a document containing just: bar ... you'll get three callbacks: one for the the start of the "foo" element, one for the "bar" character data, and one for the end of the "foo" element. Point being, when the "foo" start-element handler is invoked, the "bar" text hasn't been seen yet. To put it simply, you need to register a separate character data handler (see XML_SetCharacterDataHandler, etc.). Secondly, if you want to handle text data specific to a given element, your callback code has to contain some state -- otherwise, when you're in the context of a character data handler, you have no idea what element the character data belongs to. One possible implementation would be that you maintain a stack of tag names: in every start-element handler, you push your current tag name to the stack, and in every end-element handler, you pop from the stack. This way, your character data handler can examine the top element of the stack to determine what it should do with the text. That's one possible implementation ... I can think of other, more object-oriented ways of maintaining parse state, but this will do in a pinch. I think the fundamental thing you were missing was just a bit of the parsing model -- given that knowledge, you can implement this however is most appropriate. Hope this helps, dr Steve Messer wrote: > Pants and price are just attributes of name. But what if you have > something like this the following: > > > en_US >
MEDIUM
> F > mi > mph > in > in > > > While parsing I know when I have found the element ut for example. > > Having found the tag in the > startElement(void *userData, const char *name, const char **atts) > function how do I get the value F? From tim.crook at adobe.com Mon Aug 18 11:04:30 2003 From: tim.crook at adobe.com (Tim Crook) Date: Mon Aug 18 10:11:07 2003 Subject: [Expat-discuss] Parser that uses Expat "stops working" in Win32/MFC program... Message-ID: <311000B0752ED211B61700805F0D6B0903F160D6@ottmail3.accelio.com> This is a bit vague. One thing you might consider is that when using extern "C" callbacks with Visual Studio 6 is that it is not a good idea to construct C++ variables in your extern "C" code, even on the stack, as destructors are not called when an exception is thrown (this is a bug). What you should do is call a C++ method and instantiate the C++ variables there. Your MFC code might be throwing exceptions which maybe putting things out of whack. -----Original Message----- From: expat-discuss-request@libexpat.org [mailto:expat-discuss-request@libexpat.org] Sent: Thursday, July 24, 2003 12:00 PM To: expat-discuss@libexpat.org Subject: Expat-discuss Digest, Vol 40, Issue 11 Send Expat-discuss mailing list submissions to expat-discuss@libexpat.org To subscribe or unsubscribe via the World Wide Web, visit http://mail.libexpat.org/mailman/listinfo/expat-discuss or, via email, send a message with subject or body 'help' to expat-discuss-request@libexpat.org You can reach the person managing the list at expat-discuss-owner@libexpat.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Expat-discuss digest..." Today's Topics: 1. Parser that uses Expat "stops working" in Win32/MFC program? (warren henning) ---------------------------------------------------------------------- Message: 1 Date: Wed, 23 Jul 2003 17:18:56 +0000 From: "warren henning" Subject: [Expat-discuss] Parser that uses Expat "stops working" in Win32/MFC program? To: expat-discuss@libexpat.org Message-ID: Content-Type: text/plain; format=flowed I wrote a program which uses the Expat parser in C to run in a console (DOS) environment. I changed that code around a little bit so that I could call the important functions from other parts of my Windows program (I'm using Visual C++ 6 SP5). Basically what happens is a function that my program calls does all the Expat-based parsing and returns a data structure with all the information my program needs. To call the function you don't have to know how Expat works (that was kind of the point). But the parser seems to not be filling out the fields of the data structure. The same code worked under DOS just fine, even when I adapted it so that a test file with a short main() function just called the function in the code I wrote to do all the parsing. Now I figured problems might arise from trying to use C code with C++, but (the filenames for my code are rss_process.c and rss_process.h) as long as I include 'extern C { #include "rss_process.h"' in the C++ file that wants to call the C functions it seems to work fine. I added debugging statements to the important functions in my parser's code (the start() and end() callback functions that are provided to Expat) -- essentially they output data to a file. I added statements to simply output "in function (whatever)" to see if the functions were even called and apparently they aren't because the statements that should have appeared in the output file are non-existent. What could cause working code (the parser code was working fine under DOS) to break under Win32/MFC/C++ environment? I've been trying to get this to work for a few days and I'm pretty much stumped. If anyone wants to see the actual code I can put it on the Internet. Thanks in advance! -Warren _________________________________________________________________ Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail ------------------------------ _______________________________________________ Expat-discuss mailing list Expat-discuss@libexpat.org http://mail.libexpat.org/mailman/listinfo/expat-discuss End of Expat-discuss Digest, Vol 40, Issue 11 ********************************************* From smesser at xmission.com Mon Aug 18 13:23:36 2003 From: smesser at xmission.com (Steve Messer) Date: Mon Aug 18 14:21:21 2003 Subject: [Expat-discuss] Tracking position in the chain Message-ID: <000001c365b5$d9dd49b0$0400a8c0@neon> Hi, I am having trouble tracking my position in the chain. I have tried using a stack and the depth to track where I am at. What is a good technique for tracking the current position? Thanks, Steve > As well as the start and end handlers for a pair of tags, you need to specify a char handler for the text (data ?) in between tags. > Presumably, your start handler would have tracked the fact that you are in the "chain" > ... > at the point that the char handler returns the string "F" to your application. You then extract the string with the char handler and, because you've kept > track of where you are, you store it wherever it should go. From sachin at cse.iitb.ac.in Tue Aug 19 19:49:27 2003 From: sachin at cse.iitb.ac.in (Sachin Patil) Date: Tue Aug 19 09:21:17 2003 Subject: [Expat-discuss] Help needed Message-ID: Hi people I just wanted to know if it was possible to return a value using the function startElement (by default it is sat to void).Could someone suggest a way to get around this.I want this function to return a string to be used further in my program. Thanks a lot Sachin Patil From esilva at mobicomp.com Mon Aug 25 12:57:29 2003 From: esilva at mobicomp.com (Ernesto Silva) Date: Mon Aug 25 06:57:37 2003 Subject: [Expat-discuss] Expat for symbian OS 6.1 Message-ID: <002401c36af7$adff1e30$bd00a8c0@EmpS> Hello everyone, I'm working in a project for symbian 6.1 and i'm trying to port expat to this platform, but i'm having some problems. After some searchs in google i found one ported version (www.simkin.co.uk), the problem is when i try to include it in my project i get the error "..\..\..\Symbian\6.1\Series60\EPOC32\RELEASE\ARMI\UREL\EXPAT.DLL: file not recognized: File format not recognized", why? is this version for symbian 7.0 only? dows anyone knows the problem or another version that works on symbian 6.1? All the help will be appreciated, thanks Ernesto Silva From alleigh at mac.com Fri Aug 29 03:11:48 2003 From: alleigh at mac.com (Alan Leigh) Date: Thu Aug 28 12:17:33 2003 Subject: [Expat-discuss] [Beginner] UTF-8 / UTF-16 Question Message-ID: <537E87CB-D972-11D7-AD8D-0003938F4B34@mac.com> Hi all, I'm using another library which assumes anything that is a char* is ASCII, and anything that's wchar_t* is unicode. Anyway.. expat is doing its job very nicely, and so is the other library I think but I can't get them to cooperate. I installed expat using the default encoding (UTF-8), but since my other library thinks char* are ascii, that doesn't seem to work. I went back and built the other library, libexpatw, and I link with that, but I still get the XML_Char being a char. The other option I suppose, can I just 'promote' a char* to a wchar_t* - does this make sense if the char* is UTF 8?? Anyone? A suggestion would be greatly appreciated! Alan From lspenard at immersion.com Thu Aug 28 14:43:53 2003 From: lspenard at immersion.com (Luc Spenard) Date: Thu Aug 28 13:43:27 2003 Subject: [Expat-discuss] Using expat with domc Message-ID: <200D3BAC3B6A8E478CC72B132478BEDC06287C@astromd.immersion.com> Hi, I use both libs to manipulate XML files. When you save with domc, it creates a XML file with no indentation (all linear data). Do you know a tool I can use to parse the output file to add indentation? Thanks! Luc