<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
I am stumped. Probably doing something stupid but I just cannot get
document('') to work with lxml, but it does work when the .xsl is sent
to the browser (ff) and it does work with xsltproc<br>
<br>
I think there's been a change in libxslt at some point, but I don't
know exactly what changed.<br>
<br>
This deployment works:<br>
<br>
RHEL4 linux with libxml2 2.6.27 and libxslt 1.1.18, with lxml 2 alpha4<br>
<br>
this deployment does not work:<br>
<br>
Centos 4 with libxml2 2.6.28 and libxslt 1.1.19 with lxml 2 alpha 3<br>
<br>
So I upgraded to libxml2 2.6.30, libxslt 1.1.22 and lxml 2 beta 2<br>
But it still doesn't work correctly.<br>
<br>
I am passing a base_url when creating documents using etree.fromstring<br>
<br>
I've traced the execution of document('') via gdb, both in
libxslt/functions.c and libxslt/documents.c<br>
<br>
For example, in libxslt/functions.c<br>
<br>
142 idoc = xsltLoadDocument(tctxt, URI);<br>
(gdb) print URI<br>
$7 = (xmlChar *) 0x90e7c00 "/carrier_payables/view.htm"<br>
<br>
the correct uri (what I passed for base_url) is shown<br>
<br>
and <br>
<br>
Now in documents.c line 315::<br>
<br>
317 if ((ret->doc != NULL) &&
(ret->doc->URL != NULL) &&<br>
(gdb) print ret->doc<br>
$11 = 0x90d6ef8<br>
(gdb) print ret->doc->URL<br>
$12 = (const xmlChar *) 0x90dca08 "/carrier_payables/view.htm"<br>
(gdb) print URI<br>
$13 = (const xmlChar *) 0x90e7c00 "/carrier_payables/view.htm"<br>
<br>
<br>
so all seems to be correct, it is returning the expected document back
to the xpath evaluator.<br>
<br>
I'm stumped that it works with older versions of libxslt, works with
client-side transform, and works with xsltproc, but not through lxml
with "newer libxslt"<br>
<br>
<br>
Can anyone suggest some other steps I can use to diagnose this
problem? I'm sure I've done something wrong with how I am using<br>
lxml, but I can't figure it out.<br>
<br>
My .xsl looks (in part) like this. Its loaded using etree.fromstring
with a base_url:<br>
<br>
<tt><?xml version="1.0"?><br>
<xsl_:stylesheet xmlns:xsl_=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/1999/XSL/Transform">"http://www.w3.org/1999/XSL/Transform"</a>
xmlns:metal=<a class="moz-txt-link-rfc2396E" href="http://xml.zope.org/namespaces/metal">"http://xml.zope.org/namespaces/metal"</a> <br>
xmlns:tal=<a class="moz-txt-link-rfc2396E" href="http://xml.zope.org/namespaces/tal">"http://xml.zope.org/namespaces/tal"</a> xmlns:const="const.uri"
version="1.0" exclude-result-prefixes="tal metal const"><br>
<xsl_:output encoding="utf-8" method="xml"
omit-xml-declaration="no" cdata-section-elements=""
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" <br>
doctype-system=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</a>/><br>
<const:javascript id="number_pad_javascript"><br>
<const:file>MochiKit/MochiKit.js</const:file><br>
<const:file>jstal/jstal.js</const:file><br>
<const:file>global.js</const:file><br>
<const:file>view.js</const:file><br>
</const:javascript><br>
<xsl_:template match="/"><br>
<html xmlns=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/1999/xhtml">"http://www.w3.org/1999/xhtml"</a>><br>
<head><br>
<title><br>
View Carrier Payables<br>
</title><br>
<link rel="stylesheet" type="text/css"
href="/css/default.css"/><br>
<link rel="stylesheet" media="print" type="text/css"
href="/css/print.css"/><br>
</head><br>
<body><br>
<div id="ajax-indicator" style="display:none"
class="no-print"><br>
<img title="some title" width="24" height="24"
src="/images/ajax_indicator.gif"/><br>
</div><br>
<xsl_:for-each
select="document('')//const:javascript/const:file"><br>
<xsl_:variable name="file" select="."/><br>
<script type="text/javascript"><br>
<xsl_:attribute name="src"><br>
<xsl_:value-of select="concat('/scripts/', $file)"/><br>
</xsl_:attribute><br>
</script><br>
</xsl_:for-each><br>
<div>more stuff</div><br>
</body><br>
</html><br>
</xsl_:template><br>
</tt><tt></xsl_:stylesheet></tt><br>
<pre class="moz-signature" cols="72"><font color="#330033">using xsltproc against a source xml file:
<root />
produces this output</font>
</pre>
<br>
<tt><?xml version="1.0" encoding="utf-8"?><br>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</a>><br>
<html xmlns=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/1999/xhtml">"http://www.w3.org/1999/xhtml"</a>><br>
<head><br>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" /><br>
<title><br>
View Carrier Payables<br>
</title><br>
<link rel="stylesheet" type="text/css" href="/css/default.css"
/><br>
<link rel="stylesheet" media="print" type="text/css"
href="/css/print.css" /><br>
</head><br>
<body><br>
<div id="ajax-indicator" style="display:none"
class="no-print"><br>
<img title="some title" width="24" height="24"
src="/images/ajax_indicator.gif" /><br>
</div><br>
<script type="text/javascript"
src="/scripts/MochiKit/MochiKit.js"></script><br>
<script type="text/javascript"
src="/scripts/jstal/jstal.js"></script><br>
<script type="text/javascript"
src="/scripts/global.js"></script><br>
<script type="text/javascript"
src="/scripts/view.js"></script><br>
<div>more stuff</div><br>
</tt> <br>
<br>
But with lxml, I get:<br>
<br>
<tt><?xml version="1.0" encoding="utf-8"?><br>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</a>><br>
<html xmlns=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/1999/xhtml">"http://www.w3.org/1999/xhtml"</a>><br>
<head><br>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" /><br>
<title><br>
View Carrier Payables<br>
</title><br>
<link rel="stylesheet" type="text/css" href="/css/default.css"
/><br>
<link rel="stylesheet" media="print" type="text/css"
href="/css/print.css" /><br>
</head><br>
<body><br>
<div id="ajax-indicator" style="display:none"
class="no-print"><br>
<img title="some title" width="24" height="24"
src="/images/ajax_indicator.gif" /><br>
</div><br>
<div>more stuff</div><br>
</tt><br>
<br>
I am using a custom resolver. The resolver is not asked to resolve the
.xsl stylesheet, nor is it asked to resolve ''<br>
<br>
p-code is like this:<br>
<br>
parser = etree.XMLParser(load_dtd=True)<br>
parser.resolvers.add(Resolver(resolver=my_resolver))<br>
stylesheet_doc = etree.fromstring(xslt_src, parser,
base_url=xsl_uri)<br>
stylesheet = etree.XSLT(stylesheet_doc)<br>
<br>
likewise the source xml is loaded in the same way<br>
<br>
parser = etree.XMLParser(load_dtd=True)<br>
parser.resolvers.add(Resolver(resolver=my_resolver))
<br>
xml_doc = etree.fromstring(xml_src, parser,
base_url=xml_uri)<br>
<br>
finally <br>
<br>
return stylesheet(xml_doc, **params)<br>
<br>
<br>
-- <br>
Brad Clements, <a class="moz-txt-link-abbreviated" href="mailto:bkc@murkworks.com">bkc@murkworks.com</a> (315)268-1000<br>
<a class="moz-txt-link-freetext" href="http://www.murkworks.com">http://www.murkworks.com</a> <br>
AOL-IM: BKClements
</body>
</html>