I think it would be helpful if you sent an example of a document that
causes the problem as an attachment. There are other problems with your
listing, such as the absence of quotes around the xmlns attribute value
and the presence of a semicolon after the xmlns:xsi value.

Also, try replicating the problem with the sample applications, such as
DOMPrint. My version of DOMPrint (which is a couple of years old) has no
trouble with documents with a newline in a schemaLocation value.

-----Original Message-----
From: Steve Bukoski [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 03, 2006 4:47 PM
To: [email protected]
Subject: CR/LF in Root Element Start Tag Causes Unknown Exception in
parse method

I?m getting an exception in the parse method when my Root element start
tag contains a CR/LF. When the CR/LF is removed, the error goes away.
I?ve read through the standard and I?m not clear as to whether the CR/LF
is permitted or not. I do know that XMLSpy validates the file with the
CR/LF included. Is this the intended behavior for the library or is this
a bug?
I?m using Xerces C++ v2.7.0 on a Windows XP platform. I build the
library with Visual Studio 2003.

My XML file starts with the lines listed below (notice the CR/LF before
the schema filename). An exception is thrown on the parse call. 
<?xml version="1.0" encoding="UTF-8"?>
<MyRootTag Name="Steve1" Version="1.0" Description="A test"
xmlns=http://www.ourwebsite.com/myNamespace
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";;
xsi:schemaLocation=" http://www.ourwebsite.com/myNamespace 
myApps_Schema.xsd">

Here is the code snippet that processes the XML containing the above
lines:
    DOMcreationErrorHandler* myErrorHandler = new
DOMcreationErrorHandler;
    try
    {
        MemBufInputSource m( (const
XMLByte*)receivedXML.c_str(),receivedXML.size(), "myXMLString");
        XercesDOMParser myParser;
        std::string const schemaLocation =
"http://www.ourwebsite.com/myNamespace myApps_Schema.xsd";
        myParser.setDoNamespaces(true); 
        myParser.setDoSchema(true);
        myParser.setExternalSchemaLocation(schemaLocation.c_str() );
        myParser.setValidationSchemaFullChecking(true); 
        myParser.setValidationConstraintFatal(true); 
        myParser.setErrorHandler( (ErrorHandler*) myErrorHandler);
        myParser.parse(m); 

The parse call triggers an exception caught by the last of these four
catch blocks:
    catch (std::exception &ex)
    {
  // Code removed. A message is logged.
    }
    catch (OutOfMemoryException const &/*ex*/)
    {
// Code removed. A message is logged.
    }
    catch (DOMException const &e)
    {
// Code removed. A message is logged.
    }
    catch (...)
    {
// Code removed. A message is logged.
    }

Thanks in advance for your help,
Steve


Reply via email to