xerces-c-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alberto Massari <Alberto.Mass...@progress.com>
Subject Re: Please Help : XercesDOMParser and DOMLSParser Schema validation is not the same
Date Tue, 27 Sep 2011 16:25:09 GMT
Hi Suresh,
you cannot expect that this XML is going to load an external schema:

<p:test_in  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="urn:TEMP"xmlns="urn:TEMP"p:SchemaLocation="urn:TEMP
test_in.xsd">

You use a SchemaLocation attribute defined in your personal namespace 
"urn:TEMP"; no parser would ever imagine that you want it to treat it as 
a reference to a schema to be loaded.
You can find the proper way at 
http://xerces.apache.org/xerces-c/schema-3.html  (section "Specifying 
Schema Grammar through attributes in the instance document")

Alberto

Il 27/09/2011 18:06, unique_suresh ha scritto:
> Hello Alberto,
>
>   Thanks for your reply. Its working with third flag enabled. Thanks a lot.
> =)
>
> Now I am trying to load Schema from XML attribute instead of external
> loading. While I am trying to avoid external loading XSD so decided to use
> XMLEntityResolver based on sample from Xerces and internet. When I use
> noNamespece XML with XSD the callback function "resolveEntity" called by
> parser if I use xml with namespece then it is not working.
>
> I think, I was missing some flags to set before parsing xml file OR
> something wrong with my XML/XSD. But I don't have any issue for same xml
> file if load grammar externally with specific file path. ( Which we have
> discussed before)
>
> Overall, the idea is to auto load xsd by parsing attribute info from xml and
> call XMLEntityResolver to redirect the path to local file system. But I
> never received call back to "resolveEntity" function.
>
> Please note that, the same code works fine for NoNamespce xml but Something
> I am missing here to work for with Name-space. Can you please help.
>
> http://old.nabble.com/file/p32532099/SchemaValidator1.cpp
> SchemaValidator1.cpp
> http://old.nabble.com/file/p32532099/test1.xml test1.xml
> http://old.nabble.com/file/p32532099/test1.xsd test1.xsd
>
>
> Thanks in advance.
>
> -Suresh
>
>
>
> Hi Suresh,
> 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
>


Mime
View raw message