You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Thomas Porschberg <th...@osp-dd.de> on 2002/07/18 08:46:48 UTC

parse problems

I built a XML-document in memory , used a 
DOMWriter to write the document in a MemBufFormatTarget,
used the getString method to intanciate the MemBufInputSource
and  now I started to parse the XML with XercesDOMParser

the code
========

	 XMLCh tempStr[100];
	 XMLString::transcode("Core", tempStr, 99);
	 DOMImplementation *impl          = DOMImplementationRegistry::getDOMImplementation(tempStr);
	 DOMWriter         *theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter();
	 theSerializer->setNewLine(gMyEOLSequence);
	 theSerializer->setEncoding(gOutputEncoding);

	 DOMErrorHandler *myErrorHandler = new DOMPrintErrorHandler();
	 theSerializer->setErrorHandler(myErrorHandler);

	 MemBufFormatTarget *myMemBufFormatTarget = new MemBufFormatTarget();

	 theSerializer->writeNode(myMemBufFormatTarget, *doc);

         XMLCh* srcString = myMemBufFormatTarget->getString();
	 cout << StrX(srcString) << endl;
         MemBufInputSource* memBufIS = new MemBufInputSource
            (
             (const XMLByte*)srcString
             , XMLString::stringLen(srcString) * sizeof(XMLCh)
	     , gMemBufId
             , true
             );

	 parser->parse(*memBufIS);
	 delete [] srcString;

the output
===========

<?xml version="1.0" encoding="UTF-8"?>
<company><product>Xerces-C</product><category idea="great">XML Parsing Tools</category><developedBy>Apache Software Foundation</developedBy></company>

Fatal Error at file "prodInfo", line 2, column 1
   Message: Invalid document structure

the problem
===========
          Why does the parser complain about invalid structure ?

If I redirect stdout to a file I can use DOMPrint to print out the file
with no problems.


the version
===========

I use a snapshot from "xerces-c-src_2002-06-04"

tail -3 version.incl:

VER=2_0_0
SO_TARGET_VERSION=20
SO_TARGET_VERSION_MAJOR=0


any help is very appreciate
Thomas

-- 

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: parse problems

Posted by Dean Roddey <dr...@charmedquark.com>.
Without the original text, we can't tell where the actual error fell.

-------------------------------------
Dean Roddey
The Charmed Quark Controller
droddey@charmedquark.com
www.charmedquark.com
 

-----Original Message-----
From: Thomas Porschberg [mailto:thomas.porschberg@osp-dd.de] 
Sent: Wednesday, July 17, 2002 11:47 PM
To: xerces-c-dev@xml.apache.org
Subject: parse problems

I built a XML-document in memory , used a 
DOMWriter to write the document in a MemBufFormatTarget,
used the getString method to intanciate the MemBufInputSource
and  now I started to parse the XML with XercesDOMParser





---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org