[ https://issues.apache.org/jira/browse/XERCESC-1743?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alberto Massari resolved XERCESC-1743. -------------------------------------- Resolution: Invalid The schemas for the "base" and "core" namespaces are missing; the A.xsd schema is partial, as it misses the definitions for the types ServiceProviderId, GroupId and DepartmentKey > 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 > Components: Validating Parser (XML Schema) > Affects Versions: 2.7.0 > Environment: Solaris 10. > Reporter: PeiHua > > 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"); > // 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 = "ABC"; > // 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 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://www.xxx.com/ 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://www.xxx.com/abc/" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://www.xxx.com/abc/ A.xsd" > > <serviceProviderId>1234561702</serviceProviderId> > <groupId>1234561702</groupId> > <serviceName>Enhanced Outgoing Calling Plan</serviceName> > </createService> > A.xsd > <xs:schema xmlns="http://www.xxx.com/abc/ " > xmlns:base="http://www.xxx.com/base/" > xmlns:core="http://www.xxx.com/ema/UserProvisioning/BWAS/14/SharedTypes/Core/" > xmlns:xs="http://www.w3.org/2001/XMLSchema" > targetNamespace="http://www.xxx.com/abc/ " elementFormDefault="qualified" > attributeFormDefault="unqualified"> > <xs:import > namespace="http://www.xxx.com/ema/UserProvisioning/BWAS/14/SharedTypes/Core/"schemaLocation="ema_UserProvisioning_BWAS_14_SharedTypes_Core_.xsd"/> > <xs:include schemaLocation="B.xsd"/> > <xs:element name="createService" > substitutionGroup="base:CreateMODefinition"> > <xs:annotation> > <xs:documentation>Target > EnhancedOutgoingCallingPlan</xs:documentation> > </xs:annotation> > <xs:complexType> > <xs:complexContent> > <xs:extension > base="base: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: c-dev-unsubscr...@xerces.apache.org For additional commands, e-mail: c-dev-h...@xerces.apache.org