public void writeAttribute(String prefix, String ns, String local, String value) throws XMLStreamException { String key = convention.isElement(prefix, ns, local) ? convention.createKey(prefix, ns, local) : convention.createAttributeKey(prefix, ns, local); JSONPropertyString prop = new JSONPropertyString(key, null); prop.addText(value); current = current.withProperty(prop, false); }
@Override public boolean isElement(String p, String ns, String local) { if (p == null) p = ""; if (ns == null) ns = ""; return super.isElement(p, ns, local); } }
public void writeAttribute(String p, String ns, String local, String value) throws XMLStreamException { if (convention.isElement(p, ns, local)) { writeStartElement(p, local, ns); writeCharacters(value); writeEndElement(); return; } String key = convention.createAttributeKey(p, ns, local); try { if (current instanceof JSONArray) { JSONArray array = ((JSONArray) current); current = array.get(array.length() - 1); } makeCurrentJSONObject(); if (current instanceof JSONObject) { Object o = ((JSONObject) current).opt(key); if (o == null) { ((JSONObject) current).put(key, value); } } } catch (JSONException e) { throw new XMLStreamException(e); } }