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

XmlEventAttribute is missing namespace #54

Closed
dnfield opened this issue Jan 26, 2019 · 5 comments
Closed

XmlEventAttribute is missing namespace #54

dnfield opened this issue Jan 26, 2019 · 5 comments
Assignees

Comments

@dnfield
Copy link
Contributor

dnfield commented Jan 26, 2019

Attributes can be in a specific namespace - the API doesn't support this currently.

@dnfield
Copy link
Contributor Author

dnfield commented Jan 26, 2019

Actually, it looks like this is the case for XmlEventStartElement too... the name should probably be an XmlName instead of a string in both cases.

@renggli
Copy link
Owner

renggli commented Jan 26, 2019

True, I had it like that in my initial attempt where I reused the normal DOM nodes. The problem with XmlName is as with all the other DOM objects that many things simply don't work outside of that space (ownership navigation, namespace resolution, ...).

To keep events lightweight it would probably be the simplest to add separate accessors for the local name, the qualified name (what is currently returned), and the namespace prefix?

@renggli
Copy link
Owner

renggli commented Jan 26, 2019

What do you think about adding the following mixin to the events with name:

abstract class XmlNamed {
  /// The fully qualified name.
  String get name;

  /// The namespace prefix, or `null`.
  String get namespacePrefix {
    final index = name.indexOf(XmlToken.namespace);
    return index > 0 ? name.substring(0, index) : null;
  }

  /// The local name, excluding the namespace prefix.
  String get localName {
    final index = name.indexOf(XmlToken.namespace);
    return index > 0 ? name.substring(index + 1) : name;
  }
}

@renggli
Copy link
Owner

renggli commented Jan 26, 2019

If this is ok, I can make a new release with e6c0458?

@renggli renggli self-assigned this Jan 28, 2019
@renggli
Copy link
Owner

renggli commented Jan 28, 2019

I've released this as 3.3.1 on pub.

@renggli renggli closed this as completed Jan 28, 2019
gothamgasworks pushed a commit to gothamgasworks/dart-xml that referenced this issue Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants