-
Notifications
You must be signed in to change notification settings - Fork 11
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
[wb_load] read x namespace #405
Conversation
allow optional import of file with x namespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding in some information what the x namespace is could be helpful when people counter this. I don't know what it is or any of the implications of changing these values are, so I'd certainly be confused.
The example file used in the test wraps Our xml nodes look like this In theory this namespace does not have to be named x and could be something else, though I didn't really want to search for other namespaces. In openxml there are various namespaces like |
The more general fix would be to read the header and replace the namespace whenever they are found. But I wanted something that works quick and does not interfere with the overwhelming majority of files we import. If we get reports that users experience plenty of these warnings, we can have a look at the c++ loading functions of pugixml and see if we can implement a remove namespace wrapper there. |
Maybe we can then use the options like: options(openxlsx2.xml_namespace = "x") # maybe `TRUE` defaults to `"x"`? or options(openxlsx2.xml_namespace = c("foo", "bar"))) then check to see if any have been specified? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From some quick searches this morning it sounds like the default x
namespace can be particular annoying and prevent other software from correctly parsing the xml. It seems the go-to move is to remove the namespaces, so us doing it sounds right, especially if it's something the user has to opt into.
Haha, mate don't make this overly complicated for us. But your suggestions sound reasonable, I'll adjust the PR later. |
Should be good to go now. |
allow reading files with x namespace
what was the motivation for this PR?
This fixes import for files created by third party software as seen in ycphs/openxlsx#344.
Maybe one of you can test this @Matpli, @elinw? You can build this branch using:
what does this PR do?
I have taken the initial #213 and created a few more safeguards to make sure that we do not have to check every xml file we import.
x:workbook
in/xl/workbook.xml
options("openxlsx2.has_x_namespace" = TRUE)
xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main"
, we will remove thex
namespace from the inputIt works with the example file provided by @Matpli and if I save this file I can open it in MS365. But this file is quite large so if anyone can provide a smaller example file, that would be great.