Xerces can not check the "xs" namespace elements when doing validation
----------------------------------------------------------------------

                 Key: XERCESC-1742
                 URL: https://issues.apache.org/jira/browse/XERCESC-1742
             Project: Xerces-C++
          Issue Type: Bug
    Affects Versions: 2.7.0
         Environment: Solaris 10
            Reporter: PeiHua
             Fix For: 2.7.0


I use Xerices c++ 2.7.0 to validate xml.But I found it can not check the "xs" 
element itself.
================================================

void XercesParser::doValidation(const char *theStr, bool setDefaultValue, bool 
ignoreError)
{
    REPORT_INFO("[XercesParser] doValidation");

        //Dynamically create myParser every time. for TR HH31020/HH41398.  
ekaizli
        /*if (myParser)
        {
                XMLString::release(&mySchema);

                delete myParser;
                myParser = NULL;
        }*/

    // create parser if it is not available
    if (myParser == NULL)
    {
        myParser = XMLReaderFactory::createXMLReader();
        myParser->setFeature(XMLUni::fgSAX2CoreValidation, true);
        myParser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);
        myParser->setFeature(XMLUni::fgXercesSchema, true);
        myParser->setFeature(XMLUni::fgXercesDynamic, true);
        myParser->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
        myParser->setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes, true);
        myParser->setFeature(XMLUni::fgXercesCacheGrammarFromParse, true);
        myParser->setFeature(XMLUni::fgXercesUseCachedGrammarInParse, true);

        mySchema = XMLString::transcode(mySchemaLoc.data());
        myParser->setProperty(XMLUni::fgXercesSchemaExternalSchemaLocation, 
mySchema);
    }

    REPORT_INFO("doValidation, mySchemaLoc: " << mySchemaLoc);
    REPORT_INFO("doValidation, theStr: " << theStr);

    if(setDefaultValue)
        myParser->setContentHandler(myHandler);
    else
        myParser->setContentHandler(NULL);

    if(!ignoreError)
        myParser->setErrorHandler(myHandler);
    else
        myParser->setErrorHandler(NULL);


    try
    {
        // added for supporting file parsing
        RWURL url(theStr);
        if (url.isValid() == false)
        {
            int len = strlen(theStr);
            const char *bufId = "CAI3G";

            // the buffer must be allocated dynamically
            MemBufInputSource theMBIS(reinterpret_cast<const XMLByte*>(theStr), 
(const unsigned int)len, bufId);
            myParser->parse(theMBIS);
        }
        else

            myParser->parse(theStr);

    }
    {
        // handle CAI3G request format error
        throw e;
    }
    catch (...)
    {
        // handle other errors
        XMLString::release(&mySchema);

        // the parser must be released here
        delete myParser;
        myParser = NULL;

        throw FDSException::FDSStandardException("doValidation, An error 
occurred during parsing.", 0);
    }
}

void XercesParser::doValidation(const FDSNamedValue& theNV, bool 
setDefaultValue, bool ignoreError)
{
    REPORT_INFO("[XercesParser] doValidation");

    ostrstream tmpStr;
    theNV.print(tmpStr, 0);
    tmpStr.put('\0');
    char *tmpStr1 = tmpStr.str();

    RWCString tmpStr2(tmpStr1);
    delete[] tmpStr1;

    doValidation(tmpStr2.data(), setDefaultValue, ignoreError);
}

And Invoke the functions before.
---------------------------------------------------

const RWCString schemaLoc = 
"http://schemas.ericsson.com/ema/UserProvisioning/BWASSV/14/User/Service/CommPilotExpress/
  /home/ehuapei/tools/validation
/bin/test.xsd";

.............

        // get parser object
        XercesParser* theParser = theObj->getObj();

        // do validation
        try
        {
            theParser->doValidation(*theNV);
        }
        catch (FDSException::FDSStandardException& e)
        {
            // release cached object
            ObjectPool::getInstance()->releaseObject(theObj);
            cout << "[testMain] Error: " << e.information() << endl;
            cout << "[testMain] Reason: " << e.reason() << endl;
        }
================================================

schema and xml below.

<?xml version="1.0" encoding="UTF-8"?>^M
<!-- edited with XMLSpy v2007 (http://www.altova.com) by KENT (LLSTUDIO) -->^M
<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by rdcshbl 
(Ericsson Communication Software Research and Development Co., Ltd) -->^M
<xs:schema xmlns:ns2="http://schemas.ericsson.com/ema/UserProvisioning/"; 
xmlns:ns1="http://schemas.ericsson.com/ema/UserProvisioning/"; xmlns:cai3g="ht
tp://schemas.ericsson.com/cai3g1.2/" 
xmlns="http://schemas.ericsson.com/ema/UserProvisioning/BWASSV/14/User/Service/CommPilotExpress/";
 xmlns:xs="http:
//www.w3.org/2001/XMLSchema" 
targetNamespace="http://schemas.ericsson.com/ema/UserProvisioning/BWASSV/14/User/Service/CommPilotExpress/";
 elementFormDe
fault="qualified" attributeFormDefault="qualified">^M
^M
        <xs:element name="setService">^M
                <xs:annotation>^M
                        <xs:documentation>Target  
CommPilotExpress</xs:documentation>^M
                </xs:annotation>^M
                <xs:complexType>^M
                        <xs:sequence>^M
                                <xs:element name="serviceSpecificData">^M
                                                        <xs:complexType>^M
                                                                <xs:sequence>^M
                                                                        
<xs:element name="Data">^M
                                                                                
<xs:annotation>^M
                                                                                
        <xs:documentation>UserCommPilotExpressModifyRequest</xs:docume
ntation>^M
                                                                                
</xs:annotation>^M
                                                                                
<xs:complexType>^M
                                                                                
        <xs:sequence>^M
                                                                                
                <xs:element name="profile" type="xs:string" nillable="
true" minOccurs="0"/>^M
                                                                                
                <xs:element name="unavailable" type="xs:string " minOc
curs="0"/>^M
                                                                                
        </xs:sequence>^M
                                                                                
        <xs:attribute name="userId" type="xs:string " use="required"/>
^M
                                                                                
</xs:complexType>^M
                                                                        
</xs:element>^M
                                                                </xs:sequence>^M
                                                        </xs:complexType>^M
                                                </xs:element>^M
                                        </xs:sequence>^M
                        <xs:attribute name="serviceProviderId" type="xs:string 
" use="required"/>^M
                        <xs:attribute name="userId" type="xs:string " 
use="required"/>^M
                </xs:complexType>^M
        </xs:element>^M
</xs:schema>


<setService serviceProviderId="1234561702" userId="[EMAIL PROTECTED]" 
xmlns="http://schemas.ericsson.com/ema/UserProvisioning/BWASSV/14/User/Servi
ce/CommPilotExpress/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
   <serviceSpecificData>
       <Data userId="[EMAIL PROTECTED]">
           <profile xsi:null="true">Available Out Of Office</profile>
       </Data>
   </serviceSpecificData>
</setService>

===============================================

the xsi:null is eat by Xerces and no error reported




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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

Reply via email to