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

On Fri, May 02, 2008 at 11:42:17AM -0500, Jatayu wrote:
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?

  Honnestly I'm not sure, you can in general. RNG is not XSD
(and libxml2 doesn't implement XSD PSVI anyway). You can have 
a choice defining 2 branches, each with a <foo> element, one
validate with xsd:string and the other with xsd:integer, and
could match with either definition of the element.

  Honnestly i don't have an easy way to provide the type in libxml2
there is no PSVI defined for XSD nor RNG.

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

  No because the check can be done multiple times as we pop out
and in the in the evaluation tree of <choice> constructs.
You may get N callbacks for a single type constructs.



Red Hat Virtualization group
Daniel Veillard      | virtualization library
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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