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 Minimol M <m....@gmail.com> on 2006/08/01 10:31:15 UTC

Re: Using schema within instance document

Hi Alberto,
Thanks for the reply.
Can you please tell me how to redefine the startElement method in the call
back class?  Sorry, I haven't worked with SAX Parser.

Regards
Mini.


On 7/26/06, Alberto Massari <am...@datadirect.com> wrote:
>
> Hi Mini,
>
> At 11.50 12/07/2006 +0200, Minimol M wrote:
> >Hello,
> >
> >I am new to Xerces-C.  I want to validate the XML file with the
> >schema referenced within the instance doucment if there is one, otherwise
> >use a schema from an external location.  For using a schema from the
> >external location, I use the following code and it works fine.
> >
> >[...]
> >
> >Can anybody tell me how I can check whether a schema is referenced in the
> >instance document?
>
> You will have to parse the file in order to find out if it has the
> XSI attributes defined in the root element; just create a callback
> class that only redefine the startElement method, create a SAX2
> parser, and invoke parseFirst/parseNext until your startElement is
> invoked and you can inspect the attributes of the root node.
>
> Hope this helps,
> Alberto
>
>

Re: Using schema within instance document

Posted by Alberto Massari <am...@datadirect.com>.
At 10.31 01/08/2006 +0200, Minimol M wrote:
>Hi Alberto,
>Thanks for the reply.
>Can you please tell me how to redefine the startElement method in the call
>back class?  Sorry, I haven't worked with SAX Parser.

Have a look at the example SAX2Count; the SAX2CountHandlers.cpp 
source contains such a redefined method.

Alberto


>Regards
>Mini.
>
>
>On 7/26/06, Alberto Massari <am...@datadirect.com> wrote:
>>
>>Hi Mini,
>>
>>At 11.50 12/07/2006 +0200, Minimol M wrote:
>> >Hello,
>> >
>> >I am new to Xerces-C.  I want to validate the XML file with the
>> >schema referenced within the instance doucment if there is one, otherwise
>> >use a schema from an external location.  For using a schema from the
>> >external location, I use the following code and it works fine.
>> >
>> >[...]
>> >
>> >Can anybody tell me how I can check whether a schema is referenced in the
>> >instance document?
>>
>>You will have to parse the file in order to find out if it has the
>>XSI attributes defined in the root element; just create a callback
>>class that only redefine the startElement method, create a SAX2
>>parser, and invoke parseFirst/parseNext until your startElement is
>>invoked and you can inspect the attributes of the root node.
>>
>>Hope this helps,
>>Alberto
>>