[xml] How to access current schema information from "xmlTextReader"?



Hi all,

Is there a way to gain access to the current RNG schema
data (e.g: datatyping) within "xmlTextReaderRead()" iteration?


See below for detail:

I'm using "xmlTextReader" to read and validate xml instance docs using
Relax NG schema.

I'm using datatyping quite heavily in my RNG schema.

But in each Read() iteration, all I get access to is a "string/text"
value, not the particular datatype I've defined in my schema,

 i.e: only one API is available: xmlTextReaderConstValue().

So, after calling Read(), my application still has to "interpret"
the node's data itself (i.e: what datatype it is, etc).

It almost looks like I would have to "walkthru" my schema again
separately to determine the datatypes in addition to giving
the schema to the textReader.

This, to me, seems "redundant" because (I think) the textReader
essentially have done this datatype processing within it's
validation, right?

Can I at least get access to the RNG node to which a particular
inst node is mapped?

Then maybe I can query the RNG node to find out what's the datatype,
or any corresponding schema aspect I may need.

Or, is there better ways to do this?

Has anyone considered this as redundancy?

Sample schema/code:
 
   in my RNG schema:
 
       <element name="ANumber">
         <data type="integer"/>
       </element>


   in my application:
   
      ret = xmlTextReaderRead( reader );
     
      while ( ret == 1 ) {
         const xmlChar* nodeValue = xmlTextReaderConstValue( reader );
        
         <<< do processing of the current nodeValue (a string) >>>
        
         ret = xmlTextReaderRead( reader );
      }


As general question:

  Is there any way in libxml2 to hookup callbacks
which would be called by xmlTextReader as its doing the validation?

That way I think xmlTextReader can pass back whatever schema
information back to the user.

Thank you very much for any input.

Regards,
= Jatayu


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]