Parser Error Document Is Empty Libxml2
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss xmlparsefile example the workings and policies of this site About Us Learn more about xmlparsememory example Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow xmlreadfile Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up libxml2 fails to parse from buffer but parses successfully from file up vote 0 down vote favorite I have a function that writes an XML document to a buffer using the libxml2 writer, but when I try to parse the document from memory using xmlParseMemory, it only returns parser errors. I have also tried writing the document to a file and parsing it using xmlParseFile and it parses successfully. This is how I initialize the writer and buffer for the xml document. int rc, i = 0; xmlTextWriterPtr writer; xmlBufferPtr buf; // Create a new XML buffer, to which the XML document will be written buf = xmlBufferCreate(); if (buf == NULL) { printf("testXmlwriterMemory: Error creating the xml buffer\n"); return; } // Create a new XmlWriter for memory, with no compression. // Remark: there is no compression for this kind of xmlTextWriter writer = xmlNewTextWriterMemory(buf, 0); if (writer == NULL) { printf("testXmlwriterMemory: Error creating the xml writer\n"); return; } // Start the document with the xml default for the version, // encoding UTF-8 and the default for the standalone // declaration. rc = xmlTextWriterStartDocument(writer, NULL, ENCODING, NULL); if (rc < 0) { printf ("testXmlwriterMemory: Error at xmlTextWriterStartDocument\n"); return; } I pass the xml document to another function to be validated using int ret = validateXML(buf->content); Here is the first part of validat
xmlsecFTPWindows binariesSolaris binariesMacOsX binarieslxml Python bindingsPerl bindingsC++ bindingsPHP bindingsPascal bindingsRuby bindingsTcl bindingsBug TrackernanohttpAPI documentationThe XML C parser and toolkit of GnomeparserInternalsInterfaces, constants and types related to the XML parser Table of Contents#define XML_COMPLETE_ATTRS#define XML_DEFAULT_VERSION#define XML_DETECT_IDS#define XML_SAX2_MAGIC#define XML_SKIP_IDSEnum xmlFeature Enum xmlParserInputState Enum xmlParserMode Structure xmlParserNodeInfostruct _xmlParserNodeInfo Typedef xmlParserNodeInfo * xmlParserNodeInfoPtr Structure xmlParserNodeInfoSeqstruct _xmlParserNodeInfoSeq Typedef xmlParserNodeInfoSeq * xmlParserNodeInfoSeqPtr Enum xmlParserOption Structure xmlSAXHandlerV1struct _xmlSAXHandlerV1 Typedef xmlSAXHandlerV1 http://stackoverflow.com/questions/17732852/libxml2-fails-to-parse-from-buffer-but-parses-successfully-from-file * xmlSAXHandlerV1Ptr Function type: attributeDeclSAXFunc void attributeDeclSAXFunc (void * ctx, const xmlChar * elem, const xmlChar * fullname, int type, int def, const xmlChar * defaultValue, xmlEnumerationPtr tree) Function type: attributeSAXFunc void attributeSAXFunc (void * ctx, const xmlChar * name, http://xmlsoft.org/html/libxml-parser.html const xmlChar * value) Function type: cdataBlockSAXFunc void cdataBlockSAXFunc (void * ctx, const xmlChar * value, int len) Function type: charactersSAXFunc void charactersSAXFunc (void * ctx, const xmlChar * ch, int len) Function type: commentSAXFunc void commentSAXFunc (void * ctx, const xmlChar * value) Function type: elementDeclSAXFunc void elementDeclSAXFunc (void * ctx, const xmlChar * name, int type, xmlElementContentPtr content) Function type: endDocumentSAXFunc void endDocumentSAXFunc (void * ctx) Function type: endElementNsSAX2Func void endElementNsSAX2Func (void * ctx, const xmlChar * localname, const xmlChar * prefix, const xmlChar * URI) Function type: endElementSAXFunc void endElementSAXFunc (void * ctx, const xmlChar * name) Function type: entityDeclSAXFunc void entityDeclSAXFunc (void * ctx, const xmlChar * name, int type, const xmlChar *
application, which parses xml documents sent via TCP/IP verifying it against xsd schema. I am using libxml2-2.6.17. All is well til I get an error message like: Entity: line https://mail.gnome.org/archives/xml/2005-March/msg00162.html 1: parser error : Document is empty ^ Entity: line 1: parser error : Start tag expected, '<' not found ^ then I process next xml doc and I get : error : Memory allocation failed : growing buffer -> next xml document error : Memory allocation failed : growing buffer -> next xml document error : Memory allocation failed : growing buffer -> next xml parser error document error : Memory allocation failed : growing buffer -> next xml document error : Memory allocation failed : growing buffer -> next xml document error : Memory allocation failed : growing buffer : : -> next xml document error : Memory allocation failed : creating buffer -> next xml document error : Memory allocation failed : creating buffer -> next xml document error : Memory allocation parser error document failed : creating buffer -> next xml document error : Memory allocation failed : creating buffer : : -> next xml document parser error : Memory allocation failed : cannot initialize parser context -> next xml document application has crashed at this point. Should I report it as a bug? It is reproducible in my prod environment once a day. I can not reproduce in test. I am freeing schema, parser and document context after each processed xml doc. Schema context is recreated for each xml document being processed. Do it look like memory leak bug in libxml? I never had this with 2.6.11 version of xml . Please advise. -- -Igor Follow-Ups: Re: [xml] memory allocation errors From: Daniel Veillard [Date Prev][Date Next] [Thread Prev][Thread Next] [Thread Index] [Date Index] [Author Index] The GNOME Project About Us Get Involved Teams Support GNOME Contact Us The GNOME Foundation Resources Developer Center Documentation Wiki Mailing Lists IRC Channels Bug Tracker Development Code Build Tool News Press Releases Latest Release Planet GNOME Development News Identi.ca Twitter Copyright © 2005 - 2013 The GNOME Project. Optimised for standards. Hosted by Red Hat. Powered by MailMan, Python and GNU.