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

Consider pure R node representation? #143

Closed
hadley opened this Issue Oct 27, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@hadley
Member

hadley commented Oct 27, 2016

make_node <- function(name, children = list(), attr = list()) {
  # Check that children is a list
  # Check that attributes is a named list

  structure(
    name = name,
    children = children,
    attr = attr,
    class = "r_xml_node"
  )
}

node <- function(name, ...) {
  parts <- list(...)
  has_names <- names(parts)

  make_node(
    name,
    children = parts[!has_names],
    attr = parts[has_names]
  )
}

This would make it easier to have a symmetric as_list() and as_xml(). However, we need to scope this carefully as we don't want to end up in like XML where you have two alternative representations and each function only works with one.

jimhester added a commit that referenced this issue Dec 19, 2016

`as_xml()` generic function to convert R objects to xml
The most important method is for lists and enables full roundtrip
support for going to and back from xmfor lists and enables full
roundtrip support to and from XML.

Closes #137, #143

@jimhester jimhester closed this Dec 19, 2016

@jimhester

This comment has been minimized.

Member

jimhester commented Dec 19, 2016

We can do full round tripping without needing to do this now 1f820d8

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