Re: [xml] xmlRegisterInputCallbacks() from Python? CRASH
- From: "Brad Clements" <bkc murkworks com>
- To: xml gnome org
- Subject: Re: [xml] xmlRegisterInputCallbacks() from Python? CRASH
- Date: Sun, 23 Feb 2003 12:33:54 -0500
On 8 Feb 2003 at 17:04, Daniel Veillard wrote:
On Sat, Feb 08, 2003 at 05:01:38PM -0500, Brad Clements wrote:
I need to be able to register an input callback from within Python so I
can override the http: uri scheme handler.
check the examples !
python/tests/resolver.py
-----------------
def myResolver(URL, ID, ctxt):
return(StringIO.StringIO("<foo/>"))
libxml2.setEntityLoader(myResolver)
Daniel, Thanks for your fast answer last week.
One thing I noticed is that if I pass libxml2.setEntityLoader a bound method object, I get
a GPF under windows when trying to load a stylesheet.
For example,
class myclass:
def Resolver(self,URL,ID,ctxt):
print "RESOLVE:",URL,ID,ctxt
try:
f = self.filehandler.getFileObject(URL.split('/'))
except:
traceback.print_exc()
raise
return f.fileObject()
def setup(self):
libxml2.setEntityLoader(self.Resolver)
...
style = libxslt.parseStylesheetDoc(styleDoc)
boom.
It works if I use a top level function.
Is there a way to set the entity resolver on just the base .xml document?
And I'd want to pass a bound method object, not a global function.
I've tried finding "setEntityLoader" in the html docs, alphabetic, modules, etc, but I can't
find it. Probably because it's a python-only thing.
--
How do I "apply the default stylesheet" to an XML document? That is, I have an .xml
document that specifies it's stylesheet. Instead of creating the top level stylesheet
directly and processing the xml that way,
ie, my .xml has:
<?xml-stylesheet type="text/xsl" href="user.xsl" ?>
Is there an easy way to simple say..
doc = libxml2.parseDoc(xml)
doc.ApplyDefaultStylesheet(params)
Which would cause my registered Resolver to get called looking for user.xsl
I'm trying to get medusa to serve .htm and .xml files, where the client or the server can
do the xml->html conversion.
How do I specify the base URI for a document loaded from a string? Do I do
doc.root.setBaseURI('/configure/user.xml')
--
Brad Clements, bkc murkworks com (315)268-1000
http://www.murkworks.com (315)268-9812 Fax
http://www.wecanstopspam.org/ AOL-IM: BKClements
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]