From karl at waclawek.net Tue Aug 1 15:26:47 2006
From: karl at waclawek.net (Karl Waclawek)
Date: Tue, 01 Aug 2006 09:26:47 -0400
Subject: [Expat-discuss] Expat and JavaScript
In-Reply-To: <44CBC262.8050503@gmail.com>
References: <44CBC262.8050503@gmail.com>
Message-ID: <44CF5697.8050708@waclawek.net>
Franky Braem wrote:
> I'm porting expat to JavaScript (using SpiderMonkey, see my wxJS
> project). The application is in Unicode.
> I have the following problem:
>
> When I pass a normal JavaScript string (SpiderMonkey uses UTF-16) to a
> 'print' method I don't have to do any conversions to write the data to
> stdout.
> When I use a string generated by expat (it is build in UNICODE and
> creates data in UTF-16) I have to do a conversion before I can send the
> string to the 'print' method.
> When I look at the expat string in debug mode, I see all weird Chinese
> characters. When I debug the normal JavaScript string, I see normal text.
> Is there a conversion needed between SpiderMonkey and Expat?
>
> Maybe this JavaScript code makes some things clearer:
>
> p.parse('child', true);
> if ( p.currentElement.name == "tag1")
> {
> wxJS.print("Ok");
> }
> else
> {
> wxJS.print("Not ok");
> }
> wxJS.print(p.currentElement.name);
>
> The comparison always fails (all though the parsing in expat went fine)
>
>
How does p.currentElement.name get its value from Expat?
Karl
From franky.braem at gmail.com Tue Aug 1 19:43:33 2006
From: franky.braem at gmail.com (Franky Braem)
Date: Tue, 01 Aug 2006 19:43:33 +0200
Subject: [Expat-discuss] Expat and JavaScript
In-Reply-To: <44CF5697.8050708@waclawek.net>
References: <44CBC262.8050503@gmail.com> <44CF5697.8050708@waclawek.net>
Message-ID: <44CF92C5.6070204@gmail.com>
Karl Waclawek wrote:
> Franky Braem wrote:
>
>> I'm porting expat to JavaScript (using SpiderMonkey, see my wxJS
>> project). The application is in Unicode.
>> I have the following problem:
>>
>> When I pass a normal JavaScript string (SpiderMonkey uses UTF-16) to a
>> 'print' method I don't have to do any conversions to write the data to
>> stdout.
>> When I use a string generated by expat (it is build in UNICODE and
>> creates data in UTF-16) I have to do a conversion before I can send the
>> string to the 'print' method.
>> When I look at the expat string in debug mode, I see all weird Chinese
>> characters. When I debug the normal JavaScript string, I see normal text.
>> Is there a conversion needed between SpiderMonkey and Expat?
>>
>> Maybe this JavaScript code makes some things clearer:
>>
>> p.parse('child', true);
>> if ( p.currentElement.name == "tag1")
>> {
>> wxJS.print("Ok");
>> }
>> else
>> {
>> wxJS.print("Not ok");
>> }
>> wxJS.print(p.currentElement.name);
>>
>> The comparison always fails (all though the parsing in expat went fine)
>>
>>
>>
>
> How does p.currentElement.name get its value from Expat
This is how it is done:
void XMLParser::StartElementHandler(void *userData,
const XML_Char *name,
const XML_Char **atts)
{
wxMBConvUTF16 conv;
XMLParser *parser = (XMLParser*) userData;
wxString element(name, conv);
...
jsval rval;
jsval argv[] =
{
JS_NewUCStringCopyN(cx, (jschar *) element.c_str(),
element.length()));
OBJECT_TO_JSVAL(objAttr)
};
wxJS_CallFunctionProperty(parser->m_cx, parser->m_obj, "onStartElement",
2, argv, &rval);
}
the element name is passed to the onStartElement function. And that's a
JavaScript function that sets the current element.
When I do the following conversion. It seems to work:
wxCharBuffer s = conv.cWC2MB(element);
wxWCharBuffer t = wxConvCurrent->cMB2WC(s);
element = t;
The full Javascript code:
// Constructor for a XMLElement object
function XMLElement(parent, name, attrs)
{
this.parent = parent;
if ( parent != null )
parent.elements[parent.elements.length + 1] = this;
this.name = name;
this.attrs = attrs;
this.elements = new Array();
}
var p = new XMLParser();
p.currentElement = null;
p.onStartElement = function(element, attrs)
{
currentElement = new XMLElement(currentElement, element, attrs);
}
p.onEndElement = function(element)
{
if ( currentElement.parent != null )
currentElement = currentElement.parent;
}
p.onCharacter = function(data)
{
currentElement.data = data;
}
p.parse('child', true);
if ( p.currentElement.name == "tag1")
{
wxJS.print("Ok");
}
else
{
wxJS.print("Not ok");
}
wxJS.print(p.currentElement.name);
// p.currentElement points to the root tag now(tag1)
From karl at waclawek.net Wed Aug 2 19:05:07 2006
From: karl at waclawek.net (Karl Waclawek)
Date: Wed, 02 Aug 2006 13:05:07 -0400
Subject: [Expat-discuss] Expat and JavaScript
In-Reply-To: <44CF92C5.6070204@gmail.com>
References: <44CBC262.8050503@gmail.com> <44CF5697.8050708@waclawek.net>
<44CF92C5.6070204@gmail.com>
Message-ID: <44D0DB43.6090804@waclawek.net>
Franky Braem wrote:
>>
>> How does p.currentElement.name get its value from Expat
> This is how it is done:
>
> void XMLParser::StartElementHandler(void *userData,
> const XML_Char *name,
> const XML_Char **atts)
> {
> wxMBConvUTF16 conv;
> XMLParser *parser = (XMLParser*) userData;
>
> wxString element(name, conv);
>
> ...
>
> jsval rval;
> jsval argv[] =
> {
> JS_NewUCStringCopyN(cx, (jschar *) element.c_str(),
> element.length()));
> OBJECT_TO_JSVAL(objAttr)
> };
>
> wxJS_CallFunctionProperty(parser->m_cx, parser->m_obj,
> "onStartElement",
> 2, argv, &rval);
> }
I know nothing about the wx API, but it seems that maybe you are calling the
wxstring constructor with the wrong arguments. "name" is already in
UTF-16 encoding,
so why pass an instance of wxMBConvUTF16 (Google indicates this is used
for converting
from UTF-8 to UTF-16)?
Karl
From franky.braem at gmail.com Wed Aug 2 19:34:08 2006
From: franky.braem at gmail.com (Franky Braem)
Date: Wed, 02 Aug 2006 19:34:08 +0200
Subject: [Expat-discuss] Expat and JavaScript
In-Reply-To: <44D0DB43.6090804@waclawek.net>
References: <44CBC262.8050503@gmail.com> <44CF5697.8050708@waclawek.net>
<44CF92C5.6070204@gmail.com> <44D0DB43.6090804@waclawek.net>
Message-ID: <44D0E210.4040606@gmail.com>
Karl Waclawek wrote:
>
> I know nothing about the wx API, but it seems that maybe you are
> calling the
> wxstring constructor with the wrong arguments. "name" is already in
> UTF-16 encoding,
> so why pass an instance of wxMBConvUTF16 (Google indicates this is
> used for converting
> from UTF-8 to UTF-16)?
>
Actually the passed encoding is not used, because wxJS uses wxWidgets in
unicode. As stated in the wxWidgets manual:
*
-------------------------
wxString*(*const wchar_t**/ psz/, *wxMBConv
&*/
conv/, *size_t*/ nLength = wxSTRING_MAXLEN/)
Initializes the string from first /nLength/ characters of wide string.
The default value of wxSTRING_MAXLEN means take all the string. In ANSI
build, /conv/'s WC2MB
method is called to convert /psz/ to wide string. It is ignored in
Unicode build.
---------------------
The weird characters already shows up in the XML_Char argument of the
StartElementHandler
Franky.
From karl at waclawek.net Thu Aug 3 16:08:01 2006
From: karl at waclawek.net (Karl Waclawek)
Date: Thu, 03 Aug 2006 10:08:01 -0400
Subject: [Expat-discuss] Expat and JavaScript
In-Reply-To: <44D0E210.4040606@gmail.com>
References: <44CBC262.8050503@gmail.com> <44CF5697.8050708@waclawek.net>
<44CF92C5.6070204@gmail.com> <44D0DB43.6090804@waclawek.net>
<44D0E210.4040606@gmail.com>
Message-ID: <44D20341.6040701@waclawek.net>
Franky Braem wrote:
> Karl Waclawek wrote:
>>
>> I know nothing about the wx API, but it seems that maybe you are
>> calling the
>> wxstring constructor with the wrong arguments. "name" is already in
>> UTF-16 encoding,
>> so why pass an instance of wxMBConvUTF16 (Google indicates this is
>> used for converting
>> from UTF-8 to UTF-16)?
>>
> Actually the passed encoding is not used, because wxJS uses wxWidgets
> in unicode. As stated in the wxWidgets manual:
Are you sure that on your platform wchar_t is 2 bytes wide?
Karl
From franky.braem at gmail.com Sat Aug 5 19:40:05 2006
From: franky.braem at gmail.com (Franky Braem)
Date: Sat, 05 Aug 2006 19:40:05 +0200
Subject: [Expat-discuss] Expat and JavaScript
In-Reply-To: <44D20341.6040701@waclawek.net>
References: <44CBC262.8050503@gmail.com> <44CF5697.8050708@waclawek.net>
<44CF92C5.6070204@gmail.com> <44D0DB43.6090804@waclawek.net>
<44D0E210.4040606@gmail.com> <44D20341.6040701@waclawek.net>
Message-ID: <44D4D7F5.60407@gmail.com>
Karl Waclawek wrote:
> Franky Braem wrote:
>> Karl Waclawek wrote:
>>>
>>> I know nothing about the wx API, but it seems that maybe you are
>>> calling the
>>> wxstring constructor with the wrong arguments. "name" is already in
>>> UTF-16 encoding,
>>> so why pass an instance of wxMBConvUTF16 (Google indicates this is
>>> used for converting
>>> from UTF-8 to UTF-16)?
>>>
>> Actually the passed encoding is not used, because wxJS uses wxWidgets
>> in unicode. As stated in the wxWidgets manual:
> Are you sure that on your platform wchar_t is 2 bytes wide?
>
> Karl
>
wchar_t is 2 bytes.
From karl at waclawek.net Sun Aug 6 00:22:06 2006
From: karl at waclawek.net (Karl Waclawek)
Date: Sat, 05 Aug 2006 18:22:06 -0400
Subject: [Expat-discuss] Expat and JavaScript
In-Reply-To: <44D4D7F5.60407@gmail.com>
References: <44CBC262.8050503@gmail.com> <44CF5697.8050708@waclawek.net>
<44CF92C5.6070204@gmail.com> <44D0DB43.6090804@waclawek.net>
<44D0E210.4040606@gmail.com> <44D20341.6040701@waclawek.net>
<44D4D7F5.60407@gmail.com>
Message-ID: <44D51A0E.4030608@waclawek.net>
Franky Braem wrote:
>> Are you sure that on your platform wchar_t is 2 bytes wide?
>>
>> Karl
>>
> wchar_t is 2 bytes.
>
In that case I am afraid I have no idea what's wrong. UTF-16 output
from Expat
has been working for me for a long time (I think since 1.95.3).
Karl
From chandu_ns at yahoo.com Mon Aug 7 13:07:44 2006
From: chandu_ns at yahoo.com (chandan kumar)
Date: Mon, 7 Aug 2006 04:07:44 -0700 (PDT)
Subject: [Expat-discuss] Character Encoding 4 bytes Limitation
Message-ID: <20060807110744.65810.qmail@web30601.mail.mud.yahoo.com>
Hi All,
The expat doc/reference.html mentions these limitation for character encoding.
-----
Expat places restrictions on character encodings that it can support by filling in the XML_Encoding structure. include file:
2. Characters must be encoded in 4 bytes or less.
3. All characters encoded must have Unicode scalar values less than or equal to 65535 (0xFFFF)This does not apply to the built-in support for UTF-16 and UTF-8
------
Some of the chinese characters fall beyond this range. Does this mean that expat cannot parse all the chinese characters?
Is there any expat document providing the list of characters supported?
Thanks,
Chandu
---------------------------------
Do you Yahoo!?
Next-gen email? Have it all with the all-new Yahoo! Mail Beta.
From karl at waclawek.net Mon Aug 7 17:10:30 2006
From: karl at waclawek.net (Karl Waclawek)
Date: Mon, 07 Aug 2006 11:10:30 -0400
Subject: [Expat-discuss] Character Encoding 4 bytes Limitation
In-Reply-To: <20060807110744.65810.qmail@web30601.mail.mud.yahoo.com>
References: <20060807110744.65810.qmail@web30601.mail.mud.yahoo.com>
Message-ID: <44D757E6.8030803@waclawek.net>
chandan kumar wrote:
> Hi All,
>
>
> The expat doc/reference.html mentions these limitation for character encoding.
> -----
> Expat places restrictions on character encodings that it can support by filling in the XML_Encoding structure. include file:
>
> 2. Characters must be encoded in 4 bytes or less.
> 3. All characters encoded must have Unicode scalar values less than or equal to 65535 (0xFFFF)This does not apply to the built-in support for UTF-16 and UTF-8
> ------
>
> Some of the chinese characters fall beyond this range. Does this mean that expat cannot parse all the chinese characters?
>
Expat can parse all Chinese characters as long as they are encoded in
UTF-16 or UTF-8.
These limitations only apply to non-Unicode encodings.
Someone has supplied an Expat patch to support the GB2312 encoding. See
patch # 888879.
>
> Is there any expat document providing the list of characters supported?
>
There are source code comments in expat.h for the XML_Encoding
structure, but not a list.
Karl
From Shishir.Rawat at rds.co.nz Wed Aug 23 03:57:50 2006
From: Shishir.Rawat at rds.co.nz (Shishir.Rawat at rds.co.nz)
Date: Wed, 23 Aug 2006 07:27:50 +0530
Subject: [Expat-discuss] XMLParserBuffer returns no element found!!!
Message-ID:
Hello all,
I am using DOMC 0.8.0 along with Expat 2.0.0 and crosscompiling it for ARM
using arm-linux-g++ 3.3.2.
I am observing some problem with DOM_DocumentLS_load() API which in turn
calls XMLParserBuffer() of Expat.
The API is returning me error code as no element found - line 1. Which i
presume an error code of Expat rather then DOMC.
All of this happens as soon as i fork my parent process and try to call
this API from child process.
When i am not forking the process i get results as expected.
so when i say "make debug" it compiles without the source within #ifndef
CONSOLE_ONLY in turn the forking stuff in main function.
This works fine and returns me appropriate results.
But when i say "make" it compiles with all the forking stuff as mentioned
in main function.
The API returns with error "no element found: line 1".
even if i call the function function() before forking is done it returns
me correct results.
Can anyone help me with this problem and let me know where exactly i m
goin wrong?
The source code/makefile and xml files are as follows:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define HAVE_VARMACRO 1
#include
bool gRunningFlag = true ;
bool gErrorFlag = false ;
int function(void);
void signal_handler(int sig) /* signal handler function */
{
switch(sig){
case SIGHUP:
/* rehash the server */
syslog(LOG_USER | LOG_DEBUG, "Caught SIGHUP, reloading
configuration?") ;
break;
case SIGTERM:
/* finalize the server */
syslog(LOG_USER | LOG_DEBUG, "Caught SIGTERM, shutting down") ;
gErrorFlag = true ;
//exit(0) ;
break;
case SIGINT:
syslog(LOG_USER | LOG_DEBUG, "Caught SIGINT, shutting down") ;
gErrorFlag = true ;
break ;
}
}
int main(int argc, char *argv[])
{
function();
#ifndef CONSOLE_ONLY
/* Our process ID and Session ID */
pid_t pid, sid;
/* Fork off the parent process */
pid = fork();
if (pid < 0) {
exit(EXIT_FAILURE);
}
/* If we got a good PID, then
* we can exit the parent process. */
if (pid > 0) {
exit(EXIT_SUCCESS);
}
/* Change the file mode mask */
umask(0);
/* Open any logs here */
/* Create a new SID for the child process */
sid = setsid();
if (sid < 0) {
/* Log the failure */
exit(EXIT_FAILURE);
}
/* Change the current working directory */
if ((chdir("/")) < 0) {
/* Log the failure */
exit(EXIT_FAILURE);
}
/* Close out the standard file descriptors */
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
#endif
/* install signal handlers, so we can be a well-behaved unix daemon */
signal(SIGHUP, signal_handler); /* hangup signal */
signal(SIGTERM, signal_handler); /* software termination signal from
kill */
signal(SIGINT, signal_handler) ; /* Control-c or Control-Break from
keyboard */
while (!gErrorFlag)
{
function();
/* The Big Loop */
while (!gErrorFlag)
{
usleep(1000); /* wait 1 millisecond */
}
sleep(5) ;
}
exit(EXIT_SUCCESS);
}
int
function(void)
{
DOM_Document *doc;
DOM_Element *root;
DOM_Node *node;
if (!setlocale(LC_CTYPE, "")) {
syslog(LOG_USER | LOG_DEBUG, "Can't set the specified locale! "
"Check LANG, LC_CTYPE, LC_ALL.\n");
return 0;
}
doc = DOM_Implementation_createDocument(NULL, NULL, NULL);
if (DOM_DocumentLS_load(doc, "xmlfile.xml") == -1) {
MMSG("test xmlfile.xml load failed DOM_Exception");
syslog(LOG_USER | LOG_DEBUG, "Error trying to load XML file \n");
return 0;
}
root = doc->u.Document.documentElement;
for (node = root->firstChild;
node && node->nodeType != DOM_ELEMENT_NODE;
node = node->nextSibling) {
;
}
if (node == NULL) {
syslog(LOG_USER | LOG_DEBUG, "The document has no element
children\n");
return 0;
}
DOM_NodeList * entry =
DOM_Document_getElementsByTagName(doc,"builddate");
for (int i = 0 ; i < entry->length ; i++){
DOM_Node * node = DOM_NodeList_item(entry,i);
syslog(LOG_USER | LOG_DEBUG, "Data tag : %s :: %s", node->nodeName,
node->firstChild->nodeValue);
}
DOM_Document_destroyNodeList(doc, entry, 0);
DOM_Document_destroyNode(doc, doc);
return 1;
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The makefile contains
PREFIX = /home/shishir/arm
INCLUDE = $(PREFIX)/include
LIB = $(PREFIX)/lib
CXX = arm-linux-g++
CXX_LIBS = -L/usr/local/arm/3.3.2/lib -L$(LIB) -pthread -ldl -lm
-ldomc -lmba -lexpat
CXXFLAGS = -Wall -I$(INCLUDE)
SOURCES = testdomc.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=test
.SUFFIXES: .o .cpp
.cpp.o :
$(CXX) -c $(CXXFLAGS) $(DEBUGFLAG) -o $@ $<
all: $(EXECUTABLE)
debug: DEBUGFLAG = -DCONSOLE_ONLY
debug: clean all
$(EXECUTABLE):$(OBJECTS)
$(CXX) -o $(EXECUTABLE) $(OBJECTS) $(CXX_LIBS)
arm-linux-strip $(EXECUTABLE)
clean:
rm -f $(OBJECTS)
rm -f $(EXECUTABLE)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
xmlfile.xml contains
2006-11-23
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
From mba2000 at ioplex.com Wed Aug 23 04:31:18 2006
From: mba2000 at ioplex.com (Michael B Allen)
Date: Tue, 22 Aug 2006 22:31:18 -0400
Subject: [Expat-discuss] XMLParserBuffer returns no element found!!!
In-Reply-To:
References:
Message-ID: <20060822223118.1a7f8c02.mba2000@ioplex.com>
On Wed, 23 Aug 2006 07:27:50 +0530
Shishir.Rawat at rds.co.nz wrote:
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> xmlfile.xml contains
>
>
> 2006-11-23
>
>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
That's not a valid XML file. An XML file always begins with the processing instruction. Does the behavior change if you
add it?
Mike
PS: You might want to upgrade to the latest libmba. It's far more portable
and doesn't use variadic macros. I don't think the changes to DOMC would
be significant.
--
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/
From mba2000 at ioplex.com Wed Aug 23 07:11:29 2006
From: mba2000 at ioplex.com (Michael B Allen)
Date: Wed, 23 Aug 2006 01:11:29 -0400
Subject: [Expat-discuss] XMLParserBuffer returns no element found!!!
In-Reply-To:
References: <20060822223118.1a7f8c02.mba2000@ioplex.com>
Message-ID: <20060823011129.6c75f651.mba2000@ioplex.com>
On Wed, 23 Aug 2006 10:08:50 +0530
Shishir.Rawat at rds.co.nz wrote:
> But the second call of same function function() at the end of main
> function before Big while loop returns and prints error sayin:
>
> src/expatls.c :654:DOM_DocumentLS_fread: An XML parser error occured : no
> element found : line 1
Ah, well then it looks like it's reached the end of the stream. Perhaps
you just need to close it an reopen it? DOM_DocumentLS_fread only loads
one "document". If you want to process multiple files you will need to
close and open for each [1].
Mike
[1] If I might be so bold as to guess that you're trying to write an
XMLRPC/SOAP (or some other bastardization of XML) type server, you'll
most definitely want to write your own serialization component that
calls a callback with the DOM_Document for each complete tree and then
writes the resulting DOM_Document back to the socket. Or something like
that. The expatls.c loader implementation is really just for disk files.
--
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/
From Shishir.Rawat at rds.co.nz Wed Aug 23 08:12:29 2006
From: Shishir.Rawat at rds.co.nz (Shishir.Rawat at rds.co.nz)
Date: Wed, 23 Aug 2006 11:42:29 +0530
Subject: [Expat-discuss] XMLParserBuffer returns no element found!!!
In-Reply-To: <20060823011129.6c75f651.mba2000@ioplex.com>
Message-ID:
Hello Mike,
this time i hav repeated same process in serial.
i just commented out first function function() call and i got the same
error again,
second time i commented out second call of function function() and resumed
the first call and it worked fine by returning expected data..
so this way i am calling DOM_DocumentLS_load only once in my application
and in turn opening only one file at a time.
but the problem is still there.
My requirement is just to be able to use one xml file which contains some
of configuration data with it for my application.
But unfortunately it runs from the big while loop which u can see in the
framework source i had sent across.
Also i m comperatively a newbie to linux+xml. So silly mistakes r
expected.
cheers,
shishir
From mba2000 at ioplex.com Wed Aug 23 15:16:19 2006
From: mba2000 at ioplex.com (Michael B Allen)
Date: Wed, 23 Aug 2006 09:16:19 -0400
Subject: [Expat-discuss] XMLParserBuffer returns no element found!!!
In-Reply-To:
References:
Message-ID: <20060823091619.478ae7fc.mba2000@ioplex.com>
On Wed, 23 Aug 2006 07:27:50 +0530
Shishir.Rawat at rds.co.nz wrote:
You're changing to the root directory:
> /* Change the current working directory */
> if ((chdir("/")) < 0) {
> /* Log the failure */
> exit(EXIT_FAILURE);
> }
>
> /* Close out the standard file descriptors */
> close(STDIN_FILENO);
> close(STDOUT_FILENO);
MMSG et al write to stderr by default. See the msgno HTML documentation
on the libmba website for instructions on how to write the code necessary
for msgno macros to write to syslog.
For now, don't close stderr so you can see the error.
// close(STDERR_FILENO);
> #endif
>
Now you try to load a file in the current directory.
> if (DOM_DocumentLS_load(doc, "xmlfile.xml") == -1) {
> MMSG("test xmlfile.xml load failed DOM_Exception");
> syslog(LOG_USER | LOG_DEBUG, "Error trying to load XML file \n");
> return 0;
> }
If you comment out close(STDERR_FILENO) you'll see the error:
src/expatls.c:693:DOM_DocumentLS_load: No such file or directory: uri=xmlfile.xml
You need to use a full pathname.
Mike
--
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/
From rolf at pointsman.de Wed Aug 23 21:48:59 2006
From: rolf at pointsman.de (rolf at pointsman.de)
Date: Wed, 23 Aug 2006 21:48:59 +0200 (CEST)
Subject: [Expat-discuss] XMLParserBuffer returns no element found!!!
In-Reply-To: <20060822223118.1a7f8c02.mba2000@ioplex.com>
Message-ID: <20060823194902.96E0C963C8@pointsman.pointsman.de>
On 22 Aug, Michael B Allen wrote:
> On Wed, 23 Aug 2006 07:27:50 +0530
> Shishir.Rawat at rds.co.nz wrote:
>
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> xmlfile.xml contains
>>
>>
>> 2006-11-23
>>
>>
>> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> That's not a valid XML file. An XML file always begins with the version="1.0"?> processing instruction.
This is not right. An XML file does not always have to begin with the
XML Declaration. See the production 22 of the XML recommendation
http://www.w3.org/TR/2004/REC-xml-20040204/#NT-prolog
If you encode your XML files in another encoding then UTF-8 you must
have an XML Declaration with the right Encoding Declaration, sure. But
if your XML data is encoded in UTF-8 - which is a good idea - you can
omit the XML Declaration and every compliant parser will grok your
document.
rolf
From jeckyll at mac.com Thu Aug 24 16:02:31 2006
From: jeckyll at mac.com (Norman Rosner)
Date: Thu, 24 Aug 2006 16:02:31 +0200
Subject: [Expat-discuss] a few newbie queistions
Message-ID: <25A9CBC7-2130-463B-91E3-E8FD1178ED63@mac.com>
Hi there,
i'm new to expat and i'm trying to use it to write a chartparser...
So i have a xml-document with this structure:
>
>
>
> 0
> S
> NP VP
>
>
>
> 1
> NP
> DET A N
>
> .....
After installing expat on my machine I tried to figure out how it
works so I observed the elements.c in the examples directory.
Now my questions that I could not solve until now - maybe you can
help me:
based on the elements.c in the examples directory of expat i rewrote
the startElement-function just to test something:
> static void XMLCALL
> startElement(void *userData, const char *name, const char **atts)
> {
> if(name == "LHS") {
> printf("LeftHandSide");
> }
> else {
> printf("StartingElement : %s\n", name);
> }
> }
Could anyone tell me why does my identitytesting in (name == "LHS")
not work at all? Where is my Mistake in thinking?
Second Question:
How can i get the data that's in the elements. I tried the
XML_SetCharacterDataHandler but it didn't work the way i intended it
to work ;)
Can anyone send me an example or so where the data of the elements is
just printed on stdout? That would be nice.
Thanks a lot for your help
so far
norman
From marco.forberg at gmx.net Thu Aug 24 16:29:23 2006
From: marco.forberg at gmx.net (Marco Forberg)
Date: Thu, 24 Aug 2006 16:29:23 +0200
Subject: [Expat-discuss] a few newbie queistions
In-Reply-To: <25A9CBC7-2130-463B-91E3-E8FD1178ED63@mac.com>
References: <25A9CBC7-2130-463B-91E3-E8FD1178ED63@mac.com>
Message-ID:
Am 24.08.2006, 16:02 Uhr, schrieb Norman Rosner :
> Could anyone tell me why does my identitytesting in (name == "LHS")
> not work at all? Where is my Mistake in thinking?
name is a pointer to character, not a string-object. You should use strcmp
or something similiar for this comparison
From ali at mental.com Fri Aug 25 12:17:28 2006
From: ali at mental.com (Albrecht Fritzsche)
Date: Fri, 25 Aug 2006 12:17:28 +0200 (MEST)
Subject: [Expat-discuss] Expat-discuss Digest, Vol 77, Issue 8
In-Reply-To:
References:
Message-ID:
On Fri, 25 Aug 2006 expat-discuss-request at libexpat.org wrote:
> Message: 1
> Date: Thu, 24 Aug 2006 16:02:31 +0200
> From: Norman Rosner
> Subject: [Expat-discuss] a few newbie queistions
>
> Second Question:
>
> How can i get the data that's in the elements. I tried the
> XML_SetCharacterDataHandler but it didn't work the way i intended it
> to work ;)
Maybe the same mistake? Ie you'd expected a string but do
get a char pointer?
Watch out though what the documentation tells you
"The string your handler receives is NOT nul-terminated.
You have to use the length argument to deal with the end
of the string. A single block of contiguous text free of
markup may still result in a sequence of calls to this
handler."
Ie there might be several calls to CharacterDataHandler
before you have gathered all data.
Ali
From jemarch at gnu.org Fri Aug 25 18:05:57 2006
From: jemarch at gnu.org (Jose E. Marchesi)
Date: Fri, 25 Aug 2006 18:05:57 +0200
Subject: [Expat-discuss] Getting the markup inside an entity
Message-ID: <17647.8165.627132.810302@gargle.gargle.HOWL>
Hi all.
I am writing some xml based import/export features for GNU
Ferret[1]. The data i want to import/export is somewhat like:
...
...
Each object in a datamodel has a type. Each object type store a
different data structure. GNU Ferret is written in a way in that the
developer can "register" new object types.
I want to use different expat parsers to manage the entities
that contain the data of an object. In the same way i want to use a
different parser to manage the domain trees (the user may want to
import a domain tree stored in a separated file, beginning with the
entity).
Well, as i understand it, what i need is a way to get the complete
markup inside an entity. For example, when the datamodel parser finds
a entity, it would get the markup inside that entity, call the
object type specific parser to process it, and ignore the contents of
continuing the parsing.
Is that feasible? If not, there is another way to achieve the
modularity i want? (i was thinking in complex temporal handler and
user data reassignments).
Thanks in advance!!
[1] - http://www.gnu.org/software/ferret
From jemarch at gnu.org Fri Aug 25 17:49:32 2006
From: jemarch at gnu.org (Jose E. Marchesi)
Date: Fri, 25 Aug 2006 17:49:32 +0200
Subject: [Expat-discuss] Getting the markup inside an entity
Message-ID: <17647.7180.519310.154499@gargle.gargle.HOWL>
Hi all.
I am writing some xml based import/export features for GNU
Ferret[1]. The data i want to import/export is somewhat like:
...
...
Each object in a datamodel has a type. Each object type store a
different data structure. GNU Ferret is written in a way in that the
developer can "register" new object types.
I want to use different expat parsers to manage the entities
that contain the data of an object. In the same way i want to use a
different parser to manage the domain trees (the user may want to
import a domain tree stored in a separated file, beginning with the
entity).
Well, as i understand it, what i need is a way to get the complete
markup inside an entity. For example, when the datamodel parser finds
a entity, it would get the markup inside that entity, call the
object type specific parser to process it, and ignore the contents of
continuing the parsing.
Is that feasible? If not, there is another way to achieve the
modularity i want? (i was thinking in complex temporal handler and
user data reassignments).
Thanks in advance!!
[1] - http://www.gnu.org/software/ferret
From jeckyll at mac.com Sun Aug 27 19:42:14 2006
From: jeckyll at mac.com (Norman Rosner)
Date: Sun, 27 Aug 2006 19:42:14 +0200
Subject: [Expat-discuss] New questions arised ;)
Message-ID: <3A1C1556-EACA-43E9-A146-8BD48AAC8A37@mac.com>
Hi Guys it's me again the newbie in expat :)
Now that i have figure out that i can't access member data elemts
from static function i hope that you guys can help me with answering
the question:
Is there any way how i can access them?
Heres the code:
struct Wrapper {
public:
bool LHS_is_on, RHS_is_on, rule_is_on;
static void XMLCALL startElement(void *userData, const XML_Char
*name, const XML_Char **atts)
{
if(strcmp(name, "LHS") == 0) {
LHS_is_on = true;
RHS_is_on, rule_is_on = false;
cout << "left" <<"\n";
}
// cout << name << "\n";
}
...
};
g++ says:
grammar.h:22: error: invalid use of member 'Wrapper::LHS_is_on' in
static member function
grammar.h:34: error: from this location
So please help me ;)
So i don't have a lot of knowledge about c++ it would be great if
your answers (hopefully there are any :)) would be as simple as
possible so i can understand it :)
Thanks a lot
norman
From s.david at tom.com Mon Aug 28 13:06:23 2006
From: s.david at tom.com (sdavid)
Date: Mon, 28 Aug 2006 19:06:23 +0800
Subject: [Expat-discuss] Expat-discuss Digest, Vol 77, Issue 10
In-Reply-To:
Message-ID: <20060828110637.A09F31E4003@bag.python.org>
For Norman's problem:
Expat is a pure C xml parser and it build well with all known pop C
compiler. There's a lot of xml libs write by c++, so you don't have to wrap
it to c++ class, of course there's problem use a member of a object in
static method.
-----Original Message-----
From: expat-discuss-bounces+s.david=tom.com at libexpat.org
[mailto:expat-discuss-bounces+s.david=tom.com at libexpat.org] On Behalf Of
expat-discuss-request at libexpat.org
Sent: Monday, August 28, 2006 6:00 PM
To: expat-discuss at libexpat.org
Subject: Expat-discuss Digest, Vol 77, Issue 10
Send Expat-discuss mailing list submissions to
expat-discuss at 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 at libexpat.org
You can reach the person managing the list at
expat-discuss-owner at 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. New questions arised ;) (Norman Rosner)
----------------------------------------------------------------------
Message: 1
Date: Sun, 27 Aug 2006 19:42:14 +0200
From: Norman Rosner
Subject: [Expat-discuss] New questions arised ;)
To: expat-discuss at libexpat.org
Message-ID: <3A1C1556-EACA-43E9-A146-8BD48AAC8A37 at mac.com>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
Hi Guys it's me again the newbie in expat :)
Now that i have figure out that i can't access member data elemts
from static function i hope that you guys can help me with answering
the question:
Is there any way how i can access them?
Heres the code:
struct Wrapper {
public:
bool LHS_is_on, RHS_is_on, rule_is_on;
static void XMLCALL startElement(void *userData, const XML_Char
*name, const XML_Char **atts)
{
if(strcmp(name, "LHS") == 0) {
LHS_is_on = true;
RHS_is_on, rule_is_on = false;
cout << "left" <<"\n";
}
// cout << name << "\n";
}
...
};
g++ says:
grammar.h:22: error: invalid use of member 'Wrapper::LHS_is_on' in
static member function
grammar.h:34: error: from this location
So please help me ;)
So i don't have a lot of knowledge about c++ it would be great if
your answers (hopefully there are any :)) would be as simple as
possible so i can understand it :)
Thanks a lot
norman
------------------------------
_______________________________________________
Expat-discuss mailing list
Expat-discuss at libexpat.org
http://mail.libexpat.org/mailman/listinfo/expat-discuss
End of Expat-discuss Digest, Vol 77, Issue 10
*********************************************
From ali at mental.com Mon Aug 28 13:36:27 2006
From: ali at mental.com (Albrecht Fritzsche)
Date: Mon, 28 Aug 2006 13:36:27 +0200 (MEST)
Subject: [Expat-discuss] Expat-discuss Digest, Vol 77, Issue 10
In-Reply-To:
References:
Message-ID:
On Mon, 28 Aug 2006 expat-discuss-request at libexpat.org wrote:
> Is there any way how i can access them?
>
> Heres the code:
>
> struct Wrapper {
>
> public:
>
> bool LHS_is_on, RHS_is_on, rule_is_on;
>
> static void XMLCALL startElement(void *userData, const XML_Char
> *name, const XML_Char **atts)
> {
> if(strcmp(name, "LHS") == 0) {
> LHS_is_on = true;
> RHS_is_on, rule_is_on = false;
> }
> }
> ...
> };
>
> So i don't have a lot of knowledge about c++ it would be great if
> your answers (hopefully there are any :)) would be as simple as
> possible so i can understand it :)
Uh, that makes it hard to write C++ code, doesn't it?
This *is* actually about understanding some fundamental
principles - objects, static class data, ...
Inside the static function you try to access a (as I assume)
non-static member of Wrapper. If, as I assume, userData is
a pointer to an Wrapper object, you can write in
startElement(...) {
Wrapper* wrapper = static_cast(userData);
if (...) {
wrapper->LHS_is_on = ...
}
}
ie you get access to the Wrapper object through the userData
pointer, which needs to be re-casted to an Wrapper object
inside of each static function.
HTH
Ali
From kumar_qnx at yahoo.com Thu Aug 31 19:49:04 2006
From: kumar_qnx at yahoo.com (kumar qnx)
Date: Thu, 31 Aug 2006 10:49:04 -0700 (PDT)
Subject: [Expat-discuss] Help using Libexpat
Message-ID: <20060831174904.19499.qmail@web55008.mail.re4.yahoo.com>
Hi,
I need some help on using libexpat for creating a xml document, i looked at xml.com examples but there is no information regarding creating a xml document. Can somebody point me to some examples or functions that create xml documents.
regards,
Pavan.
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1?/min.
From regis.st-gelais at laubrass.com Thu Aug 31 20:06:33 2006
From: regis.st-gelais at laubrass.com (=?iso-8859-1?Q?R=E9gis_St-Gelais_=28Laubrass=29?=)
Date: Thu, 31 Aug 2006 14:06:33 -0400
Subject: [Expat-discuss] Help using Libexpat
References: <20060831174904.19499.qmail@web55008.mail.re4.yahoo.com>
Message-ID: <1be301c6cd28$319ac3d0$6400a8c0@laubrasssag1>
Expat is an XML parser.
It only read XML files.
I simply create my XML files using the good old fprintf function.
Regis St-Gelais
www.laubrass.com
----- Original Message -----
From: kumar qnx
To: expat-discuss at libexpat.org
Sent: Thursday, August 31, 2006 1:49 PM
Subject: [Expat-discuss] Help using Libexpat
Hi,
I need some help on using libexpat for creating a xml document, i looked at xml.com examples but there is no information regarding creating a xml document. Can somebody point me to some examples or functions that create xml documents.
regards,
Pavan.
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1?/min.
_______________________________________________
Expat-discuss mailing list
Expat-discuss at libexpat.org
http://mail.libexpat.org/mailman/listinfo/expat-discuss
From kumar_qnx at yahoo.com Thu Aug 31 20:45:00 2006
From: kumar_qnx at yahoo.com (kumar qnx)
Date: Thu, 31 Aug 2006 11:45:00 -0700 (PDT)
Subject: [Expat-discuss] Help using Libexpat
In-Reply-To: <1be301c6cd28$319ac3d0$6400a8c0@laubrasssag1>
Message-ID: <20060831184500.45192.qmail@web55004.mail.re4.yahoo.com>
Thanks for the info, i probably will do the same.
regards,
Pavan
R?gis St-Gelais (Laubrass) wrote:
Expat is an XML parser.
It only read XML files.
I simply create my XML files using the good old fprintf function.
Regis St-Gelais
www.laubrass.com
----- Original Message -----
From: kumar qnx
To: expat-discuss at libexpat.org
Sent: Thursday, August 31, 2006 1:49 PM
Subject: [Expat-discuss] Help using Libexpat
Hi,
I need some help on using libexpat for creating a xml document, i looked at xml.com examples but there is no information regarding creating a xml document. Can somebody point me to some examples or functions that create xml documents.
regards,
Pavan.
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1?/min.
_______________________________________________
Expat-discuss mailing list
Expat-discuss at libexpat.org
http://mail.libexpat.org/mailman/listinfo/expat-discuss
---------------------------------
Get your own web address for just $1.99/1st yr. We'll help. Yahoo! Small Business.
From karl at waclawek.net Thu Aug 31 21:00:57 2006
From: karl at waclawek.net (Karl Waclawek)
Date: Thu, 31 Aug 2006 15:00:57 -0400
Subject: [Expat-discuss] Help using Libexpat
In-Reply-To: <1be301c6cd28$319ac3d0$6400a8c0@laubrasssag1>
References: <20060831174904.19499.qmail@web55008.mail.re4.yahoo.com>
<1be301c6cd28$319ac3d0$6400a8c0@laubrasssag1>
Message-ID: <44F731E9.20809@waclawek.net>
R?gis St-Gelais (Laubrass) wrote:
> Expat is an XML parser.
> It only read XML files.
>
> I simply create my XML files using the good old fprintf function.
>
>
There is also genx, a C-library written by Tim Bray:
http://www.tbray.org/ongoing/When/200x/2004/02/20/GenxStatus
Karl
From tom at abc123.dowco.com Wed Aug 30 06:58:54 2006
From: tom at abc123.dowco.com (Tom Younger)
Date: Tue, 29 Aug 2006 21:58:54 -0700 (PDT)
Subject: [Expat-discuss] Linking
Message-ID:
Hi there.
I have a question about linking.
I would like to link the Expat library statically. When I link to the
Linux libraries, this happens properly, however when I link my project
under Windows, I can only get the program to work if I include the path to
the libexpat.dll in my system path.
Even though I include StaticLibs\libexpatMT.lib in my link command, without
Libs\libexpat.lib, it can't resolve some symbols. It appears as though
libexpat.lib loads the DLL at run-time.
The problem I have is that the project I am working on is expected to be
able to run without setting any environment variables prior to executing
(it does that itself at run-time), and with all software components
self-contained in its own install folder. The way I currently have things
working the DLL is loaded at program startup, prior to being able to set
the path at run-time to allow a local copy of the DLL to be loaded.
The relevant portion of my current Makefile is included below:
#### Expat
EXPAT_HOME = V:\lib\Expat-2.0.0
INCLUDE_EXPAT = -I$(EXPAT_HOME)\include
LDFLAGS_EXPAT = /LIBPATH:$(EXPAT_HOME)
LIB_EXPAT = $(LDFLAGS_EXPAT)\Libs libexpat.lib
$(LDFLAGS_EXPAT)\StaticLibs libexpatMT.lib
I've been unable to find any mention of this in any of the documentation
I've found. Like I said, my Makefile for Linux works just as expected and
links statically just fine.
---
Tom Younger, B.Sc.
Lead Engineer, Marine Division
Quester Tangent