GNOME Bugzilla – Bug 742620
No way to xinclude from an included stylesheet
Last modified: 2021-07-05 11:00:00 UTC
You can use xinclude in a stylesheet with: xslt-proc --xinclude-style. However, if you have a toplevel stylesheet which includes other stylesheets, the xincludes will only work on the toplevel stylesheet. This isn't just xslt-proc, but a hole in the libxslt API I think. There's no way to specify you want xincludes on your stylesheets using libxslt. The way xslt-proc does it is to manually import with libxml for xincludes and hand that off to libxslt. But that only functions for the toplevel stylesheet and not other stylesheets it imports. An example might clarify, take the following files... ===style.xsl=== <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2003/XInclude"> <xsl:include href="style-included.xsl"/> <xsl:template match="/"> <html> <p>In toplevel style sheet:</p> <xi:include href="xincluded.xml"/> <xsl:call-template name="style-include"/> </html> </xsl:template> </xsl:stylesheet> ===style-include.xsl=== <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xi="http://www.w3.org/2003/XInclude"> <xsl:template name="style-include"> <p>In included style sheet:</p> <xi:include href="xincluded.xml"/> </xsl:template> </xsl:stylesheet> ===xincluded.xml=== <p>XInclude is working!</p> ===in.xml=== <tag/> The output from runnning xsltproc --xincludestyle style.xsl in.xml is <html xmlns:xi="http://www.w3.org/2003/XInclude"> <p>In toplevel style sheet:</p> <p>XInclude is working!</p> <p>In included style sheet:</p> <xi:include href="xincluded.xml"></xi:include> </html> The second xi:include is never processed.
Created attachment 294125 [details] Example files in bug description
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxslt/-/issues/ Thank you for your understanding and your help.