Error in XSL filter: "xsltParseStylesheetProcess : document is not a stylesheet"

2,023 views
Skip to first unread message

Dan Brendstrup

unread,
Nov 22, 2012, 5:48:54 PM11/22/12
to na...@googlegroups.com
I'm trying to use the XSL filter that was added in Nanoc 3.3, but I keep running into this error:

    RuntimeError: compilation error: element site
    xsltParseStylesheetProcess : document is not a stylesheet

I can force the same error if I run xsltproc on the commandline with the arguments reversed (i.e. "xsltproc content/content.xml layouts/master.xsl" rather than the correct "xsltproc layouts/master.xsl content/content.xml"), so it feels like something in the Nokogiri integration is wrong, but I can't quite pinpoint it. Has anyone else experienced this error? Or has anyone successfully used the XSL filter?

This is what I've pared my setup down to:

content/content.xml:

    <?xml version="1.0" encoding="utf-8" ?>
    <site>
      <page>
        <h1>Blogpost</h1>
      </page>
    </site>

layouts/master.xsl:

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output omit-xml-declaration="yes" indent="no"/>

      <xsl:template match="/">
        <xsl:value-of select="site/page/h1"/>
      </xsl:template>

    </xsl:stylesheet>

Rules:

    compile '*' do
      layout 'master'
    end

    route '*' do
      item.identifier.chop + '.' + item[:extension]
    end

    layout '/master/', :xsl

...and this is the full error:

    RuntimeError: compilation error: element site
    xsltParseStylesheetProcess : document is not a stylesheet

    Compilation stack:

      - [item]   /content/ (rep default)

    Stack trace:

      0. /Library/Ruby/Gems/1.8/gems/nokogiri-1.5.5/lib/nokogiri/xslt.rb:32:in `parse_stylesheet_doc'
      1. /Library/Ruby/Gems/1.8/gems/nokogiri-1.5.5/lib/nokogiri/xslt.rb:32:in `parse'
      2. /Library/Ruby/Gems/1.8/gems/nokogiri-1.5.5/lib/nokogiri/xslt.rb:13:in `XSLT'
      3. /Library/Ruby/Gems/1.8/gems/nanoc-3.4.2/lib/nanoc/filters/xsl.rb:39:in `run'
      4. /Library/Ruby/Gems/1.8/gems/nanoc-3.4.2/lib/nanoc/base/result_data/item_rep.rb:413:in `layout'
      5. /Library/Ruby/Gems/1.8/gems/nanoc-3.4.2/lib/nanoc/base/compilation/item_rep_proxy.rb:69:in `layout'
      6. /Library/Ruby/Gems/1.8/gems/nanoc-3.4.2/lib/nanoc/base/compilation/rule_context.rb:67:in `layout'
      7. ./Rules:22:in `load'
      8. /Library/Ruby/Gems/1.8/gems/nanoc-3.4.2/lib/nanoc/base/compilation/rule.rb:68:in `instance_eval'
      9. /Library/Ruby/Gems/1.8/gems/nanoc-3.4.2/lib/nanoc/base/compilation/rule.rb:68:in `apply_to'
      ... 23 more lines omitted. See full crash log for details.

Can anyone spot a problem? Am I doing something wrong?

Denis Defreyne

unread,
Dec 31, 2012, 4:15:48 AM12/31/12
to na...@googlegroups.com
Hi Dan,

I’ll look into this soon, because this doesn’t look right!

Denis
> --
> You received this message because you are subscribed to the nanoc discusssion group.
>
> To post to this group, send email to na...@googlegroups.com
> To unsubscribe from this group, send email to
> nanoc+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nanoc?hl=en

Dan Brendstrup

unread,
Jan 6, 2013, 3:58:25 PM1/6/13
to na...@googlegroups.com
Thanks, Denis! I agree, it doesn't look right, so I hope you're better than me at finding the cause :)

Cheers,
Dan

Denis Defreyne

unread,
Jan 13, 2013, 10:32:17 AM1/13/13
to na...@googlegroups.com
Hi Dan,

The XSL filter indeed did not work properly. I fixed it in the release-3.4.x branch here: https://github.com/ddfreyne/nanoc/commit/231a69ccd5e0a23afe053e28094cc93cf0245e74. Can you verify whether that one works for you?

It’ll be part of either 3.4.4 or 3.5.0, whichever comes first!

Denis

Dan Brendstrup

unread,
Jan 13, 2013, 3:58:02 PM1/13/13
to na...@googlegroups.com
Yes indeed, that cured the problem! Awesome. Thanks for your help!

- Dan


On Sunday, January 13, 2013 4:32:17 PM UTC+1, Denis Defreyne wrote:
Hi Dan,

Dan Brendstrup

unread,
Jul 27, 2013, 4:02:42 PM7/27/13
to na...@googlegroups.com
Hi Denis,

A quick bugfix, I think. I've been playing around with the XSL filter again, and although I'd swear everything seemed to work after your fix, it seems to be borked again.

The XSL stylesheet applies a transformation to itself rather than to the content to which the layout is applied. However, if I change line 39 from:

xml = ::Nokogiri::XML(content)

to this:

xml = ::Nokogiri::XML(assigns[:content])

...then it works. I'm stabbing in the dark here, but does that make sense to you?

- Dan


On Sunday, January 13, 2013 4:32:17 PM UTC+1, Denis Defreyne wrote:
Hi Dan,

Reply all
Reply to author
Forward
0 new messages