You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An error undefined method 'xpath' for nil:NilClass @rels.xpath("//xmlns:Relationship[contains(@Type,'hyperlink')]") is raised when the object fails to load the documents styles because the @rels variable did not load due to method coupling between load_rels and load_styles, making it so that if an error occurs when loading file styles the @rels variable is not loaded into the object.
To Reproduce
1- Create a .docx file with missing styles, so that load_styles method will return a No such file or directory - word/styles.xml message;
2- Try and access the paragraphs property of the loaded doc object with doc.paragraphs;
example
require'docx'doc=Docx::Document.new('/path/to/your/docx/file.docx')doc.send(:load_styles)# No such file or directory - word/styles.xmldoc.paragraphs.eachdo |p|
putspend
Sample docx file
Cannot add the sample due to having confidential information in it and I do not have the means to save a docx file that will preserve the broken style used in it.
Expected behavior
Expected to be able to parse the document's text without issue when style is not present.
Describe the bug
An error
undefined method 'xpath' for nil:NilClass @rels.xpath("//xmlns:Relationship[contains(@Type,'hyperlink')]")
is raised when the object fails to load the documents styles because the@rels
variable did not load due to method coupling betweenload_rels
andload_styles
, making it so that if an error occurs when loading file styles the@rels
variable is not loaded into the object.To Reproduce
1- Create a
.docx
file with missing styles, so thatload_styles
method will return aNo such file or directory - word/styles.xml
message;2- Try and access the
paragraphs
property of the loadeddoc
object withdoc.paragraphs
;example
Sample docx file
Cannot add the sample due to having confidential information in it and I do not have the means to save a
docx
file that will preserve the broken style used in it.Expected behavior
Expected to be able to parse the document's text without issue when style is not present.
Environment
docx
gem version: ~> 0.8.0The text was updated successfully, but these errors were encountered: