-
Notifications
You must be signed in to change notification settings - Fork 39
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
New versions of create_root, new_child, etc with attributes and inner text #35
Comments
Could be additional methods using keyword arguments, I suppose. I'd look over a pull request. |
Would there be an issue with having them defined as methods with positional arguments, rather than keyword arguments, and letting dispatch choose the appropriate one? I will try and submit a pull request if I can figure out how |
The issue with positional arguments is whether the particular order is a clear API. Sometimes it's clearer to have named inputs. For example with attributes and text, what if you want to add text but not have any attributes? I also lean towards separating functionality out into smaller, more composable pieces, so I'm not sure what trying to put everything into the same list of arguments for a single function call accomplishes. |
Wouldn't it make sense to pass all attributes as keyword arguments, like this? function create_root(xdoc::XMLDocument,
name::AbstractString; # Notice the semicolon
attrs...) @315234 See Compat.jl to get things working on both 0.3 and 0.4. |
That would only work for assigning to attributes whose names are valid Julia identifiers (so no keywords, no punctuation), but otherwise would be consistent with one of the signatures of |
Right. There could be an alternative method taking a |
Actually, doing |
This is a feature request to add methods for creating new nodes with an attribute dictionary, like this:
This would remove the need for additional calls to
set_attributes
oradd_text
and make the creation of new elements much more streamlined, for example:The text was updated successfully, but these errors were encountered: