Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change xsltMaxDepth (--maxdepth) value? - where? #50

Open
Roko131 opened this issue Nov 17, 2016 · 4 comments
Open

Change xsltMaxDepth (--maxdepth) value? - where? #50

Roko131 opened this issue Nov 17, 2016 · 4 comments

Comments

@Roko131
Copy link

Roko131 commented Nov 17, 2016

Hi, I'm using Rails 3.2.12 with your Gem to create a big docx file containing the site's users with their details.

It works great with a few users, but when there are more than a few I'm getting the following error:

xsltApplyXSLTTemplate: A potential infinite template recursion was detected.
You can adjust xsltMaxDepth (--maxdepth) in order to raise the maximum number of nested template calls and variables/params (currently set to 3000).

I'm not familiar with xslt, I didn't find where I should add the maxdepth parameter-
Any ideas?

Thank you.

Full error, and what I'm trying to do below:

RuntimeError: runtime error: file C:/row/Ruby21/lib/ruby/gems/2.1.0/gems/htmltoword-0.5.1/lib/htmltoword/xslt/inline_elements.xslt line 7 element copy
xsltApplyXSLTTemplate: A potential infinite template recursion was detected.
You can adjust xsltMaxDepth (--maxdepth) in order to raise the maximum number of nested template calls and variables/params (currently set to 3000).
Templates:
#0 name node()|@*
#1 name node()|@*
#2 name node()|@*
#3 name node()|@*
#4 name node()|@*
#5 name node()|@*
#6 name node()|@*
#7 name node()|@*
#8 name node()|@*
#9 name node()|@*
#10 name node()|@*
#11 name node()|@*
#12 name node()|@*
#13 name node()|@*
#14 name node()|@*
Variables:
from C:/row/Ruby21/lib/ruby/gems/2.1.0/gems/htmltoword-0.5.1/lib/htmltoword/document.rb:88:in `transform'

More details:

I'm trying to send a mail with the docx file as attachment (It does work, but not with many users):

class MyMailer < ActionMailer::Base
  default from: "noreply@mail.net"
  default to: "mail@gmail.com"

  def send_word_files(users)
    body = ''
    users.each do |user|
      user.fields.each do |field|
        
        body << "<h2>#{field.label_name}:</h2>"
        body << "</p>#{user.field_value(field)}</p>"
      end
      body << '<div class="-page-break"></div>'
    end
    attachments["users.docx"] = Htmltoword::Document.create("<html><head></head><body>#{body}</body></html>")
  
    mail(subject: "word file", body: 'enjoy')
  end

end
@adamtomecek
Copy link

Did you find a solution to this?

@Roko131
Copy link
Author

Roko131 commented May 19, 2017

No, what I ended up doing was making a docx file for every 50 users- so I got like 10 docs files for 500 users...

Please let me know if you find another solution.

Or if you couldn't find one, take a look at this Gem: Caracal

@adamtomecek
Copy link

Well my solution is to create wrapper div for every group of 3000 nodes, which gives you enough space to overcome this limitation.

@JenniferSpry
Copy link

@adamtomecek Your comment just saved my day! Adding a seemingly useless div also solved this for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants