You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by unique_suresh <un...@gmail.com> on 2011/09/26 22:45:29 UTC
Re: XercesDOMParser and DOMLSParser Schema validation is not the
same
Guys Please suggest. I am waiting for input you.
Thanks in advance.
-Suresh
unique_suresh wrote:
>
> Hi All,
>
> I am new to Xerces lib and XML approach here. I have created XSD and also
> I created test.xml file. Where I want to validate xml with test.xsd file.
> Here I want to provide namespace p for all the elements by default and
> including attributes. However I have got two sample code from internet I
> am trying to run both of them.
>
> Xerces Version used : 3.1.1
> OS : Linux
>
> Files : test.xml test.xsd
>
> Code :
> load-grammar-dom uses DOMLSParser class to load grammer and validate xml.
> SchemaValidator.cpp uses XercesDOMParser class to load grammer and
> validate xml.
>
>
> Here is my problem,
>
> 1. Using DOMLSParser validate works fine I dont see any issues with the
> code / files
>
>
> Output:
> ./load-grammar-dom test.xsd test.xml
> loading test.xsd
> parsing test.xml
> Validation successful !!!
>
>
> 2. Using XercesDOMParser I am getting error message saying " At line 2
> Column 89, no declaration found for element 'p:test_in' . I dont
> understand that one approach says xml is fine this approach says something
> wrong. Please help
>
> Output:
> ./SchemaValidator test.xsd test.xml
> ===> At line 2 Column 89, no declaration found for element 'p:test_in'
> <====
> XML file doesn't conform to the schema
>
>
> Question :
> 1. Why DOMLSParser works but XercesDOMParser complaining about element.
> 2. can you someone explaining to me that difference between DOMLSParser
> and XercesDOMParser classes and their pros and cons.
>
> PS : I am very new to xml and xerces lib. Any help would appropriated.
>
> Attachments :
> -------------
> http://old.nabble.com/file/p32503845/test.xml test.xml
> http://old.nabble.com/file/p32503845/test.xsd test.xsd
> http://old.nabble.com/file/p32503845/SchemaValidator.cpp
> SchemaValidator.cpp
> http://old.nabble.com/file/p32503845/load-grammar-dom.cpp
> load-grammar-dom.cpp
>
>
> Thanks
> Suresh.
>
>
>
--
View this message in context: http://old.nabble.com/XercesDOMParser-and-DOMLSParser-Schema-validation-is-not-the-same-tp32503845p32503968.html
Sent from the Xerces - C - Users mailing list archive at Nabble.com.
Re: XercesDOMParser and DOMLSParser Schema validation is not the same
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Alberto responded to your question on the list a few days ago. See [1].
Thanks.
[1] http://markmail.org/message/2vgbbgyrv46iixda
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
unique_suresh <un...@gmail.com> wrote on 09/26/2011 04:45:29 PM:
> Guys Please suggest. I am waiting for input you.
>
> Thanks in advance.
>
> -Suresh
>
>
> unique_suresh wrote:
> >
> > Hi All,
> >
> > I am new to Xerces lib and XML approach here. I have created XSD and
also
> > I created test.xml file. Where I want to validate xml with test.xsd
file.
> > Here I want to provide namespace p for all the elements by default and
> > including attributes. However I have got two sample code from internet
I
> > am trying to run both of them.
> >
> > Xerces Version used : 3.1.1
> > OS : Linux
> >
> > Files : test.xml test.xsd
> >
> > Code :
> > load-grammar-dom uses DOMLSParser class to load grammer and validate
xml.
> > SchemaValidator.cpp uses XercesDOMParser class to load grammer and
> > validate xml.
> >
> >
> > Here is my problem,
> >
> > 1. Using DOMLSParser validate works fine I dont see any issues with the
> > code / files
> >
> >
> > Output:
> > ./load-grammar-dom test.xsd test.xml
> > loading test.xsd
> > parsing test.xml
> > Validation successful !!!
> >
> >
> > 2. Using XercesDOMParser I am getting error message saying " At line 2
> > Column 89, no declaration found for element 'p:test_in' . I dont
> > understand that one approach says xml is fine this approach says
something
> > wrong. Please help
> >
> > Output:
> > ./SchemaValidator test.xsd test.xml
> > ===> At line 2 Column 89, no declaration found for element 'p:test_in'
> > <====
> > XML file doesn't conform to the schema
> >
> >
> > Question :
> > 1. Why DOMLSParser works but XercesDOMParser complaining about element.
> > 2. can you someone explaining to me that difference between DOMLSParser
> > and XercesDOMParser classes and their pros and cons.
> >
> > PS : I am very new to xml and xerces lib. Any help would appropriated.
> >
> > Attachments :
> > -------------
> > http://old.nabble.com/file/p32503845/test.xml test.xml
> > http://old.nabble.com/file/p32503845/test.xsd test.xsd
> > http://old.nabble.com/file/p32503845/SchemaValidator.cpp
> > SchemaValidator.cpp
> > http://old.nabble.com/file/p32503845/load-grammar-dom.cpp
> > load-grammar-dom.cpp
> >
> >
> > Thanks
> > Suresh.
> >
> >
> >
>
> --
> View this message in context: http://old.nabble.com/XercesDOMParser-
>
and-DOMLSParser-Schema-validation-is-not-the-same-tp32503845p32503968.html
> Sent from the Xerces - C - Users mailing list archive at Nabble.com.
Re: XercesDOMParser and DOMLSParser Schema validation is not the
same
Posted by Alberto Massari <Al...@progress.com>.
Hi Suresh,
I had already replied you (on the mailing list; are you subscribed?)
Anyhow, this is what I wrote you:
if you want to re-use during the parsing the grammar that you manually
load, you need to add the third argument of loadGrammar, setting it to
true. Otherwise you are parsing the schema, but not caching it for later
use.
Alberto
Il 26/09/2011 22:45, unique_suresh ha scritto:
> Guys Please suggest. I am waiting for input you.
>
> Thanks in advance.
>
> -Suresh
>
>
> unique_suresh wrote:
>> Hi All,
>>
>> I am new to Xerces lib and XML approach here. I have created XSD and also
>> I created test.xml file. Where I want to validate xml with test.xsd file.
>> Here I want to provide namespace p for all the elements by default and
>> including attributes. However I have got two sample code from internet I
>> am trying to run both of them.
>>
>> Xerces Version used : 3.1.1
>> OS : Linux
>>
>> Files : test.xml test.xsd
>>
>> Code :
>> load-grammar-dom uses DOMLSParser class to load grammer and validate xml.
>> SchemaValidator.cpp uses XercesDOMParser class to load grammer and
>> validate xml.
>>
>>
>> Here is my problem,
>>
>> 1. Using DOMLSParser validate works fine I dont see any issues with the
>> code / files
>>
>>
>> Output:
>> ./load-grammar-dom test.xsd test.xml
>> loading test.xsd
>> parsing test.xml
>> Validation successful !!!
>>
>>
>> 2. Using XercesDOMParser I am getting error message saying " At line 2
>> Column 89, no declaration found for element 'p:test_in' . I dont
>> understand that one approach says xml is fine this approach says something
>> wrong. Please help
>>
>> Output:
>> ./SchemaValidator test.xsd test.xml
>> ===> At line 2 Column 89, no declaration found for element 'p:test_in'
>> <====
>> XML file doesn't conform to the schema
>>
>>
>> Question :
>> 1. Why DOMLSParser works but XercesDOMParser complaining about element.
>> 2. can you someone explaining to me that difference between DOMLSParser
>> and XercesDOMParser classes and their pros and cons.
>>
>> PS : I am very new to xml and xerces lib. Any help would appropriated.
>>
>> Attachments :
>> -------------
>> http://old.nabble.com/file/p32503845/test.xml test.xml
>> http://old.nabble.com/file/p32503845/test.xsd test.xsd
>> http://old.nabble.com/file/p32503845/SchemaValidator.cpp
>> SchemaValidator.cpp
>> http://old.nabble.com/file/p32503845/load-grammar-dom.cpp
>> load-grammar-dom.cpp
>>
>>
>> Thanks
>> Suresh.
>>
>>
>>