-
Notifications
You must be signed in to change notification settings - Fork 886
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
Parsing of custom message attributes #69
base: master
Are you sure you want to change the base?
Conversation
Custom arguments are then stored via an extension
👍 |
I've replied at https://community.igniterealtime.org/message/255393#255393 |
@@ -194,4 +198,17 @@ public static URI getUriFromNextText(XmlPullParser parser) throws XmlPullParserE | |||
return uri; | |||
} | |||
|
|||
public static Map<String, String> getCustomAttributes(XmlPullParser parser) { | |||
Map<String, String> customAttributes = new LinkedHashMap<>(); | |||
List<String> standardAttributes = Arrays.asList(new String[] {"xml:lang", "id", "to", "from", "type"}); |
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.
Why construct this every time the method is called? And why is it a List
? This should be a static Set
.
I've just looked at this again, and I think that public static Map<String, String> getCustomAttributes(XmlPullParser parser) {
Map<String, String> customAttributes = new LinkedHashMap<>();
for (int i = 0; i < parser.getAttributeCount(); i++) {
String attributeName = parser.getAttributeName(i);
boolean isLangAttribute = "lang".equals(attributeName) && "xml".equals(parser.getAttributePrefix(i));
if (!Stanza.REGISTERED_ATTRIBUTES.contains(attributeName) && !isLangAttribute) {
String attributeValue = parser.getAttributeValue(i);
customAttributes.put(attributeName, attributeValue);
}
}
return customAttributes;
} should take the attribute prefix into account and eventually prefix it. This is untested, but I believe that if we have <element xmlns='foo' xmlns:myns='https://my.org' attr1='x' myns:attr2='y'> then the current code would produce a map of
while it should produce a map like
If that's the case, then this should be fixed and a unit test for this should be created. |
Are you still up to pursue this further? Let me know if not, if so I probably squash it myself and add the missing features. |
Hi Flow, |
We definitely need this 👍! |
This pull request has been mentioned on Ignite Realtime Community Forums. There might be relevant details there: https://discourse.igniterealtime.org/t/support-for-custom-top-level-stanza-attributes/81376/2 |
This pull request has been mentioned on Ignite Realtime Community Forums. There might be relevant details there: https://discourse.igniterealtime.org/t/unable-to-get-message-data/85920/3 |
More explanations here : https://community.igniterealtime.org/message/255265#255265