Compilation of an XSLT stylesheet fails if an imported stylesheet imports another stylesheet

Bug #101411 reported by Walco van Loon
8
Affects Status Importance Assigned to Milestone
Silva
Fix Released
Medium
Unassigned

Bug Description

Compilation of an XSLT stylesheet fails if an imported stylesheet imports
another stylesheet.

This bug leads to limited reuse of existing stylesheets and stylesheet duplication.

Revision history for this message
Eric Casteleijn (thisfred) wrote :

Ah yes. I can see how this is caused, but not a readymade solution yet. Since
the import doesn't work with relative paths (thank you W3C) I (well Guido W.
really. He deserves all credit.) had to make use of string interpolation to pass
the right path into the xslt. Of course that doesn't work for 2nd or higher
level imports. I'll have a bit of a think about this. Maybe this will force us
to get rid of the ugliness altogether.

Revision history for this message
Andy Altepeter (aaltepet) wrote :

perhaps try using an custom python xslt function to resolve this? I don't know...

Changed in silva:
assignee: nobody → aaltepet
Revision history for this message
Andy Altepeter (aaltepet) wrote :

I tried using an extension function to dynamically generate an absolute url to the imported stylesheets. This won't work, because xsl:import _only_ allows uri references, so using an extension function isn't possible.

Relative URI's will work, however, if the stylesheet is loaded via libxslt.parseFile. Currently, as Kit points out, the stylesheet is read into a python string (so that the absolute uri can be interpolated)...relative uri's don't work with stylesheets loaded from strings, as there is to base-uri that maps to a filesystem path.

Currently, xsltrenderbase.stylesheet() does two interpolation:
1) url : this is the uri of the directory containing xsltrenderbase
2) local_url : the uri that changes according to the file context passed into xsltrenderbase.

I think we could get around this interpolation if parseFile is used instead of parseDoc.

Consider this use case:
You are developing a new stylesheet (new_normal.xslt) based off of normal_view (which uses doc_elements), in a separate product. The fs locations are:
Products/Silva/transform/renderer/
Products/XSLProduct/transform/renderer

new_normal.xslt has the following xsl:import
<xsl:import href="../../../Silva/transform/renderer/normal_view.xslt" />
normal_view.xslt has the following xsl:import:
<xsl:import href="doc_elements.xslt" />

This should work, given that the both products are installed in the same products directory. (Zope does allow multiple products directories to be used in one client...if Silva was in one product dir, while XSLProduct in another, then this method will not work.

So, the above is the only method I can see that will get around needing to interpolate the stylesheet, thus making it impossible to reuse stylesheets.

Changed in silva:
assignee: aaltepet → kitblake
Revision history for this message
Eric Casteleijn (thisfred) wrote :

We are reusing stylesheets in different products through the interpolation method right now, but yes, this would be a great improvement. I remember not getting this to work, but I didn't come across parseFile. If using that has no other side effects, I'm all for it! Cool, Andy!

Revision history for this message
Kit Blake (kitblake) wrote :

Change assignee to aaltepet

Changed in silva:
assignee: kitblake → aaltepet
Revision history for this message
Andy Altepeter (aaltepet) wrote :

switched the xsltrendererbase to use parseFile, and updated the three Silva xslt renderers to use relative paths instead of string interpolation.

Also, I added an xmlns:silva-extra to these files, since the libxslt was giving a warning.

Changed in silva:
status: Confirmed → Fix Committed
Changed in silva:
milestone: none → 2.1
Changed in silva:
assignee: aaltepet → nobody
Changed in silva:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.