Re: [xml] setting URL for xmlRelaxNGParserCtxt?



On Tue, Jan 25, 2005 at 08:14:22PM +0100, Martijn Faassen wrote:
Hi there,

In my lxml Python binding for libxml2, I was using the following 
approach to construct a Relax NG schemas:

xmlDocPtr* doc = ...
parser_ctxt = xmlRelaxNGNewDocParserCtxt(doc)

unfortunately, this got me into trouble with Relax NG schemas that use 
the 'include' statement. They try to load the files to be included, but 
have no idea where to look, as this information is lost.

Glancing through the source, it seems like the only way to make the 
'include' statement work is to use xmlRelaxNGNewParserCtxt, which takes 
a URL.

   Wrong. How did you built "doc" ?  If it's from a memory string you can
still define the base for that document by providing the URL argument
of xmlReadMemory().

Would it be useful to have a way to supply this URL to an existing 
xmlRelaxNGParserCtxtPtr? Something like:

  no the base has to be set in the document. Since that part is just
described by '...' in your mail there is little more indications I can
provide.

void xmlRelaxNGSetURL(xmlRelaxNGNParserCtxtPtr* ctxt, const char* URL)

  The base is a property of the document, not of the relax-NG transformation
compilation, this is really the wrong approach.

I imagine the same issues come up when using XSLT that tries to include 
or import external stylesheets.

  yes the base is *in* the document.
  xmlNodeSetBase(xmlNodePtr cur, const xmlChar* uri)
to be called on your document. But it should really be there as the result
of parsing.

Daniel

-- 
Daniel Veillard      | Red Hat Desktop team http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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