You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Boris Kolpackov (JIRA)" <xe...@xml.apache.org> on 2008/02/19 15:38:43 UTC
[jira] Commented: (XERCESC-1742) Xerces can not check the "xs"
namespace elements when doing validation
[ https://issues.apache.org/jira/browse/XERCESC-1742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12570248#action_12570248 ]
Boris Kolpackov commented on XERCESC-1742:
------------------------------------------
Please provide a complete set of schemas and XML documents that reproduce the problem as attachments to this bug.
> 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");
> // 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/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
> <xs:schema xmlns:base="ht
> tp://www.xxx.com/base/" xmlns="http://www.xxx.com/CommPilotExpress/" xmlns:xs="http:
> //www.w3.org/2001/XMLSchema" targetNamespace="http://www.xxx.com/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="1234561702@domain1702" xmlns="http://www.xxx.com/CommPilotExpress/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
> <serviceSpecificData>
> <Data userId="1234561702@domain1702">
> <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: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org