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

Namespace support #1

Closed
dirvens opened this issue Apr 29, 2014 · 3 comments
Closed

Namespace support #1

dirvens opened this issue Apr 29, 2014 · 3 comments

Comments

@dirvens
Copy link
Contributor

dirvens commented Apr 29, 2014

Hi, I'm refactoring some code that used the original dart-xml from John Evans to this library. I've come across the namespace limitation - something that for the most part the original library supported. It would at least have the namespaces in scope traverse with the elements, and you could look up the uri based on the prefix. Do you have on your roadmap support for namespaces? If so, when do you anticipate having that in?

Thanks,

-D

@renggli
Copy link
Owner

renggli commented Apr 30, 2014

Personally I've never used XML namespaces, that's why it is missing. I don't think it would be difficult to add some basic look-up of the URI to the qualified names. I'll have a look.

@renggli
Copy link
Owner

renggli commented Apr 30, 2014

Would adding a slightly better integrated method in the core-library like the following one help?

/**
 * Find the namespace URI of a given `name` in a `node`.
 */
String getNamespaceURI(XmlName name, XmlNode node) {
  while (node != null) {
    for (var attribute in node.attributes) {
      if ((attribute.name.local == 'xmlns' && attribute.name.prefix == null && name.prefix == null)
          || (attribute.name.prefix == 'xmlns' && attribute.name.local == name.prefix)) {
        return attribute.value;
      }
    }
    node = node.parent;
  }
  return null;
}

@renggli
Copy link
Owner

renggli commented May 2, 2014

Added XmlName#namespaceURI as of 91f4ebe.

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

No branches or pull requests

2 participants