whitespace lost in schema validation
------------------------------------

                 Key: XERCESC-1620
                 URL: http://issues.apache.org/jira/browse/XERCESC-1620
             Project: Xerces-C++
          Issue Type: Bug
          Components: SAX/SAX2
    Affects Versions: 2.7.0
         Environment: Windows 2000 SP4
Visual Studio .NET 2003
            Reporter: Takashi Matsuda


When XMLSchema validation is enabled, some whitespaces are reported neither 
characters() nor ignorableWhitespace() event.

Following is output of sample program which is attached below.

<characters>1234 5678 1234 5678 1234 5678 1234 5678</characters>
<characters> 1234 5678 1234 5678 1234 5678 1234 5678 1234 5678</characters>
<characters>1234 5678 1234 5678 1234 5678 1234 5678</characters>
<characters> 1234 5678</characters>

Between the 2nd and 3rd characters() event, whitespace is lost.

Is it distinguishable the last token of 2nd event and first token of 3rd event 
are differenet words or parts of continuous word?

Regards,

Takashi Matsuda.
======================

Sample Program:

#include <xercesc/sax2/XMLReaderFactory.hpp>
#include <xercesc/sax2/DefaultHandler.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/framework/MemBufInputSource.hpp>

#include <iostream>

#ifndef SCHEMA_VALIDATION
#define SCHEMA_VALIDATION 1
#endif

using namespace XERCES_CPP_NAMESPACE;

static const char source[] =
"<?xml version='1.0' encoding='ascii' ?>\n"
"<list xmlns='http://myNameSpace/'\n"
"   xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n"
"   xsi:schemaLocation='http://myNameSpace/ schema.xsd'\n"
">\n"
"   1234 5678\n"
"   1234 5678\n"
"   1234 5678\n"
"   1234 5678\n"
"   1234 5678\n"
"   1234 5678\n"
"   1234 5678\n"
"   1234 5678\n"
"   1234 5678\n"
"   1234 5678\n"
"   1234 5678\n"
"   1234 5678\n"
"   1234 5678\n"
"   1234 5678\n"
"</list>";

static const char schema[] =
"<?xml version='1.0' encoding='ascii' ?>\n"
"<xsd:schema\n"
"    xmlns:xsd='http://www.w3.org/2001/XMLSchema'\n"
"    targetNamespace='http://myNameSpace/'\n"
"    xmlns='http://myNameSpace/'\n"
">\n"
"<xsd:element name='list' type='list_type' />\n"
"<xsd:simpleType name='list_type'>\n"
"<xsd:list itemType='xsd:unsignedInt' />\n"
"</xsd:simpleType>\n"
"</xsd:schema>";


class MyHandler : public DefaultHandler
{
public:
    void characters(const XMLCh* const chars, const unsigned int length)
    {
        std::wstring message(chars, length);
        std::wcout << "<characters>" << message.c_str() << "</characters>" << 
std::endl;
    }

    void ignorableWhitespace(const XMLCh* const chars, const unsigned int 
length)
    {
        std::wstring message(chars, length);
        std::wcout << "<ignorableWhitespace>" << message.c_str() << 
"</ignorableWhitespace>" << std::endl;
    }
};

int main(int argc, char* argv[])
{
    XMLPlatformUtils::Initialize();

    {
            SAX2XMLReader *parser = XMLReaderFactory::createXMLReader();
            MyHandler myHandler;

        MemBufInputSource inputSource(reinterpret_cast<const XMLByte* 
const>(source), sizeof(source), "source.xml");
        MemBufInputSource inputSchema(reinterpret_cast<const XMLByte* 
const>(schema), sizeof(schema), "schema.xsd");
        
#if SCHEMA_VALIDATION
        parser->loadGrammar(inputSchema, Grammar::SchemaGrammarType, true);
        parser->setFeature(XMLUni::fgXercesDynamic, true);
#else
        parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, false);
        parser->setFeature(XMLUni::fgXercesSchema, false);
#endif
        parser->setContentHandler(&myHandler);
        parser->setInputBufferSize(64);
        parser->parse(inputSource);

        delete parser;
    }

    XMLPlatformUtils::Terminate();

        return 0;
}



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to