Re: [xml] Question regarding Xpath and streaming

On Wed, Jun 27, 2007 at 04:37:06PM -0700, Yong Chen (yongche) wrote:

On the same note, is there any way to validate a document (against a
schema) which is being streamed out using xmlWriter? 

"xmlSchemaValidateDoc(validCtxtPtr, doc)" needs a "doc", but when doing
streaming, I don't have the full doc available.

  Validation is usually done at parsing time. Schemas validation can
be streamed on top of the reader or SAX. There is nothing available
for the writer. For SAX see

 * xmlSchemaValidateStream:
 * @ctxt:  a schema validation context
 * @input:  the input to use for reading the data
 * @enc:  an optional encoding information
 * @sax:  a SAX handler for the resulting events
 * @user_data:  the context to provide to the SAX handler.
 * Validate an input based on a flow of SAX event from the parser
 * and forward the events to the @sax handler with the provided @user_data
 * the user provided @sax handler must be a SAX2 one.
 * Returns 0 if the document is schemas valid, a positive error code
 *     number otherwise and -1 in case of internal or API error.

there is an example of use in xmllint.c 


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]