Xerces reports it can not find the elment when including the other schema.
--------------------------------------------------------------------------

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


Xerces reports it can not find the elment when including the other schema and 
the schema's element depended on the othe elment.
But it validates ok in XmlSpy and Oxygen.

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

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 -> A.xsd 
A.xsd  include B.xsd

<?xml version="1.0" encoding="UTF-8"?>
<createService groupId="1234561702" serviceProviderId="1234561702" 
xmlns="http://schemas.ericsson.com/ema/UserProvisioning/BWASSV/14/Group/Service/EnhancedOutgoingCallingPlan/";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    
xsi:schemaLocation="http://schemas.ericsson.com/ema/UserProvisioning/BWASSV/14/Group/Service/EnhancedOutgoingCallingPlan/
 A.xsd" >
    <serviceProviderId>1234561702</serviceProviderId>                       
    <groupId>1234561702</groupId>                           
    <serviceName>Enhanced Outgoing Calling Plan</serviceName>
</createService>

A.xsd
<xs:schema xmlns:ns2="http://schemas.ericsson.com/ema/UserProvisioning/"; 
xmlns:ns1="http://schemas.ericsson.com/ema/UserProvisioning/"; 
xmlns:cai3g="http://schemas.ericsson.com/cai3g1.2/"; 
xmlns="http://schemas.ericsson.com/ema/UserProvisioning/BWASSV/14/Group/Service/EnhancedOutgoingCallingPlan/";
 
xmlns:core="http://schemas.ericsson.com/ema/UserProvisioning/BWAS/14/SharedTypes/Core/";
 xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
targetNamespace="http://schemas.ericsson.com/ema/UserProvisioning/BWASSV/14/Group/Service/EnhancedOutgoingCallingPlan/";
 elementFormDefault="qualified" attributeFormDefault="unqualified">
        <xs:import namespace="http://schemas.ericsson.com/cai3g1.2/"; 
schemaLocation="../../../../../../../cai3g1.2/cai3g1.2_.xsd"/>
        <xs:import 
namespace="http://schemas.ericsson.com/ema/UserProvisioning/"; 
schemaLocation="../../../../../ema_UserProvisioning_.xsd"/>
        <xs:import 
namespace="http://schemas.ericsson.com/ema/UserProvisioning/BWAS/14/SharedTypes/Core/";
 
schemaLocation="../../../../../BWAS/14/SharedTypes/Core/ema_UserProvisioning_BWAS_14_SharedTypes_Core_.xsd"/>
        <xs:include schemaLocation="B.xsd"/>
        <xs:element name="createService" 
substitutionGroup="cai3g:CreateMODefinition">
                <xs:annotation>
                        <xs:documentation>Target  
EnhancedOutgoingCallingPlan</xs:documentation>
                </xs:annotation>
                <xs:complexType>
                        <xs:complexContent>
                                <xs:extension 
base="cai3g:AbstractCreateAttributeType">
                                        <xs:sequence>
                                                <xs:element 
name="serviceProviderId" type="ServiceProviderId"/>
                                                <xs:element 
name="departmentType" type="DepartmentType"/>
                                                <xs:element name="serviceName">
                                                        <xs:simpleType>
                                                                <xs:restriction 
base="xs:token">
                                                                        
<xs:enumeration value="Enhanced Outgoing Calling Plan"/>
                                                                
</xs:restriction>
                                                        </xs:simpleType>
                                                </xs:element>
                                                <xs:element 
name="serviceSpecificData" minOccurs="0">
                                                        <xs:complexType>
                                                                <xs:sequence>
                                                                        
<xs:element name="DepartmentAuthorizationCodeList">
                                                                                
<xs:annotation>
                                                                                
        
<xs:documentation>GroupOutgoingCallingPlanDepartmentAuthorizationCodeAddListRequest</xs:documentation>
                                                                                
</xs:annotation>
                                                                                
<xs:complexType>
                                                                                
        <xs:sequence>
                                                                                
                <xs:element name="serviceProviderId" type="ServiceProviderId"/>
                                                                                
                <xs:element name="groupId" type="GroupId"/>
                                                                                
                <xs:element name="departmentKey" type="DepartmentKey" 
minOccurs="0"/>
                                                                                
                <xs:element name="codeEntry" maxOccurs="unbounded">
                                                                                
                        <xs:complexType>
                                                                                
                                <xs:complexContent>
                                                                                
                                        <xs:extension 
base="OutgoingCallingPlanAuthorizationCodeEntry">
                                                                                
                                                <xs:attribute name="code" 
type="OutgoingCallingPlanAuthorizationCode" use="required"/>
                                                                                
                                        </xs:extension>
                                                                                
                                </xs:complexContent>
                                                                                
                        </xs:complexType>
                                                                                
                        <xs:key name="skeyccccc.2.1">
                                                                                
                                <xs:selector xpath="."/>
                                                                                
                                <xs:field xpath="@code"/>
                                                                                
                        </xs:key>
                                                                                
                        <xs:keyref name="skeycccccRef.2.1" 
refer="skeyccccc.2.1">
                                                                                
                                <xs:selector xpath="."/>
                                                                                
                                <xs:field xpath="code"/>
                                                                                
                        </xs:keyref>
                                                                                
                </xs:element>
                                                                                
        </xs:sequence>
                                                                                
        <xs:attribute name="serviceProviderId" type="ServiceProviderId" 
use="required"/>
                                                                                
        <xs:attribute name="groupId" type="GroupId" use="required"/>
                                                                                
</xs:complexType>
                                                                                
<xs:key name="skeyccccc.2">
                                                                                
        <xs:selector xpath="."/>
                                                                                
        <xs:field xpath="@serviceProviderId"/>
                                                                                
        <xs:field xpath="@groupId"/>
                                                                                
</xs:key>
                                                                                
<xs:keyref name="skeycccccRef.2" refer="skeyccccc.2">
                                                                                
        <xs:selector xpath="."/>
                                                                                
        <xs:field xpath="serviceProviderId"/>
                                                                                
        <xs:field xpath="groupId"/>
                                                                                
</xs:keyref>
                                                                        
</xs:element>
                                                                </xs:sequence>
                                                        </xs:complexType>
                                                </xs:element>
                                        </xs:sequence>
                                        <xs:attribute name="serviceProviderId" 
type="ServiceProviderId" use="required"/>
                                        <xs:attribute name="groupId" 
type="GroupId" use="required"/>
                                </xs:extension>
                        </xs:complexContent>
                </xs:complexType>
                <xs:key name="skeyccccc">
                        <xs:selector xpath="."/>
                        <xs:field xpath="@serviceProviderId"/>
                        <xs:field xpath="@groupId"/>
                </xs:key>
                <xs:keyref name="skeycccccRef" refer="skeyccccc">
                        <xs:selector xpath="."/>
                        <xs:field xpath="serviceProviderId"/>
                        <xs:field xpath="groupId"/>
                </xs:keyref>
        </xs:element>

.......

B.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
    <xs:complexType name="DepartmentType">
        <xs:sequence>
            <xs:element name="deptType">
                <xs:simpleType>
                    <xs:restriction base="xs:token">
                        <xs:enumeration value="Group"/>
                        <xs:enumeration value="Enterprise"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
            <xs:element name="contact" type="Contact"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="Contact">
        <xs:annotation>
            <xs:documentation>Contact information.</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="contactName" nillable="true" minOccurs="0">
                <xs:simpleType>
                    <xs:restriction base="xs:token">
                        <xs:minLength value="1"/>
                        <xs:maxLength value="30"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
            <xs:element name="contactNumber" nillable="true" minOccurs="0">
                <xs:simpleType>
                    <xs:restriction base="xs:token">
                        <xs:minLength value="1"/>
                        <xs:maxLength value="30"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
            <xs:element name="contactEmail" type="EmailAddress" nillable="true" 
minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>
    <xs:simpleType name="EmailAddress">
        <xs:annotation>
            <xs:documentation>Email Address</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:token">
            <xs:minLength value="1"/>
            <xs:maxLength value="80"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

The Xerces will report that it can't find the element "contactNumber".


-- 
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