Hi Deepack,
At 14.58 12/07/2007 +0530, M V Deepak wrote:
Hi Alberto,
Thanks for your quick reply.
I am using this xerces library for the first time.
I have few more doubts:
1. can you please guide me where exactly to put
parser->getErrorCount() in my code,
after I call parser->parse("xmlFile") or some place else.
2. I am not getting you when you say "to return 0 before trying
to access the DOMDocument" , Where am I supposed to use DOMDocument ??
3. Since I feel parse(), function returns void, so suppose schema
validation has failed (i.e test.xsd doesn't match with
sample.xml) .How I will come to know that?
I will greatly apprecite , if you can please make these changes in my
code (Test.cpp) itself and send me back that.
parser->parse(xmlFile);
// if parsing succeeded, print out the DOM tree
if(parser->getErrorCount()==0)
{
DOMWriter *theSerializer
=((DOMImplementationLS*)DOMImplementation::getImplementation())->createDOMWriter();
XMLCh* s=theSerializer->writeToString(*parser->getDocument());
std::cout << XMLString::transcode(s) << "\n";
}
else
std::cout << "Error during parsing\n";
Can you please suggest me some good websites where I can find example
similar to this, like Specifying Schema Grammar through method calls,
which will do schema validation also, with out updating xml files?
You can find the documentation for Xerces in the binary package; also
the samples are a good source of informations.
Alberto
Thanks a lot.
Regards,
- Deepak
On 7/12/07, Alberto Massari <[EMAIL PROTECTED]> wrote:
Hi Deepack,
I have tried your code with Visual C++ 6 and the binary release of
Xerces-C 2.7, and it works fine.
Be sure to test for parser->getErrorCount() to return 0 before trying
to access the DOMDocument, or an access violation will occur.
Alberto
At 17.08 11/07/2007 +0530, M V Deepak wrote:
>Hi Alberto,
>
>Please find zip file as an attachment.
>It contains:
>1. Test.cpp
>2. TestSummary.xml
>3. TestSummary.xsd
>
>Regards,
>- Deepak
>
>On 7/11/07, Alberto Massari <[EMAIL PROTECTED]> wrote:
>>Hi Deepack,
>>I received only the XSD file....
>>
>>Alberto
>>
>>At 13.17 11/07/2007 +0530, M V Deepak wrote:
>> >Hi Alberto,
>> >
>> >Thanks for a quick reply.
>> >Please find attached cpp file, xml and xsd files.
>> >As you said , I placed XMLException before DOMException, but the
>> >problem still exists.
>> >When I run it , control reaches till
>> >parser->parse(TestSummary.xml); of try block after that it goes to
>> > return -1; of catch block with out printing "cout" on command
>> >prompt(very strange!!!!!!!!)
>> >
>> >An early response will be greatly appreciated.
>> >
>> >Regards,
>> >- Deepak
>> >
>> >
>> >
>> >On 7/10/07, Alberto Massari <[EMAIL PROTECTED]> wrote:
>> >>You should not catch DOMException, but XMLException. Also, can you
>> >>attach the XML and XSD files?
>> >>
>> >>Alberto
>> >>
>> >>At 20.03 10/07/2007 +0530, M V Deepak wrote:
>> >> >Hello,
>> >> >
>> >> >I am using the xerces C++ dll i.e xerces-c_2_7D.dll , with MSVS
2005.
>> >> >
>> >> >Basically I am trying to validate schema of xml files using xsd file.
>> >> >
>> >> >When I use "TestSummary.xsd" to validate "TestSummary.xml" using
>> >> >below code , When I run it , control reaches till
>> >> >parser->parse(TestSummary.xml); of try block after that it goes to
>> >> > return -1; of catch block with out printing "cout" on command
>> >> >prompt(very strange!!!!!!!!)
>> >> >
>> >> >XMLPlatformUtils::Initialize();
>> >> >parser = new XercesDOMParser();
>> >> >parser->setDoNamespaces(true);
>> >> >parser->setDoSchema(true);
>> >> >parser->setValidationScheme(XercesDOMParser::Val_Always);
>> >> >parser->setExternalNoNamespaceSchemaLocation("TestSummary.xsd");
>> >> >
>> >> >try{
>> >> >parser->parse(TestSummary.xml);
>> >> >}
>> >> >
>> >> >catch (const DOMException& toCatch) {
>> >> > cout << "Exception "<< endl;
>> >> > return -1;
>> >> > }
>> >> >
>> >> >
>> >> >
>> >> >Any help would be greatly appreciated.
>> >> >
>> >> >Thanks in advance.
>> >> >
>> >> >- Deepak
>> >>
>> >
>> >
>> >Content-Type: application/xml; name=TestSummary.xsd
>> >X-Attachment-Id: file3
>> >Content-Disposition: attachment; filename="TestSummary.xsd"
>> >
>>
>
>
>Content-Type: application/zip; name="Test.zip"
>Content-Disposition: attachment; filename="Test.zip"
>X-Attachment-Id: file0
>